diff mbox series

[arm-8-branch] Add Linaro version string and macros

Message ID CAD57uCfzSK8=2sDxQo4gMen_wws8GnKrJNq+ocbbT8trwYph6A@mail.gmail.com
State New
Headers show
Series [arm-8-branch] Add Linaro version string and macros | expand

Commit Message

Yvan Roux Aug. 10, 2018, 10:09 a.m. UTC
Hi,

This patch adds Linaro version string and release macros to ARM GCC 8
vendor branch.

Ok to commit?

Thanks
Yvan

gcc/ChangeLog
2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

    * LINARO-VERSION: New file.
    * configure.ac: Add Linaro version string.
    * configure: Regenerate.
    * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.
    (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.
    (cppbuiltin.o): Depend on $(LINAROVER).
    * cppbuiltin.c (parse_linarover): New.
    (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

Comments

Ramana Radhakrishnan Aug. 10, 2018, 11:45 a.m. UTC | #1
On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:
> Hi,

>

> This patch adds Linaro version string and release macros to ARM GCC 8

> vendor branch.

>

> Ok to commit?

>



Ok if no regressions. (I'm assuming you've built and eyeballed that
the pre-processor macros are being produced). (I have a patch to
www-docs for this branch that I'm writing up and should try and get
out today. Though it would be nice to have tests for these if
possible.

regards
Ramana


> Thanks

> Yvan

>

> gcc/ChangeLog

> 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

>

>     * LINARO-VERSION: New file.

>     * configure.ac: Add Linaro version string.

>     * configure: Regenerate.

>     * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.

>     (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.

>     (cppbuiltin.o): Depend on $(LINAROVER).

>     * cppbuiltin.c (parse_linarover): New.

>     (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.
Yvan Roux Aug. 10, 2018, 12:31 p.m. UTC | #2
On Fri, 10 Aug 2018 at 13:45, Ramana Radhakrishnan
<ramana.gcc@googlemail.com> wrote:
>

> On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:

> > Hi,

> >

> > This patch adds Linaro version string and release macros to ARM GCC 8

> > vendor branch.

> >

> > Ok to commit?

> >

>

>

> Ok if no regressions. (I'm assuming you've built and eyeballed that

> the pre-processor macros are being produced). (I have a patch to

> www-docs for this branch that I'm writing up and should try and get

> out today. Though it would be nice to have tests for these if

> possible.


I've not passed the regression testsuite since this patch is part of
Linaro vendor branches for a long time, I've just built an x86_64 c
compiler from arm-8-branch and verified the version string and macros:

$ ~/wip/arm-8-install/bin/gcc --version
gcc (Linaro GCC 8.2-2018.08~dev) 8.2.1 20180802

$ ~/wip/arm-8-install/bin/gcc -E -dM - < /dev/null | grep LINARO
#define __LINARO_SPIN__ 0
#define __LINARO_RELEASE__ 201808

I can add some tests, but it will take some time to remember me how
these kind of thing is tested in the testsuite ;)

> regards

> Ramana

>

>

> > Thanks

> > Yvan

> >

> > gcc/ChangeLog

> > 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

> >

> >     * LINARO-VERSION: New file.

> >     * configure.ac: Add Linaro version string.

> >     * configure: Regenerate.

> >     * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.

> >     (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.

> >     (cppbuiltin.o): Depend on $(LINAROVER).

> >     * cppbuiltin.c (parse_linarover): New.

> >     (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.
Yvan Roux Aug. 10, 2018, 2:35 p.m. UTC | #3
On Fri, 10 Aug 2018 at 14:31, Yvan Roux <yvan.roux@linaro.org> wrote:
>

> On Fri, 10 Aug 2018 at 13:45, Ramana Radhakrishnan

> <ramana.gcc@googlemail.com> wrote:

> >

> > On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:

> > > Hi,

> > >

> > > This patch adds Linaro version string and release macros to ARM GCC 8

> > > vendor branch.

> > >

> > > Ok to commit?

> > >

> >

> >

> > Ok if no regressions. (I'm assuming you've built and eyeballed that

> > the pre-processor macros are being produced). (I have a patch to

> > www-docs for this branch that I'm writing up and should try and get

> > out today. Though it would be nice to have tests for these if

> > possible.

>

> I've not passed the regression testsuite since this patch is part of

> Linaro vendor branches for a long time, I've just built an x86_64 c

> compiler from arm-8-branch and verified the version string and macros:

>

> $ ~/wip/arm-8-install/bin/gcc --version

> gcc (Linaro GCC 8.2-2018.08~dev) 8.2.1 20180802

>

> $ ~/wip/arm-8-install/bin/gcc -E -dM - < /dev/null | grep LINARO

> #define __LINARO_SPIN__ 0

> #define __LINARO_RELEASE__ 201808

>

> I can add some tests, but it will take some time to remember me how

> these kind of thing is tested in the testsuite ;)


Updated version of the patch, with a test case for Linaro macros.  The
test is not strict w/r to the version or spin number to avoid having
to update it every release or re-spin, do you think it is sufficient ?

Testsuite ran with the included test PASS.

gcc/ChangeLog
2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

    * LINARO-VERSION: New file.
    * configure.ac: Add Linaro version string.
    * configure: Regenerate.
    * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.
    (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.
    (cppbuiltin.o): Depend on $(LINAROVER).
    * cppbuiltin.c (parse_linarover): New.
    (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

gcc/testsuite/ChangeLog
2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

    * gcc.dg/cpp/linaro-macros.c: New test.
Index: gcc/LINARO-VERSION
===================================================================
--- gcc/LINARO-VERSION	(nonexistent)
+++ gcc/LINARO-VERSION	(working copy)
@@ -0,0 +1 @@
+8.2-2018.08~dev
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 263464)
+++ gcc/Makefile.in	(working copy)
@@ -854,10 +854,12 @@
 DEVPHASE    := $(srcdir)/DEV-PHASE # experimental, prerelease, ""
 DATESTAMP   := $(srcdir)/DATESTAMP # YYYYMMDD or empty
 REVISION    := $(srcdir)/REVISION  # [BRANCH revision XXXXXX]
+LINAROVER   := $(srcdir)/LINARO-VERSION # M.x-YYYY.MM[-S][~dev]
 
 BASEVER_c   := $(shell cat $(BASEVER))
 DEVPHASE_c  := $(shell cat $(DEVPHASE))
 DATESTAMP_c := $(shell cat $(DATESTAMP))
+LINAROVER_c := $(shell cat $(LINAROVER))
 
 ifeq (,$(wildcard $(REVISION)))
 REVISION_c  :=
@@ -884,6 +886,7 @@
   "\"$(if $(DEVPHASE_c)$(filter-out 0,$(PATCHLEVEL_c)), $(DATESTAMP_c))\""
 PKGVERSION_s:= "\"@PKGVERSION@\""
 BUGURL_s    := "\"@REPORT_BUGS_TO@\""
+LINAROVER_s := "\"$(LINAROVER_c)\""
 
 PKGVERSION  := @PKGVERSION@
 BUGURL_TEXI := @REPORT_BUGS_TEXI@
@@ -2883,8 +2886,9 @@
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
   @TARGET_SYSTEM_ROOT_DEFINE@
 
-CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s)
-cppbuiltin.o: $(BASEVER)
+CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s) \
+	-DLINAROVER=$(LINAROVER_s)
+cppbuiltin.o: $(BASEVER) $(LINAROVER)
 
 CFLAGS-cppdefault.o += $(PREPROCESSOR_DEFINES)
 
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 263464)
+++ gcc/configure	(working copy)
@@ -1726,7 +1726,8 @@
   --with-stabs            arrange to use stabs instead of host debug format
   --with-dwarf2           force the default debug format to be DWARF 2
   --with-specs=SPECS      add SPECS to driver command-line processing
-  --with-pkgversion=PKG   Use PKG in the version string in place of "GCC"
+  --with-pkgversion=PKG   Use PKG in the version string in place of "Linaro
+                          GCC `cat $srcdir/LINARO-VERSION`"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-multilib-list    select multilibs (AArch64, SH and x86-64 only)
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
@@ -7649,7 +7650,7 @@
       *)   PKGVERSION="($withval) " ;;
      esac
 else
-  PKGVERSION="(GCC) "
+  PKGVERSION="(Linaro GCC `cat $srcdir/LINARO-VERSION`) "
 
 fi
 
@@ -18448,7 +18449,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18451 "configure"
+#line 18452 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18554,7 +18555,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18557 "configure"
+#line 18558 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 263464)
+++ gcc/configure.ac	(working copy)
@@ -929,7 +929,7 @@
 )
 AC_SUBST(CONFIGURE_SPECS)
 
-ACX_PKGVERSION([GCC])
+ACX_PKGVERSION([Linaro GCC `cat $srcdir/LINARO-VERSION`])
 ACX_BUGURL([https://gcc.gnu.org/bugs/])
 
 # Sanity check enable_languages in case someone does not run the toplevel
Index: gcc/cppbuiltin.c
===================================================================
--- gcc/cppbuiltin.c	(revision 263464)
+++ gcc/cppbuiltin.c	(working copy)
@@ -53,18 +53,41 @@
     *patchlevel = s_patchlevel;
 }
 
+/* Parse a LINAROVER version string of the format "M.m-year.month[-spin][~dev]"
+   to create Linaro release number YYYYMM and spin version.  */
+static void
+parse_linarover (int *release, int *spin)
+{
+  static int s_year = -1, s_month, s_spin;
 
+  if (s_year == -1)
+    if (sscanf (LINAROVER, "%*[^-]-%d.%d-%d", &s_year, &s_month, &s_spin) != 3)
+      {
+	sscanf (LINAROVER, "%*[^-]-%d.%d", &s_year, &s_month);
+	s_spin = 0;
+      }
+
+  if (release)
+    *release = s_year * 100 + s_month;
+
+  if (spin)
+    *spin = s_spin;
+}
+
 /* Define __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ and __VERSION__.  */
 static void
 define__GNUC__ (cpp_reader *pfile)
 {
-  int major, minor, patchlevel;
+  int major, minor, patchlevel, linaro_release, linaro_spin;
 
   parse_basever (&major, &minor, &patchlevel);
+  parse_linarover (&linaro_release, &linaro_spin);
   cpp_define_formatted (pfile, "__GNUC__=%d", major);
   cpp_define_formatted (pfile, "__GNUC_MINOR__=%d", minor);
   cpp_define_formatted (pfile, "__GNUC_PATCHLEVEL__=%d", patchlevel);
   cpp_define_formatted (pfile, "__VERSION__=\"%s\"", version_string);
+  cpp_define_formatted (pfile, "__LINARO_RELEASE__=%d", linaro_release);
+  cpp_define_formatted (pfile, "__LINARO_SPIN__=%d", linaro_spin);
   cpp_define_formatted (pfile, "__ATOMIC_RELAXED=%d", MEMMODEL_RELAXED);
   cpp_define_formatted (pfile, "__ATOMIC_SEQ_CST=%d", MEMMODEL_SEQ_CST);
   cpp_define_formatted (pfile, "__ATOMIC_ACQUIRE=%d", MEMMODEL_ACQUIRE);
Index: gcc/testsuite/gcc.dg/cpp/linaro-macros.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/linaro-macros.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/cpp/linaro-macros.c	(working copy)
@@ -0,0 +1,14 @@
+/* Test __LINARO_RELEASE__ and __LINARO_SPIN__.  */
+/* { dg-do compile } */
+
+#if defined(__LINARO_RELEASE__) && __LINARO_RELEASE__ >= 201808
+int i;
+#else
+#error "Bad __LINARO_RELEASE__."
+#endif
+
+#if defined(__LINARO_SPIN__) && __LINARO_SPIN__ >= 0
+int j;
+#else
+#error "Bad __LINARO_SPIN__."
+#endif
Ramana Radhakrishnan Aug. 10, 2018, 3:01 p.m. UTC | #4
On Fri, Aug 10, 2018 at 3:35 PM, Yvan Roux <yvan.roux@linaro.org> wrote:
> On Fri, 10 Aug 2018 at 14:31, Yvan Roux <yvan.roux@linaro.org> wrote:

>>

>> On Fri, 10 Aug 2018 at 13:45, Ramana Radhakrishnan

>> <ramana.gcc@googlemail.com> wrote:

>> >

>> > On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:

>> > > Hi,

>> > >

>> > > This patch adds Linaro version string and release macros to ARM GCC 8

>> > > vendor branch.

>> > >

>> > > Ok to commit?

>> > >

>> >

>> >

>> > Ok if no regressions. (I'm assuming you've built and eyeballed that

>> > the pre-processor macros are being produced). (I have a patch to

>> > www-docs for this branch that I'm writing up and should try and get

>> > out today. Though it would be nice to have tests for these if

>> > possible.

>>

>> I've not passed the regression testsuite since this patch is part of

>> Linaro vendor branches for a long time, I've just built an x86_64 c

>> compiler from arm-8-branch and verified the version string and macros:

>>

>> $ ~/wip/arm-8-install/bin/gcc --version

>> gcc (Linaro GCC 8.2-2018.08~dev) 8.2.1 20180802

>>

>> $ ~/wip/arm-8-install/bin/gcc -E -dM - < /dev/null | grep LINARO

>> #define __LINARO_SPIN__ 0

>> #define __LINARO_RELEASE__ 201808

>>

>> I can add some tests, but it will take some time to remember me how

>> these kind of thing is tested in the testsuite ;)

>

> Updated version of the patch, with a test case for Linaro macros.  The

> test is not strict w/r to the version or spin number to avoid having

> to update it every release or re-spin, do you think it is sufficient ?

>

> Testsuite ran with the included test PASS.

>

> gcc/ChangeLog

> 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

>

>     * LINARO-VERSION: New file.

>     * configure.ac: Add Linaro version string.

>     * configure: Regenerate.

>     * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.

>     (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.

>     (cppbuiltin.o): Depend on $(LINAROVER).

>     * cppbuiltin.c (parse_linarover): New.

>     (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

>

> gcc/testsuite/ChangeLog

> 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

>

>     * gcc.dg/cpp/linaro-macros.c: New test.



Looks good, thanks  - can you put the Changelog in a Changelog.arm file ?

regards
Ramana
Yvan Roux Aug. 10, 2018, 4 p.m. UTC | #5
On Fri, 10 Aug 2018 at 17:01, Ramana Radhakrishnan
<ramana.gcc@googlemail.com> wrote:
>

> On Fri, Aug 10, 2018 at 3:35 PM, Yvan Roux <yvan.roux@linaro.org> wrote:

> > On Fri, 10 Aug 2018 at 14:31, Yvan Roux <yvan.roux@linaro.org> wrote:

> >>

> >> On Fri, 10 Aug 2018 at 13:45, Ramana Radhakrishnan

> >> <ramana.gcc@googlemail.com> wrote:

> >> >

> >> > On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:

> >> > > Hi,

> >> > >

> >> > > This patch adds Linaro version string and release macros to ARM GCC 8

> >> > > vendor branch.

> >> > >

> >> > > Ok to commit?

> >> > >

> >> >

> >> >

> >> > Ok if no regressions. (I'm assuming you've built and eyeballed that

> >> > the pre-processor macros are being produced). (I have a patch to

> >> > www-docs for this branch that I'm writing up and should try and get

> >> > out today. Though it would be nice to have tests for these if

> >> > possible.

> >>

> >> I've not passed the regression testsuite since this patch is part of

> >> Linaro vendor branches for a long time, I've just built an x86_64 c

> >> compiler from arm-8-branch and verified the version string and macros:

> >>

> >> $ ~/wip/arm-8-install/bin/gcc --version

> >> gcc (Linaro GCC 8.2-2018.08~dev) 8.2.1 20180802

> >>

> >> $ ~/wip/arm-8-install/bin/gcc -E -dM - < /dev/null | grep LINARO

> >> #define __LINARO_SPIN__ 0

> >> #define __LINARO_RELEASE__ 201808

> >>

> >> I can add some tests, but it will take some time to remember me how

> >> these kind of thing is tested in the testsuite ;)

> >

> > Updated version of the patch, with a test case for Linaro macros.  The

> > test is not strict w/r to the version or spin number to avoid having

> > to update it every release or re-spin, do you think it is sufficient ?

> >

> > Testsuite ran with the included test PASS.

> >

> > gcc/ChangeLog

> > 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

> >

> >     * LINARO-VERSION: New file.

> >     * configure.ac: Add Linaro version string.

> >     * configure: Regenerate.

> >     * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.

> >     (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.

> >     (cppbuiltin.o): Depend on $(LINAROVER).

> >     * cppbuiltin.c (parse_linarover): New.

> >     (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

> >

> > gcc/testsuite/ChangeLog

> > 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

> >

> >     * gcc.dg/cpp/linaro-macros.c: New test.

>

>

> Looks good, thanks  - can you put the Changelog in a Changelog.arm file ?


Sure, does it need the FSF Copyright lines at the end like other ChangeLogs ?

Thanks
Yvan

> regards

> Ramana
Ramana Radhakrishnan Aug. 14, 2018, 9:22 a.m. UTC | #6
On Fri, Aug 10, 2018 at 5:00 PM, Yvan Roux <yvan.roux@linaro.org> wrote:
> On Fri, 10 Aug 2018 at 17:01, Ramana Radhakrishnan

> <ramana.gcc@googlemail.com> wrote:

>>

>> On Fri, Aug 10, 2018 at 3:35 PM, Yvan Roux <yvan.roux@linaro.org> wrote:

>> > On Fri, 10 Aug 2018 at 14:31, Yvan Roux <yvan.roux@linaro.org> wrote:

>> >>

>> >> On Fri, 10 Aug 2018 at 13:45, Ramana Radhakrishnan

>> >> <ramana.gcc@googlemail.com> wrote:

>> >> >

>> >> > On Fri, Aug 10, 2018 at 11:09 AM, Yvan Roux <yvan.roux@linaro.org> wrote:

>> >> > > Hi,

>> >> > >

>> >> > > This patch adds Linaro version string and release macros to ARM GCC 8

>> >> > > vendor branch.

>> >> > >

>> >> > > Ok to commit?

>> >> > >

>> >> >

>> >> >

>> >> > Ok if no regressions. (I'm assuming you've built and eyeballed that

>> >> > the pre-processor macros are being produced). (I have a patch to

>> >> > www-docs for this branch that I'm writing up and should try and get

>> >> > out today. Though it would be nice to have tests for these if

>> >> > possible.

>> >>

>> >> I've not passed the regression testsuite since this patch is part of

>> >> Linaro vendor branches for a long time, I've just built an x86_64 c

>> >> compiler from arm-8-branch and verified the version string and macros:

>> >>

>> >> $ ~/wip/arm-8-install/bin/gcc --version

>> >> gcc (Linaro GCC 8.2-2018.08~dev) 8.2.1 20180802

>> >>

>> >> $ ~/wip/arm-8-install/bin/gcc -E -dM - < /dev/null | grep LINARO

>> >> #define __LINARO_SPIN__ 0

>> >> #define __LINARO_RELEASE__ 201808

>> >>

>> >> I can add some tests, but it will take some time to remember me how

>> >> these kind of thing is tested in the testsuite ;)

>> >

>> > Updated version of the patch, with a test case for Linaro macros.  The

>> > test is not strict w/r to the version or spin number to avoid having

>> > to update it every release or re-spin, do you think it is sufficient ?

>> >

>> > Testsuite ran with the included test PASS.

>> >

>> > gcc/ChangeLog

>> > 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

>> >

>> >     * LINARO-VERSION: New file.

>> >     * configure.ac: Add Linaro version string.

>> >     * configure: Regenerate.

>> >     * Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.

>> >     (CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.

>> >     (cppbuiltin.o): Depend on $(LINAROVER).

>> >     * cppbuiltin.c (parse_linarover): New.

>> >     (define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

>> >

>> > gcc/testsuite/ChangeLog

>> > 2018-08-10  Yvan Roux  <yvan.roux@linaro.org>

>> >

>> >     * gcc.dg/cpp/linaro-macros.c: New test.

>>

>>

>> Looks good, thanks  - can you put the Changelog in a Changelog.arm file ?

>

> Sure, does it need the FSF Copyright lines at the end like other ChangeLogs ?


Yep it's like any other upstream branch.

ramana
>

> Thanks

> Yvan

>

>> regards

>> Ramana
diff mbox series

Patch

Index: gcc/LINARO-VERSION
===================================================================
--- gcc/LINARO-VERSION	(nonexistent)
+++ gcc/LINARO-VERSION	(working copy)
@@ -0,0 +1 @@ 
+8.2-2018.08~dev
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 263464)
+++ gcc/Makefile.in	(working copy)
@@ -854,10 +854,12 @@ 
 DEVPHASE    := $(srcdir)/DEV-PHASE # experimental, prerelease, ""
 DATESTAMP   := $(srcdir)/DATESTAMP # YYYYMMDD or empty
 REVISION    := $(srcdir)/REVISION  # [BRANCH revision XXXXXX]
+LINAROVER   := $(srcdir)/LINARO-VERSION # M.x-YYYY.MM[-S][~dev]
 
 BASEVER_c   := $(shell cat $(BASEVER))
 DEVPHASE_c  := $(shell cat $(DEVPHASE))
 DATESTAMP_c := $(shell cat $(DATESTAMP))
+LINAROVER_c := $(shell cat $(LINAROVER))
 
 ifeq (,$(wildcard $(REVISION)))
 REVISION_c  :=
@@ -884,6 +886,7 @@ 
   "\"$(if $(DEVPHASE_c)$(filter-out 0,$(PATCHLEVEL_c)), $(DATESTAMP_c))\""
 PKGVERSION_s:= "\"@PKGVERSION@\""
 BUGURL_s    := "\"@REPORT_BUGS_TO@\""
+LINAROVER_s := "\"$(LINAROVER_c)\""
 
 PKGVERSION  := @PKGVERSION@
 BUGURL_TEXI := @REPORT_BUGS_TEXI@
@@ -2883,8 +2886,9 @@ 
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
   @TARGET_SYSTEM_ROOT_DEFINE@
 
-CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s)
-cppbuiltin.o: $(BASEVER)
+CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s) \
+	-DLINAROVER=$(LINAROVER_s)
+cppbuiltin.o: $(BASEVER) $(LINAROVER)
 
 CFLAGS-cppdefault.o += $(PREPROCESSOR_DEFINES)
 
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 263464)
+++ gcc/configure	(working copy)
@@ -1726,7 +1726,8 @@ 
   --with-stabs            arrange to use stabs instead of host debug format
   --with-dwarf2           force the default debug format to be DWARF 2
   --with-specs=SPECS      add SPECS to driver command-line processing
-  --with-pkgversion=PKG   Use PKG in the version string in place of "GCC"
+  --with-pkgversion=PKG   Use PKG in the version string in place of "Linaro
+                          GCC `cat $srcdir/LINARO-VERSION`"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-multilib-list    select multilibs (AArch64, SH and x86-64 only)
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
@@ -7649,7 +7650,7 @@ 
       *)   PKGVERSION="($withval) " ;;
      esac
 else
-  PKGVERSION="(GCC) "
+  PKGVERSION="(Linaro GCC `cat $srcdir/LINARO-VERSION`) "
 
 fi
 
@@ -18448,7 +18449,7 @@ 
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18451 "configure"
+#line 18452 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18554,7 +18555,7 @@ 
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18557 "configure"
+#line 18558 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 263464)
+++ gcc/configure.ac	(working copy)
@@ -929,7 +929,7 @@ 
 )
 AC_SUBST(CONFIGURE_SPECS)
 
-ACX_PKGVERSION([GCC])
+ACX_PKGVERSION([Linaro GCC `cat $srcdir/LINARO-VERSION`])
 ACX_BUGURL([https://gcc.gnu.org/bugs/])
 
 # Sanity check enable_languages in case someone does not run the toplevel
Index: gcc/cppbuiltin.c
===================================================================
--- gcc/cppbuiltin.c	(revision 263464)
+++ gcc/cppbuiltin.c	(working copy)
@@ -53,18 +53,41 @@ 
     *patchlevel = s_patchlevel;
 }
 
+/* Parse a LINAROVER version string of the format "M.m-year.month[-spin][~dev]"
+   to create Linaro release number YYYYMM and spin version.  */
+static void
+parse_linarover (int *release, int *spin)
+{
+  static int s_year = -1, s_month, s_spin;
 
+  if (s_year == -1)
+    if (sscanf (LINAROVER, "%*[^-]-%d.%d-%d", &s_year, &s_month, &s_spin) != 3)
+      {
+	sscanf (LINAROVER, "%*[^-]-%d.%d", &s_year, &s_month);
+	s_spin = 0;
+      }
+
+  if (release)
+    *release = s_year * 100 + s_month;
+
+  if (spin)
+    *spin = s_spin;
+}
+
 /* Define __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ and __VERSION__.  */
 static void
 define__GNUC__ (cpp_reader *pfile)
 {
-  int major, minor, patchlevel;
+  int major, minor, patchlevel, linaro_release, linaro_spin;
 
   parse_basever (&major, &minor, &patchlevel);
+  parse_linarover (&linaro_release, &linaro_spin);
   cpp_define_formatted (pfile, "__GNUC__=%d", major);
   cpp_define_formatted (pfile, "__GNUC_MINOR__=%d", minor);
   cpp_define_formatted (pfile, "__GNUC_PATCHLEVEL__=%d", patchlevel);
   cpp_define_formatted (pfile, "__VERSION__=\"%s\"", version_string);
+  cpp_define_formatted (pfile, "__LINARO_RELEASE__=%d", linaro_release);
+  cpp_define_formatted (pfile, "__LINARO_SPIN__=%d", linaro_spin);
   cpp_define_formatted (pfile, "__ATOMIC_RELAXED=%d", MEMMODEL_RELAXED);
   cpp_define_formatted (pfile, "__ATOMIC_SEQ_CST=%d", MEMMODEL_SEQ_CST);
   cpp_define_formatted (pfile, "__ATOMIC_ACQUIRE=%d", MEMMODEL_ACQUIRE);