Search code examples
linuxalpine-linuxautoconflibtoolmusl

3rd party library complains about types when building on alpine


I'm trying to build a static version of libnfnetlink on an alpine build container. It uses the usual autogen->configure->make->make install route but for some reason it complains at the make stage about unknown types (u_int8_t, u_int16_t etc)

The output of each command:

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,
      |                    ^~~~~~~~
......

I cannot figure out what the problem could be. The configure part correctly identifies that I have sys/types.h where the unknown types are defined but when I look in the src/.deps folder, I don't see it listed in the PLO file.

If i run the same steps in a centos 7 or 8 container, it works as expected. The only difference I can see in the configure stage between centos and alpine is that on centos it has these extra lines:

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

I don't really know enough about autoconf/libtool to debug this or where I should be looking or if that is even the issue. From the information provided, does anything stand out as wrong or is there some other stage (not documented) that I need to follow?


Solution

  • So it seems I can answer my own question. I was using the latest release of libnfnetlink last week when I had the issue (1.0.1). There was a new release today (1.0.2) that had 9 years worth of fixes released, one of which was to not do the conversions I was having issues with e.g. __16 -> u_int16_t.

    All builds fine now (and note to self, always check the history of the master branch)