Eda*_*aro 3 c linux gcc glibc musl
我正在尝试使用musl-gcc构建FIO(由于 glibc 的许可问题,我们需要使用 musl)。我尝试使用 musl 提供的头文件而不是 glibc,但到目前为止编译 FIO 并不成功。我首先使用以下选项运行配置:
\n\nmy@desktop % ./configure --cc="/usr/local/musl/bin/musl-gcc -I/usr/local/musl/include" --cpu="x86_64" --prefix="/usr/bin"\nOperating system Linux\nCPU x86_64\nBig endian no\nCompiler /usr/local/musl/bin/musl-gcc -I/usr/local/musl/include\nCross compile no\n\nStatic build no\nWordsize 64\nzlib no\nLinux AIO support no\nPOSIX AIO support yes\nPOSIX AIO support needs -lrt no\nPOSIX AIO fsync yes\nPOSIX pshared support yes\nSolaris AIO support no\n__sync_fetch_and_add yes\n__sync_synchronize yes\n__sync_val_compare_and_swap yes\nlibverbs no\nrdmacm no\nasprintf() yes\nvasprintf() yes\nLinux fallocate no\nPOSIX fadvise yes\nPOSIX fallocate yes\nsched_setaffinity(3 arg) yes\nsched_setaffinity(2 arg) no\nclock_gettime yes\nCLOCK_MONOTONIC yes\nCLOCK_MONOTONIC_RAW yes\nCLOCK_MONOTONIC_PRECISE no\nclockid_t yes\ngettimeofday yes\nfdatasync yes\nsync_file_range no\nEXT4 move extent yes\nLinux splice(2) yes\nGUASI no\nlibnuma no\nstrsep yes\nstrcasestr yes\nstrlcat yes\ngetopt_long_only() yes\ninet_aton yes\nsocklen_t yes\n__thread yes\nRUSAGE_THREAD yes\nSCHED_IDLE yes\nTCP_NODELAY yes\nNet engine window_size yes\nTCP_MAXSEG yes\nRLIMIT_MEMLOCK yes\npwritev/preadv yes\npwritev2/preadv2 no\nIPv6 helpers yes\nhttp engine no\nRados engine no\nRados Block Device engine no\nsetvbuf yes\nGluster API engine no\ns390_z196_facilities no\nHDFS engine no\nMTD no\nlibpmem no\nlibpmemblk no\nPMDK pmemblk engine no\nPMDK dev-dax engine no\nPMDK libpmem engine no\nDDN\'s Infinite Memory Engine no\niscsi engine no\nlex/yacc for arithmetic no\ngetmntent yes\ngetmntinfo no\nStatic Assert no\nbool yes\nstrndup yes\nValgrind headers no\nZoned block device support no\nmarch_armv8_a_crc_crypto no\ncuda no\nmkdir(a, b) yes\nBuild march=native no\nCUnit no\n__kernel_rwf_t no\n-Wimplicit-fallthrough no\nMADV_HUGEPAGE yes\ngettid no\nConsider installing zlib-dev (zlib-devel, some fio features depend on it.\nTCMalloc support no\n\nRun Code Online (Sandbox Code Playgroud)\n\n然后运行 make:
\n\nmy@desktop % make\n CC crc/crc16.o\n CC crc/crc32.o\n CC crc/crc32c-arm64.o\nIn file included from crc/../os/os.h:38,\n from crc/crc32c-arm64.c:2:\ncrc/../os/os-linux.h:16:26: error: linux/unistd.h: No such file or directory\ncrc/../os/os-linux.h:17:23: error: linux/raw.h: No such file or directory\ncrc/../os/os-linux.h:18:25: error: linux/major.h: No such file or directory\ncrc/../os/os-linux.h:19:22: error: linux/fs.h: No such file or directory\nIn file included from crc/../os/os.h:38,\n from crc/crc32c-arm64.c:2:\ncrc/../os/os-linux.h: In function \xe2\x80\x98fio_lookup_raw\xe2\x80\x99:\ncrc/../os/os-linux.h:175: error: storage size of \xe2\x80\x98rq\xe2\x80\x99 isn\xe2\x80\x99t known\ncrc/../os/os-linux.h:178: error: \xe2\x80\x98RAW_MAJOR\xe2\x80\x99 undeclared (first use in this function)\ncrc/../os/os-linux.h:178: error: (Each undeclared identifier is reported only once\ncrc/../os/os-linux.h:178: error: for each function it appears in.)\ncrc/../os/os-linux.h:192: error: \xe2\x80\x98RAW_GETBIND\xe2\x80\x99 undeclared (first use in this function)\ncrc/../os/os-linux.h:175: warning: unused variable \xe2\x80\x98rq\xe2\x80\x99\nmake: *** [crc/crc32c-arm64.o] Error 1\nRun Code Online (Sandbox Code Playgroud)\n\n我不明白为什么我收到此文件的错误 - 当我尝试构建 x86_64 时(在配置选项中使用该文件),它看起来是 crc/crc32c-arm64.c。它查找 linux/*.h,但 /usr/local/musl/include 中没有 \'linux\' 文件夹。我通过包含 /usr/include 再次运行它(其中确实有 linux/*.h),如下所示:
\n\nmy@desktop % ./configure --cc="/usr/local/musl/bin/musl-gcc -I/usr/include" --cpu="x86_64" --prefix="/usr/bin"\nRun Code Online (Sandbox Code Playgroud)\n\n但现在当我运行 make 时出现不同的错误:
\n\nmy@desktop % make\n CC crc/crc16.o\n CC crc/crc32.o\n CC crc/crc32c-arm64.o\n CC crc/crc32c-intel.o\n CC crc/crc32c.o\n CC crc/crc64.o\n CC crc/crc7.o\n CC crc/fnv.o\n CC crc/md5.o\n CC crc/murmur3.o\n CC crc/sha1.o\n CC crc/sha256.o\n CC crc/sha3.o\n CC crc/sha512.o\n CC crc/test.o\nIn file included from /usr/include/stdio.h:75,\n from crc/test.c:2:\n/usr/include/libio.h:491: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/libio.h:493: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\nIn file included from crc/test.c:2:\n/usr/include/stdio.h:80: error: expected \xe2\x80\x98=\xe2\x80\x99, \xe2\x80\x98,\xe2\x80\x99, \xe2\x80\x98;\xe2\x80\x99, \xe2\x80\x98asm\xe2\x80\x99 or \xe2\x80\x98__attribute__\xe2\x80\x99 before \xe2\x80\x98va_list\xe2\x80\x99\nIn file included from crc/test.c:2:\n/usr/include/stdio.h:371: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:370: warning: conflicting types for built-in function \xe2\x80\x98vfprintf\xe2\x80\x99\n/usr/include/stdio.h:376: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:376: warning: conflicting types for built-in function \xe2\x80\x98vprintf\xe2\x80\x99\n/usr/include/stdio.h:379: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:378: warning: conflicting types for built-in function \xe2\x80\x98vsprintf\xe2\x80\x99\n/usr/include/stdio.h:390: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:389: warning: conflicting types for built-in function \xe2\x80\x98vsnprintf\xe2\x80\x99\n/usr/include/stdio.h:399: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:417: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:476: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:475: warning: conflicting types for built-in function \xe2\x80\x98vfscanf\xe2\x80\x99\n/usr/include/stdio.h:483: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:483: warning: conflicting types for built-in function \xe2\x80\x98vscanf\xe2\x80\x99\n/usr/include/stdio.h:488: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/stdio.h:487: warning: conflicting types for built-in function \xe2\x80\x98vsscanf\xe2\x80\x99\nIn file included from crc/test.c:2:\n/usr/include/stdio.h:899: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\nIn file included from /usr/include/stdio.h:932,\n from crc/test.c:2:\n/usr/include/bits/stdio2.h:28: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:26: warning: conflicting types for built-in function \xe2\x80\x98__vsprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h:44: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vsprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:48: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:48: error: (Each undeclared identifier is reported only once\n/usr/include/bits/stdio2.h:48: error: for each function it appears in.)\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:58: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:56: warning: conflicting types for built-in function \xe2\x80\x98__vsnprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h:75: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vsnprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:79: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:90: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:89: warning: conflicting types for built-in function \xe2\x80\x98__vfprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h:92: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:91: warning: conflicting types for built-in function \xe2\x80\x98__vprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h:115: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:118: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:118: error: too many arguments to function \xe2\x80\x98__vfprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:126: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vfprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:128: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:128: error: too many arguments to function \xe2\x80\x98__vfprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:137: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:142: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:151: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h:196: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vasprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:199: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:199: error: too many arguments to function \xe2\x80\x98__vasprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:203: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98vdprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:205: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:205: error: too many arguments to function \xe2\x80\x98__vdprintf_chk\xe2\x80\x99\n/usr/include/bits/stdio2.h: At top level:\n/usr/include/bits/stdio2.h:209: error: expected declaration specifiers or \xe2\x80\x98...\xe2\x80\x99 before \xe2\x80\x98__gnuc_va_list\xe2\x80\x99\n/usr/include/bits/stdio2.h: In function \xe2\x80\x98obstack_vprintf\xe2\x80\x99:\n/usr/include/bits/stdio2.h:213: error: \xe2\x80\x98__ap\xe2\x80\x99 undeclared (first use in this function)\n/usr/include/bits/stdio2.h:213: error: too many arguments to function \xe2\x80\x98__obstack_vprintf_chk\xe2\x80\x99\nmake: *** [crc/test.o] Error 1\nRun Code Online (Sandbox Code Playgroud)\n\n使用的版本:\nmusl-1.1.23、\nfio-3.15、\ngcc-4.4.6
\n\n如果我只使用 glibc,那么在不使用 musl 的情况下也可以正常构建。\n如何使用 musl 而不是 glibc 成功构建 FIO?这可能吗?
\n包装器脚本的全部要点musl-gcc是gcc通过调整包含和库路径来调用,以将其与主机包含和库生态系统(假设是基于 glibc 的)隔离。其中包括主机系统的内核头文件。如果您想使用任何库(包括“仅标头库”,如内核标头)musl-gcc,您需要针对 musl 而不是 glibc 构建一个版本,并将其安装在 musl include/library 路径中。
对于内核头文件来说,它们实际上并不依赖于 libc 或具有任何库文件;这只是标题。linux因此,您可能可以通过将、asm和asm-generic目录复制(或符号链接)/usr/include到 musl include 目录来完成。或者,您可以从内核源安装它们。
不过,如果您发现需要大量的第三方库内容,那么放弃musl-gcc并使用真正的交叉编译器更有意义。如果您愿意从musl.cc获得预构建的二进制文件,或者使用musl-cross-make构建您自己的二进制文件(如今在典型系统上大约需要 15 分钟)。这将自动为您提供内核头文件,以及一整套 GCC 目标库,可让您构建 C++ 软件、使用 OpenMP 的软件等。
| 归档时间: |
|
| 查看次数: |
2509 次 |
| 最近记录: |