[BUG]: cannot use LLVM command-line arguments starting with "-l"
brunodf-snps opened this issue · comments
Describe the bug
When specifying a gcc/clang command-line argument starting with "-loop", it seems this command-line argument is silently dropped. The easiest is to try a non-existing command-line argument such as "-loop-some-invalid-option" and notice that you don't get an error, while you do get an error for "-foobar-some-invalid-option". But of course there are existing options which start with "-loop", and these cannot be used.
Steps to reproduce
- Visit godbolt.org
- Reset code UI and layout (or select "x86-64 gcc 13.2")
- Add command-line argument: -loop-some-invalid-option
Expected behavior
Gcc error saying that "-loop-some-invalid-option" does not exist.
Reproduction link
https://godbolt.org/z/Yc5E47qed
Screenshots
Not applicable
Operating System
No response
Browser version
No response
The issue seems a bit wider: any option starting with "-l".
Presumably this is to strip link options, but it prevents to use "-mllvm -loop-something" options such as these:
https://github.com/llvm/llvm-project/blob/f4c0c40f388fff0975ecada4997683cef3cb1fae/llvm/lib/Transforms/Scalar/LoopFlatten.cpp#L85-L103
Also when using LLVM tools inside Godbolt directly (for example, switch language to "LLVM IR" and select a version of the "opt" tool) any option starting with "-l" is removed. Here, you should be able to specify the LLVM options directly, without "-mllvm" prefix, so directly "-loop-something". This does not work.
At least for GCC and clang, -l
gets passed to the linker as a library to link against. I can run this on my local clang:
% clang -loop-some-invalid-option -c /tmp/moo.cc
clang: warning: -loop-some-invalid-option: 'linker' input unused [-Wunused-command-line-argument]
%
no error, that's just a warning. We don't strip anything but hand all the arguments (plus a few more) to the compiler itself. In the default mode we don't link so the -l
option is not processed by anything. If you enable the linker: https://godbolt.org/z/xjzETcr8G you get the error you'd expect.
I agree the -l
option does seem to somehow get droppedf by the opt
tool though,. so we still have something to investigate! :)
mayyybe we do filter -l
stuff? argh :) we will loko. thanks again for this
Thanks, Matt. I should have reported my problem more directly: I cannot use LLVM command-line arguments starting with -loop
, or even starting with -l
. They are either ignored, or they trigger an error.
This is with clang:
https://godbolt.org/z/r15bGsjnr
This is with opt:
https://godbolt.org/z/8YdWPP3e6
probable culprit: #6297