Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-8: error: linker command failed with exit code 1 (use -v to see invocation) running FuzzerUnitTests #37867

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38894
Status CONFIRMED
Importance P normal
Reported by Mike Coyle (michael.coyle@newwavedv.com)
Reported on 2018-09-10 10:50:23 -0700
Last modified on 2018-10-24 22:25:07 -0700
Version unspecified
Hardware Other Linux
CC llvm-bugs@lists.llvm.org, phosek@chromium.org, tstellar@redhat.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
[mcoyle@dut build]$ ninja-build -v projects/compiler-
rt/lib/fuzzer/tests/FuzzerUnitTests
[0/2] cd /mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64-bins && /usr/bin/cmake3 --build .
ninja: no work to do.
[2/2] cd /mnt/raid5_a/llvm/build/projects/compiler-rt/lib/fuzzer/tests &&
/mnt/raid5_a/llvm/build/./bin/clang
FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o FuzzerTestObjects.gtest-
all.cc.x86_64.o /mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/tests/libRTFuzzerTest.x86_64.a -o
/mnt/raid5_a/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./Fuzzer-x86_64-
Test -Wl,-allow-shlib-undefined --driver-mode=g++ -lstdc++ -lpthread
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a -m64
FAILED: projects/compiler-rt/lib/fuzzer/tests/Fuzzer-x86_64-Test
cd /mnt/raid5_a/llvm/build/projects/compiler-rt/lib/fuzzer/tests &&
/mnt/raid5_a/llvm/build/./bin/clang
FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o FuzzerTestObjects.gtest-
all.cc.x86_64.o /mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/tests/libRTFuzzerTest.x86_64.a -o
/mnt/raid5_a/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./Fuzzer-x86_64-
Test -Wl,-allow-shlib-undefined --driver-mode=g++ -lstdc++ -lpthread
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a -m64
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(char const*)':
stdexcept.cpp:(.text+0x620): multiple definition of
`std::logic_error::logic_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(char const*)':
stdexcept.cpp:(.text+0x620): multiple definition of
`std::logic_error::logic_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(std::logic_error const&)':
stdexcept.cpp:(.text+0x680): multiple definition of
`std::logic_error::logic_error(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(std::logic_error const&)':
stdexcept.cpp:(.text+0x680): multiple definition of
`std::logic_error::logic_error(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::operator=(std::logic_error const&)':
stdexcept.cpp:(.text+0x6a0): multiple definition of
`std::logic_error::operator=(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_erroraSERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(char const*)':
stdexcept.cpp:(.text+0x750): multiple definition of
`std::runtime_error::runtime_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(char const*)':
stdexcept.cpp:(.text+0x750): multiple definition of
`std::runtime_error::runtime_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7b0): multiple definition of
`std::runtime_error::runtime_error(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7b0): multiple definition of
`std::runtime_error::runtime_error(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::operator=(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7d0): multiple definition of
`std::runtime_error::operator=(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_erroraSERKS_+0x0): first defined here
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.

running from a git clone of https://git.llvm.org/git/compiler-rt.git/ as of
commit-id e843a7f9826d6fc8aaa5934003298bf453a0373a

on RHEL 7

Linux 3.10.0-862.11.6.el7.x86_64 #1 SMP Fri Aug 10 16:55:11 UTC 2018 x86_64
x86_64 x86_64 GNU/Linux

using

[mcoyle@dut compiler-rt]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-
languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --
mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-
7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --
enable-shared --enable-threads=posix --enable-checking=release --enable-
multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-
exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-
version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-
array --with-default-libstdcxx-abi=gcc4-compatible --with-
isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-
install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --
with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)

to compile.
Quuxplusone commented 6 years ago
I used

cmake -G Ninja

to create this failure.

Am now rebuilding without Ninja, just to see if using *nix makefiles has the
same failure mode.
Quuxplusone commented 6 years ago
Same failure under make as under ninja:

