Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

compiler-rt fails to build when building 32-bit compat libraries on a 64-bit OS if -m64 is in the CFLAGS variable #41378

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR42409
Status NEW
Importance P enhancement
Reported by Bernhard Rosenkraenzer (bero@lindev.ch)
Reported on 2019-06-26 09:39:33 -0700
Last modified on 2019-06-27 11:36:55 -0700
Version trunk
Hardware PC Linux
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Building LLVM (with all subprojects enabled) from the current git tree results
in

[6/2906] Linking CXX static library
lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a
FAILED: lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a
: && /usr/bin/cmake -E remove lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-
i386.a && /usr/bin/ar qc lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerCrossOver.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerDataFlowTrace.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerDriver.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerExtFunctionsDlsym.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerExtFunctionsWeak.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerExtFunctionsWindows.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerExtraCounters.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerFork.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerIO.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerIOPosix.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerIOWindows.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerLoop.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerMerge.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerMutate.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerSHA1.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerTracePC.cpp.o
projects/compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtil.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtilDarwin.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtilFuchsia.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtilLinux.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtilPosix.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer.i386.dir/FuzzerUtilWindows.cpp.o
projects/compiler-
rt/lib/fuzzer/CMakeFiles/RTfuzzer_main.i386.dir/FuzzerMain.cpp.o &&
/usr/bin/ranlib lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a && cd
/home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-20190625/build/projects/compiler-
rt/lib/fuzzer/cxx_i386_merge.dir && /usr/bin/ld -m elf_i386 --whole-archive
/home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a --no-whole-
archive /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a -
r -o fuzzer.o && /usr/bin/objcopy --localize-hidden fuzzer.o && /usr/bin/cmake -
E remove /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a &&
/usr/bin/ar qcs /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/lib64/clang/9.0.0/lib/linux/libclang_rt.fuzzer-i386.a fuzzer.o
/usr/bin/ld: warning: Disabling --icf due to -r
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(algorithm.cpp.o): incompatible
target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(chrono.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(condition_variable.cpp.o):
incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(ios.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(locale.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(mutex.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(new.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(string.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(system_error.cpp.o): incompatible
target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(thread.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(vector.cpp.o): incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(cxa_guard.cpp.o): incompatible
target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(private_typeinfo.cpp.o):
incompatible target
/usr/bin/ld: error: /home/bero/temp/abf/llvm/BUILD/llvm-9.0.0-
20190625/build/projects/compiler-
rt/lib/fuzzer/libcxx_fuzzer_i386/lib/libc++.a(stdlib_new_delete.cpp.o):
incompatible target
ninja: build stopped: subcommand failed.

Looking into the listed object files shows that all the files in libc++.a in
libcxx_fuzzer_i386 are actually 64-bit files.
Looks like the CMake files for libcxx_fuzzer_i386 don't pass the correct -
target or -m32 flags.

This may be related to
https://bugs.llvm.org/show_bug.cgi?id=38025
Quuxplusone commented 5 years ago

Partial PEBKAC here. I had -m64 in my CFLAGS and CXXFLAGS settings. Removing that fixes the issue.

Of course ideally the cmake files would strip out flags that can't be used while crosscompiling.