Author Topic: -s option generated for Clang compiler in debug, but -s is only a GCC option?  (Read 4704 times)

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
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.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(I use the lld linker, in case that is relevant).
What do you mean by this? -s is a linker option, not compiler option.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
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.  :-[
« Last Edit: July 15, 2020, 06:06:22 pm by pabristow »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
You can just remove the '-s' from your projects. It is not something hidden, there is a checkbox for it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]