-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AMDGPU][LLD][Clang] Passing arguments via -mllvm
to pass plugin causes unknown argument in lld
#63604
Comments
you can use -Xarch_host -mllvm=-wave-goodbye, then the -mllvm option will not be passed to lld |
Are we passing |
that's a good point. we should stop passing -mllvm options to device lld. Since we use -Xoffload-linker instead of -Wl to pass options to device lld, we should use -Xoffload-linker -mllvm= to pass -mllvm to device linker. |
@llvm/issue-subscribers-clang-driver |
Thanks for the tip. I can confirm that the code can compile when using LLVM: $ ml LLVM
$ clang --version
clang version 16.0.6 (git@github.com:llvm/llvm-project.git 7cbf1a2591520c2491aa35339f227775f4d3adf6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/software/software/LLVM/16.0.6/bin
$ clang -fPIC -shared bye.cpp -o bye.so -fno-rtti
$ clang -fplugin=./bye.so -fpass-plugin=./bye.so -O3 minimal.c -Xarch_host -mllvm=-wave-goodbye
clang-16: warning: argument unused during compilation: '-Xarch_host -mllvm=-wave-goodbye' [-Wunused-command-line-argument] aomp 17.0-0: $ ml ROCm
$ clang --version
AOMP_STANDALONE_17.0-0 clang version 17.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/software/software/ROCm/aomp_17.0/bin
$ clang -fPIC -shared bye.cpp -o bye.so -fno-rtti
$ clang -fplugin=./bye.so -fpass-plugin=./bye.so -O3 minimal.c -Xarch_host -mllvm=-wave-goodbye
Bye: main |
the older compiler does not support -mllvm=, which is added recently |
Description
I'm in the process of writing a pass plugin for instrumentation of applications compiled with LLVM. While checking for function names which need to be filtered, I tried to compile a bit of CUDA and HIP code. During this, I encountered an issue when trying to pass an argument to the pass plugin.
Right now, I'm passing arguments to the pass plugin via
-mllvm [arg]
. I found the suggestion here and it worked fine for basic code.As far as I've seen, this is the only way to process arguments outside of using
opt
, right? Usingopt
would be extremely inconvenient, especially for projects with a lot of source files and dependencies.Error output
For this example, I'm using the
Bye
example in the LLVM repository. I've removed all of the legacy registration, which should not affect the functionality.Looking at the output with
clang -v
, we can see that the argument is passed tolld
"/opt/software/software/LLVM/16.0.6/bin/lld" -flavor gnu -m elf64_amdgpu --no-undefined -shared -plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx906 -plugin-opt=-wave-goodbye -o /tmp/minimal-6ad3b7/minimal-gfx906.out /tmp/minimal-f23b1b/minimal-gfx906.o
Trying to compile the same tool with
-x cuda
works fine.The main question here is: Is there a way to avoid passing the parameter to
lld
when working withclang -x hip
(orhipcc
with ROCm)?The text was updated successfully, but these errors were encountered: