r270240 - Make __FreeBSD_cc_version predefined macro configurable at build time

Dimitry Andric via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 10:27:23 PDT 2016

Author: dim
Date: Fri May 20 12:27:22 2016
New Revision: 270240

URL: http://llvm.org/viewvc/llvm-project?rev=270240&view=rev
Make __FreeBSD_cc_version predefined macro configurable at build time

The `FreeBSDTargetInfo` class has always set the `__FreeBSD_cc_version`
predefined macro to a rather static value, calculated from the major OS

In the FreeBSD base system, we will start incrementing the value of this
macro whenever we make any signifant change to clang, so we need a way
to configure the macro's value at build time.

Use `FREEBSD_CC_VERSION` for this, which we can define in the FreeBSD
build system using either the `-D` command line option, or an include
file.  Stock builds will keep the earlier value.

Differential Revision: http://reviews.llvm.org/D20037


Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270240&r1=270239&r2=270240&view=diff
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 20 12:27:22 2016
@@ -308,6 +308,10 @@ public:
 // FreeBSD Target
 template<typename Target>
 class FreeBSDTargetInfo : public OSTargetInfo<Target> {
@@ -318,10 +322,13 @@ protected:
     unsigned Release = Triple.getOSMajorVersion();
     if (Release == 0U)
-      Release = 8;
+      Release = 8U;
+    unsigned CCVersion = FREEBSD_CC_VERSION;
+    if (CCVersion == 0U)
+      CCVersion = Release * 100000U + 1U;
     Builder.defineMacro("__FreeBSD__", Twine(Release));
-    Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 100000U + 1U));
+    Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
     DefineStd(Builder, "unix", Opts);

More information about the cfe-commits mailing list