summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-10-10 21:04:25 +0000
committerReid Kleckner <rnk@google.com>2019-10-10 21:04:25 +0000
commitc677d420e10769596cb21a859d7896139adc8be5 (patch)
treebd2fc50b3194f838a51656f8191b7ebd99fb401e /docs
parent3ee1fe728c53ee07305dcb33177f7de493d108c2 (diff)
downloadclang-c677d420e10769596cb21a859d7896139adc8be5.tar.gz
Add -fgnuc-version= to control __GNUC__ and other GCC macros
I noticed that compiling on Windows with -fno-ms-compatibility had the side effect of defining __GNUC__, along with __GNUG__, __GXX_RTTI__, and a number of other macros for GCC compatibility. This is undesirable and causes Chromium to do things like mix __attribute__ and __declspec, which doesn't work. We should have a positive language option to enable GCC compatibility features so that we can experiment with -fno-ms-compatibility on Windows. This change adds -fgnuc-version= to be that option. My issue aside, users have, for a long time, reported that __GNUC__ doesn't match their expectations in one way or another. We have encouraged users to migrate code away from this macro, but new code continues to be written assuming a GCC-only environment. There's really nothing we can do to stop that. By adding this flag, we can allow them to choose their own adventure with __GNUC__. This overlaps a bit with the "GNUMode" language option from -std=gnu*. The gnu language mode tends to enable non-conforming behaviors that we'd rather not enable by default, but the we want to set things like __GXX_RTTI__ by default, so I've kept these separate. Helps address PR42817 Reviewed By: hans, nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D68055 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/ReleaseNotes.rst5
-rw-r--r--docs/UsersManual.rst7
2 files changed, 11 insertions, 1 deletions
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 8e9d298c95..7f823e3826 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -80,7 +80,10 @@ Non-comprehensive list of changes in this release
New Compiler Flags
------------------
-- ...
+- The -fgnuc-version= flag now controls the value of ``__GNUC__`` and related
+ macros. This flag does not enable or disable any GCC extensions implemented in
+ Clang. Setting the version to zero causes Clang to leave ``__GNUC__`` and
+ other GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined.
Deprecated Compiler Flags
-------------------------
diff --git a/docs/UsersManual.rst b/docs/UsersManual.rst
index 419714d38c..de28d77671 100644
--- a/docs/UsersManual.rst
+++ b/docs/UsersManual.rst
@@ -701,6 +701,13 @@ Other Options
-------------
Clang options that don't fit neatly into other categories.
+.. option:: -fgnuc-version=
+
+ This flag controls the value of ``__GNUC__`` and related macros. This flag
+ does not enable or disable any GCC extensions implemented in Clang. Setting
+ the version to zero causes Clang to leave ``__GNUC__`` and other
+ GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined.
+
.. option:: -MV
When emitting a dependency file, use formatting conventions appropriate