Patchwork [U-Boot,RFC] ARM: print gcc version

login
register
mail settings
Submitter Peter Tyser
Date Jan. 18, 2011, 4:20 p.m.
Message ID <1295367620.29642.10984.camel@petert>
Download mbox | patch
Permalink /patch/79327/
State RFC
Headers show

Comments

Peter Tyser - Jan. 18, 2011, 4:20 p.m.
> >> Anyway, I would found it a nice feature, at startup or when running the
> >> version command, but both aren't a must.
> >
> > I think it would be a really useful extension to the version command.
> > Looking forwad to seeing your patch.
> 
> Maybe if someone could feed me with what to use for the version. E.g. my 
> gcc here defines __VERSION__ as "4.5.2" but when I'm looking at
> u-boot/lib/asm-offsets.s I see
> 
> .ident  "GCC: (Gentoo 4.5.2 p1.0, pie-0.4.5) 4.5.2"
> 
> So I would like to display that which would be in line with the comment 
> section of generated binaries.
> 
> But when I use "gcc -E -dM empty.c" to print all predefined macros, I 
> don't see the text found in .ident. Not even something else which 
> includes "Gentoo".

I believe the output of "$(CC) --version" should contain the same data
as your .ident string.  You could echo it into a file like:

Best,
Peter
Alexander Holler - Jan. 18, 2011, 5:04 p.m.
Am 18.01.2011 17:20, schrieb Peter Tyser:
>>>> Anyway, I would found it a nice feature, at startup or when running the
>>>> version command, but both aren't a must.
>>>
>>> I think it would be a really useful extension to the version command.
>>> Looking forwad to seeing your patch.
>>
>> Maybe if someone could feed me with what to use for the version. E.g. my
>> gcc here defines __VERSION__ as "4.5.2" but when I'm looking at
>> u-boot/lib/asm-offsets.s I see
>>
>> .ident  "GCC: (Gentoo 4.5.2 p1.0, pie-0.4.5) 4.5.2"
>>
>> So I would like to display that which would be in line with the comment
>> section of generated binaries.
>>
>> But when I use "gcc -E -dM empty.c" to print all predefined macros, I
>> don't see the text found in .ident. Not even something else which
>> includes "Gentoo".
>
> I believe the output of "$(CC) --version" should contain the same data
> as your .ident string.  You could echo it into a file like:
> diff --git a/Makefile b/Makefile
> index 0685ef9..e070d40 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -416,6 +416,8 @@ $(U_BOOT_ONENAND):  $(ONENAND_IPL) $(obj)u-boot.bin
>   $(VERSION_FILE):
>                  @( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
>                   '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' )>  $@.tmp
> +               @( printf '#define CC_VERSION_STRING "%s"\n' \
> +                '$(shell $(CC) --version | head -1)' )>>  $@.tmp
>                  @cmp -s $@ $@.tmp&&  rm -f $@.tmp || mv -f $@.tmp $@
>
>   $(TIMESTAMP_FILE):

That would the trick. The first line of gcc --version includes here the 
correct string. Thanks. (Btw. I would use head -n 1)

But I will wait for a comment from one of the maintainers about defining 
CC_VERSION_STRING.

If someone gives me an ok, I will write a patch including your 
suggestion and will print that version in the command version.

Regards,

Alexander
Wolfgang Denk - Jan. 18, 2011, 7:53 p.m.
Dear Alexander Holler,

In message <4D35C836.3020400@ahsoftware.de> you wrote:
>
> > @@ -416,6 +416,8 @@ $(U_BOOT_ONENAND):  $(ONENAND_IPL) $(obj)u-boot.bin
> >   $(VERSION_FILE):
> >                  @( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
> >                   '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' )>  $@.tmp
> > +               @( printf '#define CC_VERSION_STRING "%s"\n' \
> > +                '$(shell $(CC) --version | head -1)' )>>  $@.tmp
> >                  @cmp -s $@ $@.tmp&&  rm -f $@.tmp || mv -f $@.tmp $@
> >
> >   $(TIMESTAMP_FILE):
> 
> That would the trick. The first line of gcc --version includes here the 
> correct string. Thanks. (Btw. I would use head -n 1)
> 
> But I will wait for a comment from one of the maintainers about defining 
> CC_VERSION_STRING.
> 
> If someone gives me an ok, I will write a patch including your 
> suggestion and will print that version in the command version.

Looks good to me - please go on.

Hm... while we are at it... the bintuils (especially linker) version
is probably equally interesting, so eventually we should also add a
LD_VERSION_STRING.

Best regards,

Wolfgang Denk

Patch

diff --git a/Makefile b/Makefile
index 0685ef9..e070d40 100644
--- a/Makefile
+++ b/Makefile
@@ -416,6 +416,8 @@  $(U_BOOT_ONENAND):  $(ONENAND_IPL) $(obj)u-boot.bin
 $(VERSION_FILE):
                @( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
                 '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ) > $@.tmp
+               @( printf '#define CC_VERSION_STRING "%s"\n' \
+                '$(shell $(CC) --version | head -1)' ) >> $@.tmp
                @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 $(TIMESTAMP_FILE):