Hi, Mathias
On 04/26/2021 03:17 PM, Mathias Krause wrote:
Am 25.04.21 um 07:50 schrieb Youling Tang:
> When using the "help -k" command in the 5.12 kernel, it was found
> that the
> gcc_version character string was displayed as 0.0.0.
> Check the value of the proc_version string to know,
> crash> help -k
> ...
> proc_version: Linux version 5.12.0-rc2kexec+ (root@bogon) (gcc
> (GCC) 7.3.1
> 20180303 (Red Hat 7.3.1-6), GNU ld version
> 2.28-13.fc21.loongson.6) #30
> SMP PREEMPT Thu Apr 22 09:04:57 HKT 2021
> ...
>
> Therefore, the "gcc (GCC)" character should be searched to obtain the
> correct
> character string "gcc_version" value.
I don't think that's sufficient to catch current kernels.
Here's another data point from a Debian system:
$ cat /proc/version
Linux version 5.9.0-0.bpo.5-amd64 (debian-kernel(a)lists.debian.org)
(gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian)
2.31.1) #1 SMP Debian 5.9.15-1~bpo10+1 (2020-12-31)
So the below pattern won't match this one either.
Maybe we should give up on extracting the version and simply use the
full string for diagnostical messages? Like extracting everything from
"gcc" till the next ","?
If it is only used to display gcc_version during "help -k", it is
possible
to display it in a string format (Like extracting everything from "gcc" till
the next ","). But in the def.h file, the THIS_GCC_VERSION macro will
use the
relevant version number integer value, and in the form of a string, it will
not be able to correctly define THIS_GCC_VERSION.
Thanks,
Youling
Thanks,
Mathias
>
> Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
> ---
> kernel.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/kernel.c b/kernel.c
> index 528f6ee..a1872c2 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -1103,9 +1103,13 @@ verify_version(void)
> /*
> * Keeping the gcc version with #define's is getting out of hand.
> */
> - if ((p1 = strstr(kt->proc_version, "gcc version "))) {
> + if ((p1 = strstr(kt->proc_version, "gcc version ")) ||
> + (p1 = strstr(kt->proc_version, "gcc (GCC) "))) {
> BZERO(buf, BUFSIZE);
> - p1 += strlen("gcc version ");
> + if (strstr(kt->proc_version, "gcc version "))
> + p1 += strlen("gcc version ");
> + else
> + p1 += strlen("gcc (GCC) ");
> p2 = buf;
> while (((*p1 >= '0') && (*p1 <= '9')) || (*p1
== '.')) {
> if (*p1 == '.')
> @@ -3661,7 +3665,7 @@ module_init(void)
> modules_found = TRUE;
> break;
> }
> - }
> + }
> if (!modules_found) {
> error(WARNING,
>