What else is Clang hiding from me? (Aka how to find ALL supported flags)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

What else is Clang hiding from me? (Aka how to find ALL supported flags)

suyash singh via cfe-dev

Hello everyone,

 

(There is a TL;DR down there)

 

I started to look into the Spectre Mitigation features of the MSVC compiler - we are planning to apply those to our code base finally. I was able to find out, that the MSVC compiler supports 3 flags for this:

/Qspectre -> "Specifies compiler generation of instructions to mitigate certain Spectre variant 1 security vulnerabilities."

/Qspectre-load -> "Specifies compiler generation of serializing instructions for every load instruction."

/Qspectre-load-cf -> "Specifies compiler generation of serializing instructions for every control-flow instruction that contains a load."

 

That was surprisingly helpful! However, we are also using the Clang-Cl compiler, so I wanted to find out which features are supported in terms of the Spectre Mitigation. This was difficult! I found at least this website:

https://llvm.org/docs/SpeculativeLoadHardening.html - Which is really interesting but... too much for me >o<

Next hint I got was the attribute "speculative_load_hardening" but there the 'frustration' started. On the site, the compiler flag "-mno-speculative-load-hardening" was mentioned - I figured that the flag "-mspeculative-load-hardening" would be a thing. The link https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mspeculative-load-hardening was of no help however, because the flag isn't mentioned there as it seems. Sooo... Next thing I did was executing "clang -help" and "clang --help-hidden" to my surprise the flag wasn't mentioned there as well...

 

So I went to one of our projects and added it by hand, checking if it will throw an error or not - it did not.

 

TL;DR:

My problem as a user is... I'm really unsure how many undocumented flags are supported by Clang and which one might be of interested for me. For example, do I know all the flags now that are related to the spectre mitigation? I know that there is also -mreptoline (or something), but I can't know about the flags I don't know about - and when not even Clang itself dumps them, then I'm really screwed.

 

Also, how can I be sure, that the flag is also supported by Clang-Cl? Or by Clang-Cl -Xclang?

 

Also a kinda confusing thing... When I go to the LLVM/Clang online documentation, then it says Clang 11, when I ask my Clang about the version it replies with Clang 9 - also on the website I can only download LLVM 9 - That makes me feel like I missed 2 Versions already - even though I think to recall that LLVM 10 is next.

 

Yet it seems like I'm the only one with that issue .w.

 

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, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: What else is Clang hiding from me? (Aka how to find ALL supported flags)

suyash singh via cfe-dev
There's a manual step involved in updating our documentation for some reason. Looks like this manual step has been missed or only done piecemeal for specific options. I think this led to -mspeculative-load-hardening not being in the docs. I've resynced the documentation with the latest source so hopefully 
the webpage will be updated in the next day or so.

Not sure why clang doesn't print all the options. I normally work in the backend. Hopefully someone from the frontend can chime in here.

~Craig


On Tue, Mar 10, 2020 at 12:40 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello everyone,

 

(There is a TL;DR down there)

 

I started to look into the Spectre Mitigation features of the MSVC compiler - we are planning to apply those to our code base finally. I was able to find out, that the MSVC compiler supports 3 flags for this:

/Qspectre -> "Specifies compiler generation of instructions to mitigate certain Spectre variant 1 security vulnerabilities."

/Qspectre-load -> "Specifies compiler generation of serializing instructions for every load instruction."

/Qspectre-load-cf -> "Specifies compiler generation of serializing instructions for every control-flow instruction that contains a load."

 

That was surprisingly helpful! However, we are also using the Clang-Cl compiler, so I wanted to find out which features are supported in terms of the Spectre Mitigation. This was difficult! I found at least this website:

https://llvm.org/docs/SpeculativeLoadHardening.html - Which is really interesting but... too much for me >o<

Next hint I got was the attribute "speculative_load_hardening" but there the 'frustration' started. On the site, the compiler flag "-mno-speculative-load-hardening" was mentioned - I figured that the flag "-mspeculative-load-hardening" would be a thing. The link https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mspeculative-load-hardening was of no help however, because the flag isn't mentioned there as it seems. Sooo... Next thing I did was executing "clang -help" and "clang --help-hidden" to my surprise the flag wasn't mentioned there as well...

 

So I went to one of our projects and added it by hand, checking if it will throw an error or not - it did not.

 

TL;DR:

My problem as a user is... I'm really unsure how many undocumented flags are supported by Clang and which one might be of interested for me. For example, do I know all the flags now that are related to the spectre mitigation? I know that there is also -mreptoline (or something), but I can't know about the flags I don't know about - and when not even Clang itself dumps them, then I'm really screwed.

 

Also, how can I be sure, that the flag is also supported by Clang-Cl? Or by Clang-Cl -Xclang?

 

Also a kinda confusing thing... When I go to the LLVM/Clang online documentation, then it says Clang 11, when I ask my Clang about the version it replies with Clang 9 - also on the website I can only download LLVM 9 - That makes me feel like I missed 2 Versions already - even though I think to recall that LLVM 10 is next.

 

Yet it seems like I'm the only one with that issue .w.

 

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, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev