reswitched/libtransistor

Check for working C compiler: /usr/bin/clang -- broken

ConnorRigby opened this issue · 8 comments

    "/usr/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_1967b/fast"
    make[1]: Entering directory '/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp'
    /usr/bin/make -f CMakeFiles/cmTC_1967b.dir/build.make CMakeFiles/cmTC_1967b.dir/build
    make[2]: Entering directory '/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_1967b.dir/testCCompiler.c.o
    /usr/bin/clang --target=aarch64-none-linux-gnu   -g -fPIC -ffreestanding -fexceptions -fuse-ld=lld -fstack-protector-strong -O0 -mtune=cortex-a53 -target aarch64-none-linux-gnu -nostdlib -nostdlibinc -isystem /home/connor/oss/libtransistor/newlib/newlib/libc/sys/switch/include/ -isystem /home/connor/oss/libtransistor/newlib/newlib/libc/include/ -I/home/connor/oss/libtransistor/include/ -I /home/connor/oss/libtransistor/build/sdl2_install/include/ -D__SWITCH__=1    -o CMakeFiles/cmTC_1967b.dir/testCCompiler.c.o   -c /home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-5.0: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
    Linking C executable cmTC_1967b
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1967b.dir/link.txt --verbose=1
    /usr/bin/clang --target=aarch64-none-linux-gnu -g -fPIC -ffreestanding -fexceptions -fuse-ld=lld -fstack-protector-strong -O0 -mtune=cortex-a53 -target aarch64-none-linux-gnu -nostdlib -nostdlibinc -isystem /home/connor/oss/libtransistor/newlib/newlib/libc/sys/switch/include/ -isystem /home/connor/oss/libtransistor/newlib/newlib/libc/include/ -I/home/connor/oss/libtransistor/include/ -I /home/connor/oss/libtransistor/build/sdl2_install/include/ -D__SWITCH__=1   -fuse-ld=lld  CMakeFiles/cmTC_1967b.dir/testCCompiler.c.o  -o cmTC_1967b
    clang-5.0: error: invalid linker name in argument '-fuse-ld=lld'
    make[2]: *** [CMakeFiles/cmTC_1967b.dir/build.make:98: cmTC_1967b] Error 1
    make[2]: Leaving directory '/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp'
    make[1]: *** [Makefile:126: cmTC_1967b/fast] Error 2
    make[1]: Leaving directory '/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeTmp'




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:14 (project)


-- Configuring incomplete, errors occurred!
See also "/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeOutput.log".
See also "/home/connor/oss/libtransistor/build/compiler-rt/CMakeFiles/CMakeError.log".
make: *** [Makefile:92: /home/connor/oss/libtransistor/build/compiler-rt/Makefile] Error 1

build is on arch linux with latest llvm and clang installed.

error: invalid linker name in argument '-fuse-ld=lld'
For those who don't want to read the entire trace.

on ubuntu I get about a million warnings about -fuse-ld=lld being an unused (option... flag... something...), but it happily completes the build.

Interesting. I get a lot of warnings but it is treating them as errors

Do you have lld installed?

We pass that command line flag in order to satisfy CMake's compiler test, since it tries to compile and link a whole binary. When we're compiling libtransistor projects, we're compiling everything as binaries and calling the linker explicitly, thus the option is never used. We may want to disable that warning.

Ok. I was able to do

grep -lr fuse-ld=lld >> fuse-ld.txt
while read i ; do sed -i 's@-fuse-ld=lld@@g' $i ; done < ./fuse-ld.txt

Feel free to reopen if you feel so inclined.

Did that actually work and build the whole thing? I would think that you would only get such an error if you didn't have lld installed, and lld is necessary for linking libtransistor binaries.

I had lld installed. (it was installed as a dependency of llvm if i remember correctly). The fuse-ld warning was treated as an error. This has happened before on arch linux