JuliaPackaging/BinaryBuilderBase.jl

Clang on Armv6/7 on musl gives linker errors

gbaraldi opened this issue · 2 comments

As mose showed in #261
Clang doesn't find the libs when using arm + musl

% julia --compile=min -e 'using BinaryBuilderBase; BinaryBuilderBase.runshell(Platform("armv7l", "linux"; libc="musl"))'
sandbox:${WORKSPACE} # echo 'int test(){return 0;}' | clang -x c - -c -o test.o
clang-13: warning: argument unused during compilation: '-rtlib=libgcc' [-Wunused-command-line-argument]
clang-13: warning: argument unused during compilation: '-stdlib=libstdc++' [-Wunused-command-line-argument]
sandbox:${WORKSPACE} # echo 'int test(){return 0;}' | clang -x c - -shared -o test.so
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find crtbeginS.o: No such file or directory
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find -lgcc
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find -lgcc_s
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find -lgcc
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find -lgcc_s
/opt/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld: cannot find crtendS.o: No such file or directory
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
sandbox:${WORKSPACE} # qfind /opt/${target}/${target} -name 'libgcc_s.*'
/opt/arm-linux-musleabihf/arm-linux-musleabihf/lib/libgcc_s.so
/opt/arm-linux-musleabihf/arm-linux-musleabihf/lib/libgcc_s.so.1

That's a good guess:

sandbox:${WORKSPACE} # clang -print-search-dirs
programs: =/opt/x86_64-linux-musl/bin
libraries: =/opt/x86_64-linux-musl/lib/clang/13.0.1:/opt/arm-linux-musleabihf/arm-linux-musleabihf/sys-root/lib/../lib:/opt/arm-linux-musleabihf/arm-linux-musleabihf/sys-root/usr/lib/../lib:/opt/arm-linux-musleabihf/arm-linux-musleabihf/sys-root/lib:/opt/arm-linux-musleabihf/arm-linux-musleabihf/sys-root/usr/lib

the list of libdirs is missing /opt/arm-linux-musleabihf/arm-linux-musleabihf/lib, where the gcc toolchain libraries are.