3rd 方库在高山上构建时抱怨类型

3rd party library complains about types when building on alpine

我正在尝试在 alpine 构建容器上构建 libnfnetlink 的静态版本。它使用通常的 autogen->configure->make->make install 路线,但出于某种原因,它在 make 阶段抱怨未知类型(u_int8_t、u_int16_t 等)

每条命令的输出:

bash-5.1# ./autogen.sh 
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:14: installing 'build-aux/compile'
configure.ac:8: installing 'build-aux/missing'
/usr/share/automake-1.16/am/ltlibrary.am: warning: 'libnfnetlink.la': linking libtool libraries using a non-POSIX
/usr/share/automake-1.16/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'
src/Makefile.am:3:   while processing Libtool library 'libnfnetlink.la'
src/Makefile.am: installing 'build-aux/depcomp
bash-5.1# ./configure
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ./build-aux/install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/x86_64-alpine-linux-musl/bin/ld
checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 98304
checking how to convert x86_64-pc-linux-musl file names to x86_64-pc-linux-musl format... func_convert_file_noop
checking how to convert x86_64-pc-linux-musl file names to toolchain format... func_convert_file_noop
checking for /usr/x86_64-alpine-linux-musl/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating include/Makefile
config.status: creating include/libnfnetlink/Makefile
config.status: creating utils/Makefile
config.status: creating libnfnetlink.pc
config.status: executing depfiles commands
config.status: executing libtool commands
bash-5.1# make
Making all in src
make[1]: Entering directory '/opt/libnfnetlink/src'
  CC       libnfnetlink.lo
In file included from ../include/libnfnetlink/linux_nfnetlink.h:4,
                 from ../include/libnfnetlink/libnfnetlink.h:20,
                 from libnfnetlink.c:53:
../include/libnfnetlink/linux_nfnetlink_compat.h:23:2: error: unknown type name 'u_int16_t'
   23 |  u_int16_t nfa_len;
      |  ^~~~~~~~~
../include/libnfnetlink/linux_nfnetlink_compat.h:24:2: error: unknown type name 'u_int16_t'
   24 |  u_int16_t nfa_type; /* we use 15 bits for the type, and the highest
      |  ^~~~~~~~~
In file included from ../include/libnfnetlink/libnfnetlink.h:20,
                 from libnfnetlink.c:53:
../include/libnfnetlink/linux_nfnetlink.h:28:2: error: unknown type name 'u_int8_t'
   28 |  u_int8_t  nfgen_family;  /* AF_xxx */
      |  ^~~~~~~~
../include/libnfnetlink/linux_nfnetlink.h:29:2: error: unknown type name 'u_int8_t'
   29 |  u_int8_t  version;  /* nfnetlink version */
      |  ^~~~~~~~
../include/libnfnetlink/linux_nfnetlink.h:30:2: error: unknown type name 'u_int16_t'
   30 |  u_int16_t    res_id;  /* resource id */
      |  ^~~~~~~~~
In file included from libnfnetlink.c:53:
../include/libnfnetlink/libnfnetlink.h:58:2: error: unknown type name 'u_int16_t'
   58 |  u_int16_t attr_count;
      |  ^~~~~~~~~
../include/libnfnetlink/libnfnetlink.h:72:10: error: unknown type name 'u_int8_t'; did you mean 'uint8_t'?
   72 |          u_int8_t, u_int8_t,
      |          ^~~~~~~~
      |          uint8_t
../include/libnfnetlink/libnfnetlink.h:72:20: error: unknown type name 'u_int8_t'; did you mean 'uint8_t'?
   72 |          u_int8_t, u_int8_t,
      |                    ^~~~~~~~
......

我不知道问题出在哪里。配置部分正确地识别出我在 sys/types.h 中定义了未知类型,但是当我查看 src/.deps 文件夹时,我没有看到它列在 PLO 文件中。

如果我 运行 在 centos 7 或 8 容器中执行相同的步骤,它会按预期工作。我在 centos 和 alpine 之间的配置阶段看到的唯一区别是在 centos 上它有这些额外的行:

checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes

我对 autoconf/libtool 的了解还不够,无法对此进行调试,或者我应该查看的地方,或者这是否是问题所在。从所提供的信息来看,是否有任何明显错误或是否有其他我需要遵循的阶段(未记录)?

看来我可以回答我自己的问题了。上周我遇到问题时使用的是最新版本的 libnfnetlink (1.0.1)。今天发布了一个新版本 (1.0.2),其中发布了 9 年的修复,其中之一是不进行我遇到问题的转换,例如__16 -> u_int16_t.

现在所有构建都很好(并提醒自己,始终检查 master 分支的历史记录)