Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Dec 2012 15:18:14 +0200
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Mateusz Guzik <mjguzik@gmail.com>, freebsd-current@FreeBSD.org
Subject:   Re: compiler info in kernel identification string
Message-ID:  <50D70496.6030307@FreeBSD.org>
In-Reply-To: <50A5540D.2030707@FreeBSD.org>
References:  <20121113234303.GA15319@dft-labs.eu> <50A5540D.2030707@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
on 15/11/2012 22:43 Andriy Gapon said the following:
> on 14/11/2012 01:43 Mateusz Guzik said the following:
>> Hello,
>>
>> avg@ suggested to include compiler version in the kernel so that it's
>> present in uname (and one can easly tell what was used to compile it).
>>
>> Here is my attempt:
>> http://people.freebsd.org/~mjg/patches/newvers-compiler.diff
> 
> When are you committing this?

It seems that this effort has stuck?..

Here is a change that I am using locally.  It doesn't change uname output at
all, but rather adds a compiler version string to the kernel banner.

I may even commit this :)

    [test] print compiler version in the kernel banner

diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 5e83e1a..724f609 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -86,6 +86,7 @@ fi
 touch version
 v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
 i=`${MAKE:-make} -V KERN_IDENT`
+compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')

 for dir in /bin /usr/bin /usr/local/bin; do
 	if [ -x "${dir}/svnversion" ] && [ -z ${svnversion} ] ; then
@@ -159,6 +160,7 @@ $COPYRIGHT

 char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
 char version[sizeof(VERSTR) > 256 ? sizeof(VERSTR) : 256] = VERSTR;
+char compiler_version[] = "${compiler_v}";
 char ostype[] = "${TYPE}";
 char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR;
 int osreldate = ${RELDATE};
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 00b1c3f..a92b6db 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -325,6 +325,7 @@ print_version(void *data __unused)
 	while (len > 0 && version[len - 1] == '\n')
 		len--;
 	printf("%.*s %s\n", len, version, machine);
+	printf("%s\n", compiler_version);
 }

 SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t,
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index fec77d2..3163b9f 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -49,6 +49,7 @@ extern int cold;		/* nonzero if we are doing a cold boot */
 extern int rebooting;		/* kern_reboot() has been called. */
 extern const char *panicstr;	/* panic message */
 extern char version[];		/* system version */
+extern char compiler_version[];	/* system version */
 extern char copyright[];	/* system copyright */
 extern int kstack_pages;	/* number of kernel stack pages */


-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50D70496.6030307>