Bug 248230 - Compiled C++ program fails to run with the Undefined symbol error on Clang 10 / FreeBSD 12-STABLE (Clang 10 / 11.4 OK)
Summary: Compiled C++ program fails to run with the Undefined symbol error on Clang 10...
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords: needs-qa, regression
Depends on:
Blocks:
 
Reported: 2020-07-23 22:13 UTC by Vedran Miletic
Modified: 2020-07-28 21:28 UTC (History)
3 users (show)

See Also:
koobs: mfc-stable12?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vedran Miletic 2020-07-23 22:13:34 UTC
I'm running

% uname -a
FreeBSD bsd-testing 12.1-STABLE FreeBSD 12.1-STABLE r363428 GENERIC  amd64

and

% clang++ --version 
FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin

I'm developing RxDock [1] and FreeBSD is one of our two primary target platforms [2], other being Linux. I recently did some refactoring (commit 6d99131ef712a27d6637564de75b2b59bbc23619 in [3]) and tests now fail with:

The output from the failed tests:

1/5 rbcavity-1koc      FAIL           0.01s (exit status 1)

--- command ---
22:09:55 RBT_HOME='/usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME' RBT_ROOT='/usr/home/vedranm/workspace/rxdock' /usr/home/vedranm/workspace/rxdock/builddir/rbcavity -r /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1koc.prm -W
--- stderr ---
ld-elf.so.1: /usr/home/vedranm/workspace/rxdock/builddir/rbcavity: Undefined symbol "_ZN6rxdock14PrintStdHeaderERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS0_12basic_stringIcS3_NS0_9allocatorIcEEEE"
-------

2/5 rbcavity-1yet      FAIL           0.01s (exit status 1)

--- command ---
22:09:55 RBT_HOME='/usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME' RBT_ROOT='/usr/home/vedranm/workspace/rxdock' /usr/home/vedranm/workspace/rxdock/builddir/rbcavity -r /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1YET.prm -W
--- stderr ---
ld-elf.so.1: /usr/home/vedranm/workspace/rxdock/builddir/rbcavity: Undefined symbol "_ZN6rxdock14PrintStdHeaderERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS0_12basic_stringIcS3_NS0_9allocatorIcEEEE"
-------

3/5 rbcavity-1yet-test FAIL           0.01s (exit status 1)

--- command ---
22:09:55 RBT_HOME='/usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME' RBT_ROOT='/usr/home/vedranm/workspace/rxdock' /usr/home/vedranm/workspace/rxdock/builddir/rbcavity -r /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1YET_test.prm -W
--- stderr ---
ld-elf.so.1: /usr/home/vedranm/workspace/rxdock/builddir/rbcavity: Undefined symbol "_ZN6rxdock14PrintStdHeaderERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS0_12basic_stringIcS3_NS0_9allocatorIcEEEE"
-------

4/5 unit-test          FAIL           0.01s (exit status 1)

--- command ---
22:09:55 RBT_HOME='/usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME' RBT_ROOT='/usr/home/vedranm/workspace/rxdock' /usr/home/vedranm/workspace/rxdock/builddir/unit-test
--- stderr ---
ld-elf.so.1: Undefined symbol "_ZTVN6rxdock18RbtFlexAtomFactoryE" referenced from COPY relocation in /usr/home/vedranm/workspace/rxdock/builddir/unit-test
-------

5/5 rbdock-1yet-test   FAIL           0.01s (exit status 1)

--- command ---
22:09:55 RBT_HOME='/usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME' RBT_ROOT='/usr/home/vedranm/workspace/rxdock' /usr/home/vedranm/workspace/rxdock/builddir/rbdock -r /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1YET_test.prm -i /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1YET_c.sd -p dock.prm -n 1 -s 48151623 -o /usr/home/vedranm/workspace/rxdock/build/test/RBT_HOME/1YET_test_out
--- stderr ---
ld-elf.so.1: /usr/home/vedranm/workspace/rxdock/builddir/rbdock: Undefined symbol "_ZN6rxdock14PrintStdHeaderERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS0_12basic_stringIcS3_NS0_9allocatorIcEEEE"
-------

Full log written to /usr/home/vedranm/workspace/rxdock/builddir/meson-logs/testlog.txt
FAILED: meson-test 
/usr/local/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed.

However, tests works fine on FreeBSD 11.4 with Clang 10 and 12.1 with Clang 8 (and also on Linux).

If I revert that commit, the tests work fine on 12.1-STABLE as well. I tried to come up with a more minimal example, but I couldn't figure out what exactly makes it break.

[1] https://www.rxdock.org/
[2] https://www.rxdock.org/documentation/devel/html/developer-guide/target-platforms.html
[3] https://bitbucket.org/rxdock/rxdock
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2020-07-24 02:26:11 UTC
Thank you for the report Vedran. 6d99131ef712a27d6637564de75b2b59bbc23619 is a rather large changeset. If you're able to reduce that test case down that should prove handy.

A minimal test/reproduction case is going to be the best bet to isolation and resolution here.
Comment 2 Mark Millard 2020-07-24 08:13:59 UTC
> tests works fine on FreeBSD 11.4 with Clang 10 and 12.1 with Clang 8 (and also on Linux).

(I assume system-clang/llvm was in use instead of devel/llvm* 's. This wording
presumes that the 11.4 and 12.1-STABLE system clang 10 based rxdock builds were
separate. If not, do the contrasting case implicit below.)

If you copy the rxdock installed materials from 11.4 to 12.1-STABLE, do you see the
problem on 12.1-STABLE? This is different than building rxdock materials on
12.1-STABLE with the 12.1-STABLE's llvm10/clang10 toochain. This is sort of like
upgrading FreeBSD after the rxdock software was installed, without rebuilding the
rxdock software. (That is another way of doing the experiment.)

The alternatives would seem to be:

A) Still works on 12.1-STABLE, so that 12.1-STABLE's toolchain is involved for
   the behavioral change in the re-built rxdock.

vs.

B) Fails on 12.1-STABLE, so just other differences in the FreeBSD versions make
   the difference, not the toolchain used to do the build (rxdock held
   invariant).

So it is just a partial problem-isolation test but it might help limit what
else to explore.

Of course, the suggestion presumes that FreeBSD's backwards compatibility
support has been built and installed in the 12.1-STABLE system, so that
the 12.1-STABLE is supposed to execute 11.x material just fine.
Comment 3 Vedran Miletic 2020-07-28 21:28:37 UTC
False alarm, everything actually works as intended. I had a conflicting library in a directory in the LD_LIBRARY_PATH and only figured it out today when moving things around. Should have thought of LD_LIBRARY_PATH sooner and checked it, apologies for that.