Re: compiler info in kernel identification string

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Sun, 23 Dec 2012 15:18:14 +0200
on 15/11/2012 22:43 Andriy Gapon said the following:
> on 14/11/2012 01:43 Mateusz Guzik said the following:
>> Hello,
>>
>> avg_at_ 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
_at__at_ -86,6 +86,7 _at__at_ 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
_at__at_ -159,6 +160,7 _at__at_ $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
_at__at_ -325,6 +325,7 _at__at_ 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
_at__at_ -49,6 +49,7 _at__at_ 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
Received on Sun Dec 23 2012 - 12:18:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:33 UTC