_find_linker_path returns wrong path
See original GitHub issueDescription of the bug:
The _find_linker_path
function determines the linker path by using the output of the following command (e.g. for the lld
linker):
$ cc empty.cc -o /dev/null -Wl,--start-lib -Wl,--end-lib -fuse-ld=lld -v
It then looks for a line with lld
in (since this is the linker we are looking for). The problem is that on my system, this also matches -debugger-tuning=lldb
:
$ cc empty.cc -o /dev/null -Wl,--start-lib -Wl,--end-lib -fuse-ld=lld -v 2>&1 | rg lld
"/usr/local/Cellar/llvm/14.0.6_1/bin/clang-14" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name empty.cc -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 764 -v -fcoverage-compilation-dir= -resource-dir /usr/local/Cellar/llvm/14.0.6_1/lib/clang/14.0.6 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/local/include -internal-isystem /usr/local/Cellar/llvm/14.0.6_1/lib/clang/14.0.6/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir= -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/bs/zp6qt5sd2_z9yh6cy2kktbp80000gp/T/foo-9bee4e.o -x c++ empty.cc
"/usr/local/Cellar/llvm/14.0.6_1/bin/ld64.lld" -demangle -no_deduplicate -dynamic -arch x86_64 -platform_version macos 12.0.0 12.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o /dev/null /var/folders/bs/zp6qt5sd2_z9yh6cy2kktbp80000gp/T/foo-9bee4e.o --start-lib --end-lib -lSystem /usr/local/Cellar/llvm/14.0.6_1/lib/clang/14.0.6/lib/darwin/libclang_rt.osx.a
This in turn causes a -fuse-ld=-debugger-tuning=lldb
flag to be set, which results in the following error (since of course -debugger-tuning=lldb
is not a valid linker path):
clang-14: error: invalid linker name in argument '-fuse-ld=-debugger-tuning=lldb'
I think the simplest way to fix this would be to check the flag ends with .lld
, rather than check if the flag contains lld
.
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
No response
Which operating system are you running Bazel on?
Mac
What is the output of bazel info release
?
Starting local Bazel server and connecting to it… (15:41:06) WARNING: info command does not support starlark options. Ignoring options: [–@io_bazel_rules_go//go/config:linkmode=pie] release 5.2.0
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top GitHub Comments
@sgowroji This has been resolved by #15006.
Thanks @keith! I just tested your branch and it works great 😄