Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: pabristow on July 14, 2020, 05:00:01 pm

Title: -s option generated for Clang compiler in debug, but -s is only a GCC option?
Post by: pabristow on July 14, 2020, 05:00:01 pm
I get warnings when using any Clang compiler (version 7 to 10) that the option -s is not understood and ignored.
This is annoying.

-s option generated for Clang compilers in debug, but -s is only a GCC option (where is works as expected).

https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
-s    Remove all symbol table and relocation information from the executable.

so this is valid option for GCC - but not Clang etc.

.cbp files contain

       <Linker>
         <Add option="-s" />
       </Linker>

and if i delete the add option line, the warning is absent.

(I use the lld linker, in case that is relevant).

I don't see any options listed in the global compiler setting, and I dare not edit the compiler option .xml without guidance.

Suggestions welcome.

Title: Re: -s option generated for Clang compiler in debug, but -s is only a GCC option?
Post by: stahta01 on July 14, 2020, 05:07:08 pm
And, how did you add the option to the project?

1. Wizard
  If yes, which wizard
2. Manually, if yes do not do that anymore
3. Some other way, describe that way

To remove the linker option from an project using the GUI look under
Project -> Build Options
Select project or target in left hand column
Tab: Linker
Box: Other linker options

Tim S.
Title: Re: -s option generated for Clang compiler in debug, but -s is only a GCC option?
Post by: oBFusCATed on July 14, 2020, 08:05:18 pm
(I use the lld linker, in case that is relevant).
What do you mean by this? -s is a linker option, not compiler option.
Title: Re: -s option generated for Clang compiler in debug, but -s is only a GCC option?
Post by: pabristow on July 15, 2020, 03:37:41 pm
I have used the New Project wizard to create a console project, and choosing Clang 10.0.0 as the compiler.

(@oBFusCATed Clang++ is used as a linker as well as a compiler, though I am using the LLVM/Clang LLD.exe linker ).

I get this warning:

  clang++: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
 
I don't choose -s as a build option, and it doesn't appear in the linker options (or other linker options).

In trying to trace another annoyance the -Weverything option (that is strongly unrecommended), I have found where looks like where this linker option is added.

C:\Program Files\CodeBlocks\share\CodeBlocks\templates\wizard\common_functions.script  line 183

            base.AddLinkerOption(_T("-s"));

This isn't a valid option for the LLD linker (or I believe the Clang++.exe linker) so it would be tidier to make this conditional on being GCC or not-Clang?

Should I try patching this line out on my copy of common_functions.script ?

Or can you suggest a better way for this?

(I at least can add the -s option by ticking the Compiler settings box "Strip all symbols from binary" if I am using GCC and care about .exe size - since I am just running tests, I usually care little).

Corrections.

1  I am using clang++.exe to get this message - because my compiler executables have clang++.exe for dynamic linking (and lld for static linking.  (I might change this).

2  -s IS a  clang++.exe linkage command, but for reasons unclear to me the Clang warning system is triggered by -s even when it is in linking mode.  So I conclude that this might be a Clang mis-feature?

I can disable the warning -Wno-unused-command-line-argument I suppose to suppress my 'no warnings' urges ;-)

So I think that I am wrong to suggest any CodeBlocks changes.  Sorry for the noise.  :-[
Title: Re: -s option generated for Clang compiler in debug, but -s is only a GCC option?
Post by: oBFusCATed on July 15, 2020, 08:34:44 pm
You can just remove the '-s' from your projects. It is not something hidden, there is a checkbox for it.