2.6.8: test suite build fails on linking with missing symbol
Looks like it is something wrong with test suite
[tkloczko@pers-jacek openvpn-2.6.8]$ make check
make check-recursive
make[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8'
Making check in build
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/build'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/build'
Making check in distro
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro'
Making check in systemd
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro/systemd'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro/systemd'
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro'
make[3]: Nothing to be done for 'check-am'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro'
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/distro'
Making check in include
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/include'
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/include'
Making check in src
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src'
Making check in compat
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/compat'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/compat'
Making check in openvpn
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpn'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpn'
Making check in openvpnmsica
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpnmsica'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpnmsica'
Making check in openvpnserv
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpnserv'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/openvpnserv'
Making check in plugins
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins'
Making check in auth-pam
make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins/auth-pam'
make[4]: Nothing to be done for 'check'.
make[4]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins/auth-pam'
Making check in down-root
make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins/down-root'
make[4]: Nothing to be done for 'check'.
make[4]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins/down-root'
make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins'
make[4]: Nothing to be done for 'check-am'.
make[4]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins'
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/plugins'
Making check in tapctl
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/tapctl'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src/tapctl'
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src'
make[3]: Nothing to be done for 'check-am'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src'
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/src'
Making check in sample
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/sample'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/sample'
Making check in doc
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc'
Making check in doxygen
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc/doxygen'
make[3]: Nothing to be done for 'check'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc/doxygen'
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc'
make[3]: Nothing to be done for 'check-am'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc'
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/doc'
Making check in tests
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests'
Making check in unit_tests
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests'
Making check in example_test
make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
make example_testdriver example2_testdriver
make[5]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
make[5]: 'example_testdriver' is up to date.
make[5]: 'example2_testdriver' is up to date.
make[5]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
make check-TESTS
make[5]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
[==========] success_test: Running 2 test(s).
[ RUN ] null_test_success
[ OK ] null_test_success
[ RUN ] int_test_success
[ OK ] int_test_success
[==========] success_test: 2 test(s) run.
[ PASSED ] 2 test(s).
PASS: example_testdriver
[==========] success_test2: Running 1 test(s).
[ RUN ] test_true
[ OK ] test_true
[==========] success_test2: 1 test(s) run.
[ PASSED ] 1 test(s).
PASS: example2_testdriver
==================
All 2 tests passed
==================
make[5]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
make[4]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/example_test'
Making check in openvpn
make[4]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/openvpn'
make argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver ncp_testdriver misc_testdriver pkt_testdriver tls_crypt_testdriver provider_testdriver
make[5]: Entering directory '/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/openvpn'
/bin/sh ../../../libtool --tag=CC --mode=link /usr/bin/gcc -I../../../include -I../../../src/openvpn -I../../../src/compat -Wall -Wno-stringop-truncation -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -std=c99 -lssl -lcrypto -lpkcs11-helper -lssl -lcrypto -llzo2 -lcmocka -L../../../src/openvpn -Wl,--wrap=parse_line -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--gc-sections -Wl,--as-needed -Wl,--build-id=sha1 -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,pack-relative-relocs -flto=auto -fuse-linker-plugin -o argv_testdriver argv_testdriver-test_argv.o argv_testdriver-mock_msg.o argv_testdriver-mock_get_random.o ../../../src/openvpn/argv_testdriver-platform.o ../../../src/openvpn/argv_testdriver-buffer.o ../../../src/openvpn/argv_testdriver-win32-util.o ../../../src/openvpn/argv_testdriver-argv.o -lcap-ng
libtool: link: /usr/bin/gcc -I../../../include -I../../../src/openvpn -I../../../src/compat -Wall -Wno-stringop-truncation -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -std=c99 -Wl,--wrap=parse_line -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--gc-sections -Wl,--as-needed -Wl,--build-id=sha1 -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z -Wl,pack-relative-relocs -flto=auto -fuse-linker-plugin -o argv_testdriver argv_testdriver-test_argv.o argv_testdriver-mock_msg.o argv_testdriver-mock_get_random.o ../../../src/openvpn/argv_testdriver-platform.o ../../../src/openvpn/argv_testdriver-buffer.o ../../../src/openvpn/argv_testdriver-win32-util.o ../../../src/openvpn/argv_testdriver-argv.o -lpkcs11-helper -lssl -lcrypto -llzo2 -lcmocka -L../../../src/openvpn -lcap-ng
/usr/bin/ld: /tmp/ccxC7zSQ.ltrans0.ltrans.o: in function `argv_parse_cmd.constprop.0':
/home/tkloczko/rpmbuild/BUILD/openvpn-2.6.8/tests/unit_tests/openvpn/../../../src/openvpn/argv.c:488:(.text.argv_parse_cmd.constprop.0+0x83): undefined reference to `__wrap_parse_line'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:1046: argv_testdriver] Error 1
It works fine on Gentoo here (git checkout of tag v2.6.8, cmocka 1.1.5, gcc 13.2.1):
[ OK ] argv_str__multiple_argv__correct_output
[ RUN ] argv_insert_head__non_empty_argv__head_added
[ OK ] argv_insert_head__non_empty_argv__head_added
[ RUN ] argv_insert_head__empty_argv__head_only
[ OK ] argv_insert_head__empty_argv__head_only
[==========] 14 test(s) run.
[ PASSED ] 14 test(s).
PASS: argv_testdriver
so I'm afraid it's something with your RPM build environment. What Linux version is this exactly? Does it work if you build & test outside of rpmbuild? The RPM gcc command line adds quite a number of switches that might cause the link fail.
Interesting enough we did have a report about the same issue in 2.5.0, also with rpmbuild, in our old ticket system - https://community.openvpn.net/openvpn/ticket/1346 - and the original poster never provided any information, so it was closed without resolution.
Would need at least the version of your distro and of gcc to be able to try to reproduce. But as @cron2 said, it is likely that one of the various compiler/linker flags is the problem here.
I suspect you need LTO (-flto) to trigger it. Our automated tinderboxing effort with LTO hit this at https://bugs.gentoo.org/877741.
I've seen quirks with -Wl,--wrap and LTO in other places but not yet tried to understand the problem.
I suspect you need LTO (
-flto) to trigger it. Our automated tinderboxing effort with LTO hit this at https://bugs.gentoo.org/877741.I've seen quirks with
-Wl,--wrapand LTO in other places but not yet tried to understand the problem.
I can only confirm that I'm using LTO as well 😋
I've spent a bit of time staring at the gentoo bug, the gentoo build log (which is -j16, so hard to follow) and reproducing this on one of my gentoo test systems.
So, indeed, if built with
$ ./configure 'CFLAGS=-O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0'
I get the same error out of make check V=1
gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../include -I../../../src/openvpn -I../../../src/compat -I../../../include -Wall -Wno-stringop-truncation -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -std=c99 -I/usr/include/libnl3 -MT ../../../src/openvpn/argv_testdriver-argv.o -MD -MP -MF ../../../src/openvpn/.deps/argv_testdriver-argv.Tpo -c -o ../../../src/openvpn/argv_testdriver-argv.o `test -f '../../../src/openvpn/argv.c' || echo './'`../../../src/openvpn/argv.c
mv -f ../../../src/openvpn/.deps/argv_testdriver-argv.Tpo ../../../src/openvpn/.deps/argv_testdriver-argv.Po
/bin/sh ../../../libtool --tag=CC --mode=link gcc -I../../../src/openvpn -I../../../src/compat -I../../../include -Wall -Wno-stringop-truncation -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -std=c99 -I/usr/include/libnl3 -lssl -lcrypto -llzo2 -lcmocka -L../../../src/openvpn -Wl,--wrap=parse_line -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -o argv_testdriver argv_testdriver-test_argv.o argv_testdriver-mock_msg.o argv_testdriver-mock_get_random.o ../../../src/openvpn/argv_testdriver-platform.o ../../../src/openvpn/argv_testdriver-buffer.o ../../../src/openvpn/argv_testdriver-win32-util.o ../../../src/openvpn/argv_testdriver-argv.o -lnl-genl-3 -lnl-3 -lcap-ng
libtool: link: gcc -I../../../src/openvpn -I../../../src/compat -I../../../include -Wall -Wno-stringop-truncation -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -std=c99 -I/usr/include/libnl3 -Wl,--wrap=parse_line -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -o argv_testdriver argv_testdriver-test_argv.o argv_testdriver-mock_msg.o argv_testdriver-mock_get_random.o ../../../src/openvpn/argv_testdriver-platform.o ../../../src/openvpn/argv_testdriver-buffer.o ../../../src/openvpn/argv_testdriver-win32-util.o ../../../src/openvpn/argv_testdriver-argv.o -lssl -lcrypto -llzo2 -lcmocka -L../../../src/openvpn -lnl-genl-3 -lnl-3 -lcap-ng
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/cct2glrE.ltrans0.ltrans.o: in function `argv_parse_cmd.constprop.0':
<artificial>:(.text+0x1326): undefined reference to `__wrap_parse_line'
collect2: error: ld returned 1 exit status
I'm not sure if we can fix this, except by "not using -Wl,-wrap=... - which would work for this particular test case, but for other cases it's not so straightforward to build a meaningful unit test with wrapper functions to provide test data when compiling unmodified source files (which is the point of the unit tests).
I'm not sure I understand what is happening here, but it seems -flto and -Wl,-wrap= upset each other. So, please do not build the unit tests with -flto.
OK, a few things going on here -- thanks to Gert for giving a nudge on the Gentoo bug.
I summarise it at https://bugs.gentoo.org/877741#c9, but repeating it here:
Good news: there was a bfd bug here which H.J. Lu has posted a patch for! (https://sourceware.org/bugzilla/show_bug.cgi?id=31956)
Bad news: the tests fail execution (runtime) because the real definition of e.g. buffer_write_file is visible and could be inlined. It needs to be firewalled via e.g. an internal shared library.