[cfe-dev] What else is Clang hiding from me? (Aka how to find ALL supported flags)

Gaier, Bjoern via cfe-dev cfe-dev at lists.llvm.org
Tue Mar 10 00:40:34 PDT 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200310/d5495917/attachment.html>


More information about the cfe-dev mailing list