Integrated: 8341806: Gcc version detection failure on Alinux3

SendaoYan syan at openjdk.org
Fri Oct 11 07:32:20 UTC 2024


On Wed, 9 Oct 2024 11:52:13 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> There is a gcc version detection bug in `make/autoconf/toolchain.m4`.
> Before this PR, the gcc version detection shell command is:
> 
> gcc --version 2>&1 | tr "\n" " " | sed -e 's/ *Copyright .*//' | sed -e 's/^.* ([1-9][0-9]*.[0-9.]*)[^0-9.].*$/\1/'
> 
> And this gcc version detection command can't work on some linux distribution such as alinux3(Alibaba Cloud Linux 3.2104).
> The `gcc --version` first line output is `gcc (GCC) 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)`, because the `sed -e` get the `.*` strings as greedy mode, so  the original command get gcc  version as `2.32`, but the actual version is `10.2.1`
> 
> I observed some `gcc --version` output like:
> 
> 1. alinux3 gcc: `gcc (GCC) 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)`
> 2. centos7/8 gcc: `gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)`
> 3. ubuntu22 gcc: `gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0`
> 4. gcc build from source: `gcc (GCC) 10.3.0`
> 5. riscv cross gcc compiler which build from source: `riscv64-unknown-linux-gnu-gcc (g85f323c2dc3) 13.3.1 20240901`
> 
> The command `gcc version` string pattern is, after the first `) ` split string, and before an empty space or at the end of line.
> So I change the gcc version detection shell command to:
> 
> gcc --version 2>&1 | tr "\n" " " | sed -e 's/ *Copyright .*//' | awk -F ')' '{print $2}' | awk '{print $1}'
> 
> 
> Addiontial testing:
> 
> - [x] configure on alinux3
> - [x] configure on ubuntu22
> - [x] configure on centos7
> - [x] configure with gcc10 which build from source
> 
> By the way, the original makefile command miss an `@` character.
> 
> $SED -e 's/^.* (@<:@1-9@:>@<:@0-9@:>@*.@<:@0-9.@:>@*)@<:@^0-9.@:>@.*$/\1/'`
> 
> The correct makefile command should be:
> 
> $SED -e 's/^.* (@<:@1-9@:>@@<:@0-9@:>@*.@<:@0-9.@:>@*)@<:@^0-9.@:>@.*$/\1/'`

This pull request has now been integrated.

Changeset: ace44e56
Author:    SendaoYan <syan at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/ace44e564ffe67af5fc25a0f126cf48da0eca078
Stats:     7 lines in 1 file changed: 6 ins; 0 del; 1 mod

8341806: Gcc version detection failure on Alinux3

Reviewed-by: ihse, jwaters

-------------

PR: https://git.openjdk.org/jdk/pull/21421


More information about the build-dev mailing list