LibtraceTeam / libtrace

C Library for working with network packet traces
GNU Lesser General Public License v3.0
156 stars 51 forks source link

configure fails on Apple Silicon #205

Closed josephnoir closed 1 year ago

josephnoir commented 1 year ago

libtrace version: 4.0.20.

configure stops with this error:

./configure: line 21506: syntax error near unexpected token `DPDK,'
./configure: line 21506: `                        PKG_CHECK_MODULES(DPDK, libdpdk >= 18, pkgconf_dpdk_found="yes",'

I did not enable DPDK, the only argument to configure I'm using is --prefix=PATH. I'm inexperienced with automake and don't know where to start debugging this. Any help would be appreciated.

configure output so far ``` + aclocal-1.11 -I m4 ./bootstrap.sh: line 14: aclocal-1.11: command not found + aclocal-1.9 -I m4 ./bootstrap.sh: line 15: aclocal-1.9: command not found + aclocal -I m4 aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in' + libtoolize --force --copy ./bootstrap.sh: line 19: libtoolize: command not found + glibtoolize --force --copy glibtoolize: putting auxiliary files in '.'. glibtoolize: copying file './ltmain.sh' glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'. glibtoolize: copying file 'm4/libtool.m4' glibtoolize: copying file 'm4/ltoptions.m4' glibtoolize: copying file 'm4/ltsugar.m4' glibtoolize: copying file 'm4/ltversion.m4' glibtoolize: copying file 'm4/lt~obsolete.m4' + autoheader2.50 ./bootstrap.sh: line 22: autoheader2.50: command not found + autoheader autoheader: warning: autoconf input should be named 'configure.ac', not 'configure.in' + automake-1.11 --add-missing --copy --foreign ./bootstrap.sh: line 25: automake-1.11: command not found + automake-1.10 --add-missing --copy --foreign ./bootstrap.sh: line 26: automake-1.10: command not found + automake-1.9 --add-missing --copy --foreign ./bootstrap.sh: line 27: automake-1.9: command not found + automake --add-missing --copy --foreign automake: warning: autoconf input should be named 'configure.ac', not 'configure.in' configure.in:67: installing './compile' configure.in:76: installing './config.guess' configure.in:76: installing './config.sub' configure.in:21: installing './install-sh' configure.in:21: installing './missing' examples/parallel/Makefile.am: installing './depcomp' automake: warning: autoconf input should be named 'configure.ac', not 'configure.in' configure.in: installing './ylwrap' + autoconf2.50 ./bootstrap.sh: line 30: autoconf2.50: command not found + autoconf checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a race-free mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes 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 for g++... g++ checking whether the compiler supports GNU C++... yes checking whether g++ accepts -g... yes checking for g++ option to enable C++11 features... none needed checking dependency style of g++... gcc3 checking whether the C++ compiler works... yes checking build system type... aarch64-apple-darwin22.3.0 checking host system type... aarch64-apple-darwin22.3.0 checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no 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... 786432 checking how to convert aarch64-apple-darwin22.3.0 file names to aarch64-apple-darwin22.3.0 format... func_convert_file_noop checking how to convert aarch64-apple-darwin22.3.0 file names to toolchain format... func_convert_file_noop checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for file... file 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... no 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 dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes 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 sys/time.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.3.0 dyld 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... yes checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common -DPIC checking if g++ PIC flag -fno-common -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin22.3.0 dyld checking how to hardcode library paths into programs... immediate checking for bison... bison -y checking for flex... flex checking for lex output file root... lex.yy checking for lex library... none needed checking for library containing yywrap... -ll checking whether yytext is a pointer... yes ./configure: line 17794: PKG_PROG_PKG_CONFIG: command not found checking for GNU libc compatible malloc... yes checking for GNU libc compatible realloc... yes checking for an ANSI C-conforming const... yes checking for inline... inline checking whether byte ordering is bigendian... no checking for size_t... yes checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... no checking for simple visibility declarations... yes checking if -Werror flag is supported by compiler... yes checking if compiler supports __attribute__((packed))... yes checking if compiler supports __attribute__((aligned(1)))... yes checking if compiler supports __attribute__((deprecated))... yes checking if compiler supports __attribute__((unused))... yes checking if compiler supports __attribute__((pure))... yes checking if compiler supports __attribute__((format(printf)))... yes checking if compiler supports TLS __thread... yes checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking for gcc options needed to detect all undeclared functions... none needed checking whether strdup is declared... yes checking whether strlcpy is declared... yes checking whether strcasecmp is declared... yes checking whether strncasecmp is declared... yes checking whether snprintf is declared... yes checking whether vsnprintf is declared... yes checking whether strndup is declared... yes checking whether posix_memalign is declared... yes checking whether socket is declared... yes checking whether recvmmsg is declared... no checking size of long int... 8 checking for pcap.h... yes checking for pcap-bpf.h... yes checking for net/bpf.h... yes checking for sys/limits.h... no checking for stddef.h... yes checking for inttypes.h... (cached) yes checking for limits.h... yes checking for net/ethernet.h... yes checking for sys/prctl.h... no checking for ncurses.h... yes checking for netinet/in.h... yes checking for netpacket/packet.h... no checking for net/if.h... yes checking for linux/ethtool.h... no checking for netinet/ether.h... no checking for netinet/if_ether.h... yes checking for net/if_arp.h... yes checking for struct sockaddr_dl.sdl_len... yes checking for pcap-bpf.h... (cached) yes checking for net/bpf.h... (cached) yes checking for gdc.h... no checking for wandio_wflush in -lwandio... yes checking for EVP_EncryptInit_ex in -lcrypto... no checking for yaml_parser_initialize in -lyaml... no checking for asn1_array2tree in -ltasn1... no checking for elf_begin in -lelf... no checking for pcap_next_ex in -lpcap... yes checking for pcap_create in -lpcap... yes checking for pcap_set_immediate_mode in -lpcap... yes checking whether BIOCSETIF is declared... yes checking for pcap_inject... yes checking for pcap_sendpacket... yes checking for pcap_setnonblock... yes checking for dag_open in -ldag... no checking whether we have DAG 2.4 API instead... false checking whether PACKET_FANOUT is declared... no checking for numa_node_to_cpus in -lnuma... no checking for wandder_etsili_get_cc_format in -lwandder... no checking for pthread_create in -lpthread... yes checking for pthread_setname_np in -lpthread... yes checking for library containing pfring_recv... no checking for library containing getservent... none required checking for library containing inet_ntop... none required checking for library containing dlopen... none required checking for clock_gettime in -lrt... no ./configure: line 21506: syntax error near unexpected token `DPDK,' ./configure: line 21506: ` PKG_CHECK_MODULES(DPDK, libdpdk >= 18, pkgconf_dpdk_found="yes",' ```

Here is the configure script created by bootstrap (added txt because GH doesn't allow me to upload it otherwise): configure.txt

salcock commented 1 year ago

Hi,

Try installing pkg-config and then re-running the bootstrap script followed by ./configure.

If you use homebrew, brew install pkg-config should do the job for you.

josephnoir commented 1 year ago

That was it! Thank you :)

I'm running into a compiler error now:

trace.c:1943:15: error: implicit declaration of function 'bpf_filter' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = bpf_filter(filter->filter.bf_insns, (u_char *)linkptr,

My first suspicion was that libpcap is no longer in /usr/local/ because the Homebrew path was moved to /opt/homebrew. But adding the libpcap paths to the LDFLAGS and CPPFLAGS didn't make a difference. Neither did setting PKG_CONFIG_PATH as suggested by brew info libpcap. (I can see that those environment variables were read by libtrace in libtrace/config.log though.)

Edit: If it was a libpcap problem it would probably have shown when running configure.

josephnoir commented 1 year ago

I can get around this by adding a forward declaration of the function to trace.c:

u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int);

I'm not sure why it is missing though. In older xnu kernel versions, there is a net/bpf.h that has that same line. If I check the net/bpf.h that is included on my system (in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/net/bpf.h) the extern declaration of bpf_filter is not there. Since I don't know when it changed, I can't tell if this is the actual problem.

(I was pointed to the file in /Library/Developer/.... when I tried to simply add the pcap header to trace.c and I promptly got errors about redefined types pointing to that bpf header file.)

salcock commented 1 year ago

Thanks for looking into this -- I'll try to dig into this further at some point to get to the root cause.

I'm pleased you've managed to find a work around for now and I'll leave this issue up in the hope that this will help other people who run into the same problem.

salcock commented 1 year ago

Ok, I think I've finally got this fixed in our develop branch and will release a new version of libtrace that includes the fix in the next day or so.