Can we disable the linker relaxation i.e -mno-relax for intel target in Clang,since we use partial linking like kernel module and “mno-relax” is not effective and clang warns like
./clang -mno-relax -S ~t.c
clang-16: warning: argument unused during compilation: ‘-mno-relax’ [-Wunused-command-line-argument]
Not familiar with the feature specifically but you could pass the equivalent linker flag using
-Wl,--no-relax (which is the
ld name for it).
Thank you @DavidSpickett for quick reply ,but was looking how we can disable relaxation assumption from compiler / clang and its good to have a such feature for the relocatable file that use the partial linking (-r).
Ok I figured it was just a convenience to have the compiler flag.
Looking at the clang sources, only RISCV seems to pay attention to
mno-relax. Confirmed by checking a few other targets in Godbolt: Compiler Explorer
Which is why you get “argument unused during compilation” instead of something like “argument not recognised”. It’s known but not checked by the Intel driver.
If you wanted to contribute such checking, a search for
mno_relax in the code is a good place to start.
No, we should not accept
-mno-relax for other targets. Rejecting
-mno-relax is the expected behavior. It’s currently RISC-V specific (LoongArch may want it in the future).
-mno-relax and many other target-specific options can be an error but currently we don’t have good mechanism to enforce this.
Thank you @MaskRay and @DavidSpickett ,we will fix our runtime here .