appneta / tcpreplay

Pcap editing and replay tools for *NIX and Windows - Users please download source from
http://tcpreplay.appneta.com/wiki/installation.html#downloads
1.15k stars 268 forks source link

[Bug] 4.4.4 fails to build with clang: incomplete definition of the 'struct next' type #809

Open ehaupt opened 1 year ago

ehaupt commented 1 year ago

Describe the bug Version 4.4.4 fails to build with clang (previous version 4.4.3 builds fine):

Compiler version:

$ clang --version
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
Target: x86_64-unknown-freebsd13.2
Thread model: posix
InstalledDir: /usr/bin

In 'mod.c', a fatal error occurs due to an incomplete definition of the 'struct next' type, resulting in a build failure.

cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-fragroute.o -MD -MP -MF .deps/libfragroute_a-fragroute.Tpo -c -o libfragroute_a-fragroute.o `test -f 'fragroute.c' || echo './'`fragroute.c
mv -f .deps/libfragroute_a-fragroute.Tpo .deps/libfragroute_a-fragroute.Po
cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-bget.o -MD -MP -MF .deps/libfragroute_a-bget.Tpo -c -o libfragroute_a-bget.o `test -f 'bget.c' || echo './'`bget.c
mv -f .deps/libfragroute_a-bget.Tpo .deps/libfragroute_a-bget.Po
cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-mod.o -MD -MP -MF .deps/libfragroute_a-mod.Tpo -c -o libfragroute_a-mod.o `test -f 'mod.c' || echo './'`mod.c
mod.c:180:5: fatal error: incomplete definition of type 'struct next'
    TAILQ_FOREACH_REVERSE(rule, &rules, next, head)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/queue.h:750:15: note: expanded from macro 'TAILQ_FOREACH_REVERSE'
        for ((var) = TAILQ_LAST((head), headname);                      \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/queue.h:824:44: note: expanded from macro 'TAILQ_LAST'
        (*(((struct headname *)((head)->tqh_last))->tqh_last))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
mod.c:180:41: note: forward declaration of 'struct next'
    TAILQ_FOREACH_REVERSE(rule, &rules, next, head)
                                        ^

Full build log: tcpreplay-4.4.4.log

To Reproduce

  1. Download a FreeBSD vagrant image
  2. Try to compile 4.4.4

System (please complete the following information):

fklassen commented 1 year ago

I tried with clang-13 and clang-17 on Debian Linux. No failure. Do you see this fail on 4.4.3?

ehaupt commented 1 year ago

4.4.3 builds fine.

fklassen commented 1 year ago

OK, I'll build up a FreeBSD VM to test on.

ehaupt commented 1 year ago

OK, I'll build up a FreeBSD VM to test on.

Quick setup to have all deps:

Vagrant.configure("2") do |config|
  config.vm.box = "freebsd/FreeBSD-13.2-RELEASE"
  config.vm.box_version = "2023.04.07"

  config.vm.provision "shell", inline: <<-SHELL
    sed -i'' -e 's|quarterly|latest|' /etc/pkg/FreeBSD.conf
    pkg install -y bash git
    portsnap --interactive fetch extract
    sh -c '(cd /usr/ports/net-mgmt/tcpreplay; make missing | xargs pkg install -y)'
  SHELL
end
ehaupt commented 1 year ago

Just to verify, I attempted compiling with a different compiler (gcc 12.2.0), but it failed as well.

See tcpreplay-4.4.4_gcc_freebsd_13_1.log

The title of the issue should probably be changed to:

[Bug] 4.4.4 fails to build on FreeBSD: incomplete definition of the 'struct next' type
ehaupt commented 10 months ago

According to repology, no other *BSD has updated to 4.4.4 so this bug likely exists on those platforms as well.