首页 > 解决方案 > 从 LLVM IR 文件编译 Apache

问题描述

我正在尝试从 LLVM IR 中间文件编译 apache2。

我能够用 clang 编译 apache2 并生成带有 LLVM IR 中间文件的 apaches 可执行文件。我能够对一些 LLVM IR 中间文件进行一些优化。现在我想从新的/修改的 LLVM-IR 文件中重新生成 apache2 可执行文件,以比较两个可执行文件的性能。

我使用 llvm-llc 从生成的 llvm 文件生成目标文件,现在当我尝试使用 clang 链接所有目标文件时,我得到了错误。以下只是我得到的错误示例:

/apache/httpd-2.4.46/srclib/apr-util/ldap/apr_ldap_init.c:92: undefined reference to `ldap_err2string'
/apache/httpd-2.4.46/srclib/apr-util/ldap/apr_ldap_option.c:603: undefined reference to `ldap_set_option'
/home/yousif/fuzz-testing/apache/httpd-2.4.46/srclib/apr-util/xml/apr_xml.c:380: undefined reference to `XML_StopParser'
dso.o: In function `dso_cleanup':
/apache/httpd-2.4.46/srclib/apr/dso/unix/dso.c:72: undefined reference to `dlclose'
dso.o: In function `apr_dso_load':
/apache/httpd-2.4.46/srclib/apr/dso/unix/dso.c:139: undefined reference to `dlopen'
/apache/httpd-2.4.46/srclib/apr/dso/unix/dso.c:153: undefined reference to `dlerror'
dso.o: In function `apr_dso_sym':
/apache/httpd-2.4.46/srclib/apr/dso/unix/dso.c:227: undefined reference to `dlsym'
/apache/httpd-2.4.46/srclib/apr/dso/unix/dso.c:231: undefined reference to `dlerror'
proc_mutex.o: In function `proc_mutex_pthread_acquire_ex':
/apache/httpd-2.4.46/srclib/apr/locks/unix/proc_mutex.c:807: undefined reference to `pthread_mutex_timedlock'
/apache/httpd-2.4.46/srclib/apr/locks/unix/proc_mutex.c:788: undefined reference to `pthread_mutex_trylock'

....

我猜我错过了链接阶段所需的许多目标文件或库,以便生成最终的可执行文件。

我的问题是如何以及在哪里可以找到重新生成 apache 可执行文件所需的所有目标文件?

标签: apachellvmllvm-ir

解决方案


看来您需要链接 pthreads 和 libdl 等库。显然,您可以从普通的链接器 cmdline 中查看需要什么。


推荐阅读