Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autotools: fix/improve gcc and Apple clang version detection #12362

Closed

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Nov 19, 2023

  • Before this patch we expected n.n -dumpversion output, but Ubuntu
    may return n-win32 (also with -dumpfullversion). Causing these
    errors and failing to enable picky warnings:

    ../configure: line 23845: test: : integer expression expected
    

    Ref: https://github.com/libssh2/libssh2/actions/runs/6263453828/job/17007893718#step:5:143

    Fix that by stripping any dash-suffix and handling a dotless (major-only)
    version number by assuming .0 in that case.

    9.3-posix, 9.3-win32, 6, 9.3.0, 11, 11.2, 11.2.0
    Ref: fix version detection in str_to_version for versions formatted as (n).(n)-suffix mamedev/mame#9767

  • fix Apple clang version detection for releases between
    'Apple LLVM version 7.3.0' and 'Apple LLVM version 10.0.1' where the
    version was under-detected as 3.7 llvm/clang equivalent.

  • fix Apple clang version detection for 'Apple clang version 11.0.0'
    and newer where the Apple clang version was detected, instead of its
    llvm/clang equivalent.

  • display detected clang/gcc/icc compiler version.

Via libssh2:

Closes #12362

@vszakats vszakats added the build label Nov 19, 2023
@bagder
Copy link
Member

bagder commented Nov 20, 2023

gcc version detection is still half broken because we translate '10' to '10.10' because cut -d. -f2 returns the first word if the delimiter missing.

Is cut's -s portable enough to be used in the -f2 invocation ? "do not print lines not containing delimiters"

@vszakats
Copy link
Member Author

-s is there on macOS and GNU, and part of POSIX.2: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html

But, we need to fill the blank with a zero, so this is what I was experiment with instead:

--- a/m4/curl-compilers.m4
+++ b/m4/curl-compilers.m4
@@ -160,7 +160,11 @@ AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
     compiler_id="GNU_C"
     gccver=`$CC -dumpversion`
     gccvhi=`echo $gccver | cut -d . -f1`
-    gccvlo=`echo $gccver | cut -d . -f2`
+    if echo $gccver | grep -F "." >/dev/null; then
+      gccvlo=`echo $gccver | cut -d . -f2`
+    else
+      gccvlo="0"
+    fi
     compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
     flags_dbg_yes="-g"
     flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast"

Before this patch we expected `n.n` `-dumpversion` output, but Ubuntu
may return `n-win32` (also with `-dumpfullversion`). Causing these
errors and failing to enable picky warnings:
```
../configure: line 23845: test: : integer expression expected
```
Ref: https://github.com/libssh2/libssh2/actions/runs/6263453828/job/17007893718#step:5:143

Fix that by stripping any dash-suffix.

gcc version detection is still half broken because we translate '10'
to '10.10' because `cut -d. -f2` returns the first word if the
delimiter missing.

More possible `-dumpversion` output: `10-posix`, `10-win32`,
`9.3-posix`, `9.3-win32`, `6`, `9.3.0`, `11`, `11.2`, `11.2.0`
Ref: mamedev/mame#9767

Copied from project libssh2:
libssh2/libssh2@00a3b88
libssh2/libssh2#1187

Closes #xxxxx
@vszakats vszakats force-pushed the autotools-fix-gcc-ver-detection-ubuntu branch from 4db23ba to 862a1a7 Compare November 20, 2023 09:26
@vszakats vszakats changed the title autotools: fix to strip suffix from gcc version autotools: fix gcc version detection for suffixed or dotless numbers Nov 20, 2023
@vszakats

This comment was marked as resolved.

@vszakats vszakats changed the title autotools: fix gcc version detection for suffixed or dotless numbers autotools: fix/improve gcc and Apple clang version detection Nov 20, 2023
@vszakats
Copy link
Member Author

Merged #12358 into this PR, and also applied the Xcode version fixes from libssh2/libssh2#1232.

@vszakats vszakats closed this in 9523192 Nov 20, 2023
@vszakats vszakats deleted the autotools-fix-gcc-ver-detection-ubuntu branch November 20, 2023 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants