question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_find_linker_path returns wrong path

See original GitHub issue

Description 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fmeumcommented, Oct 7, 2022

@sgowroji This has been resolved by #15006.

1reaction
zakcutnercommented, Aug 5, 2022

Thanks @keith! I just tested your branch and it works great 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake FIND_LIBRARY returns wrong path - Stack Overflow
It looks like CMake has found another installation of the library in your MinGW environment. This might be a false positive.
Read more >
Bash remembers wrong path to an executable that was moved ...
When you run a command in bash it will remember the location of that executable so it doesn't have to search the PATH...
Read more >
currentStyle.getPath() returning wrong path in publish mode
Solved: I am working with a project of aem6.5. I want to read .css and .js from page template policy and use code...
Read more >
Added wrong path to $PATH variable but can't find old ...
PATH is usually set up in ${HOME}/.bashrc, the file you source`d. To see which line, you could type: grep -n virtualenvwrapper ${HOME}/.
Read more >
Why does locate give an incorrect path? - linux - Server Fault
locate uses a database generated and updated by the updatedb command that is run by cron ( usually every night).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found