[cfe-dev] Clang function-sections flag

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 20 07:07:05 PST 2021


Looks like CloudABI is the only triple that uses it by default. Presumably you aren't on that, but I could also be missing something.

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

/clang:-fno-function-sections

From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: paul.robinson at sony.com; cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] Clang function-sections flag

Hey Paul,

I tried that already and got:
"error: unknown argument: '-fno-function-sections'"

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf - however the flag is not supported (not with -Xclang but also not without)
However "-ffunction-sections" is accepted (with -Xclang)

Kind greetings
Björn

From: paul.robinson at sony.com<mailto:paul.robinson at sony.com> <paul.robinson at sony.com<mailto:paul.robinson at sony.com>>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <Bjoern.Gaier at horiba.com<mailto:Bjoern.Gaier at horiba.com>>; cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
Subject: RE: Clang function-sections flag

Try adding -fno-function-sections to make sure it's turned off (sounds like it is on by default for your target).
--paulr

From: cfe-dev <cfe-dev-bounces at lists.llvm.org<mailto:cfe-dev-bounces at lists.llvm.org>> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
Subject: [cfe-dev] Clang function-sections flag

Hey Clang-people,

I have a nooby question about the -ffunction-sections flag of Clang.
As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:
#define wuff(a, b) \
a##b

#define crap(num) \
int wuff(schwimmflugel, num) () \
{ \
    return num; \
}

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.
Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

So... what does that flag effect?

Kind greetings
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210120/381a0970/attachment.html>


More information about the cfe-dev mailing list