[100%] Generating Fuzzer-x86_64-Test
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(char const*)':
stdexcept.cpp:(.text+0x620): multiple definition of
`std::logic_error::logic_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(char const*)':
stdexcept.cpp:(.text+0x620): multiple definition of
`std::logic_error::logic_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(std::logic_error const&)':
stdexcept.cpp:(.text+0x680): multiple definition of
`std::logic_error::logic_error(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::logic_error(std::logic_error const&)':
stdexcept.cpp:(.text+0x680): multiple definition of
`std::logic_error::logic_error(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::logic_error::operator=(std::logic_error const&)':
stdexcept.cpp:(.text+0x6a0): multiple definition of
`std::logic_error::operator=(std::logic_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt11logic_erroraSERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(char const*)':
stdexcept.cpp:(.text+0x750): multiple definition of
`std::runtime_error::runtime_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(char const*)':
stdexcept.cpp:(.text+0x750): multiple definition of
`std::runtime_error::runtime_error(char const*)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2EPKc+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7b0): multiple definition of
`std::runtime_error::runtime_error(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::runtime_error(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7b0): multiple definition of
`std::runtime_error::runtime_error(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_errorC2ERKS_+0x0): first defined here
/mnt/raid5_a/llvm/build-makefiles/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_x86_64/lib/libc++.a(stdexcept.cpp.o): In function
`std::runtime_error::operator=(std::runtime_error const&)':
stdexcept.cpp:(.text+0x7d0): multiple definition of
`std::runtime_error::operator=(std::runtime_error const&)'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-
linux/7/libstdc++_nonshared.a(cow-
stdexcept.o):(.text._ZNSt13runtime_erroraSERKS_+0x0): first defined here
clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)
make[3]: *** [projects/compiler-rt/lib/fuzzer/tests/CMakeFiles/TFuzzer-x86_64-
Test.dir/build.make:64: projects/compiler-rt/lib/fuzzer/tests/Fuzzer-x86_64-
Test] Error 1
make[2]: *** [CMakeFiles/Makefile2:31715: projects/compiler-
rt/lib/fuzzer/tests/CMakeFiles/TFuzzer-x86_64-Test.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
Quuxplusone commented 6 years ago

What arguments did you pass to cmake when configuring compiler-rt and also llvm if you built that yourself?

Quuxplusone commented 6 years ago

It looks like the problem is that it is linking against libstdc++ and libc++, but I'll still need the cmake arguments to try to reproduce.

Quuxplusone commented 6 years ago
All build from scratch following https://llvm.org/docs/GettingStarted.html#git-
mirror scripted as follows:

[mcoyle@dut llvm]$ more clone.sh
git clone https://git.llvm.org/git/llvm.git/
cd llvm/tools
git clone https://git.llvm.org/git/clang.git/
cd ../projects
git clone https://git.llvm.org/git/compiler-rt.git/
git clone https://git.llvm.org/git/libcxx.git/
git clone https://git.llvm.org/git/libcxxabi.git/
git clone https://git.llvm.org/git/test-suite.git/
[mcoyle@dut llvm]$ more build-ninja.sh
rm -rf build
mkdir build
cd build
cmake ../llvm -G Ninja
ninja-build
ninja-build check-all
Quuxplusone commented 6 years ago

Are you building on RHEL or CentOS?

Quuxplusone commented 6 years ago

On RHEL 7.5

Quuxplusone commented 6 years ago
(In reply to Mike Coyle from comment #7)
> On RHEL 7.5

Not sure if this helps you at all, but llvm and clang packages are available
for RHEL[1].  libfuzzer is shipped as part of the llvm-toolset-7-compiler-rt
package.

I will still look into your issues building with trunk.

[1] https://developers.redhat.com/blog/2018/07/07/yum-install-gcc7-clang/
Quuxplusone commented 6 years ago

Petr, It looks like you added libc++ support to the fuzzer in r322604. The problem here is that the unit tests are trying to link against both libstdc++ and libc++. Note that with the devtoolset toolchain on RHEL, libstdc++ is split into 2 libraries, a shared library that is ABI compatible with libstdc++ from gcc 4.8.5 and a static library which contains all the new features added to the library between 4.8.5 and gcc 7.3.1.

Do you have any suggestions for how to fix this?

Quuxplusone commented 6 years ago

Mike, is there any particular reason why you are trying to build libc++? Is there some reason why libstdc++ won't work for the codebase you are planning to build with clang?