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

Mistakes in autotools code (configure.ac) #5067

Closed
fullincome opened this issue Mar 10, 2020 · 5 comments
Closed

Mistakes in autotools code (configure.ac) #5067

fullincome opened this issue Mar 10, 2020 · 5 comments
Labels

Comments

@fullincome
Copy link
Contributor

@fullincome fullincome commented Mar 10, 2020

operating system

CentOS 6 with gcc 4.9.2.

curl/libcurl version

upstream (commit 94ced8e)

I did this

  1. Add this line between 64-65 and 275-276 in configure.ac:
    echo "Compiler info: $compiler_id, $compiler_num\n"

  2. ./buildconf && ./configure --enable-werror

I expected the following

Some compiler id and version number (492) in output

I got

Empty $compiler_id, $compiler_num at first echo
And wierd $compiler_num (= 409) at second

Problems and possible solutions:

  1. Condition in configure.ac:68:
    if test "$compiler_num" -ge "500"; then
    is always false, because compiler_num and compiler_id will defined only after CURL_CHECK_COMPILER macro.

As solution: put code about CURL_CFLAG_EXTRAS after CURL_CHECK_COMPILER.

  1. Code in m4/curl-compilers.m4:165-167 determine gcc version wierd. In my view it must be like:
diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4
index c64db4bc6..9eb68f698 100644
--- a/m4/curl-compilers.m4
+++ b/m4/curl-compilers.m4
@@ -164,8 +164,9 @@ 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`
-    compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
+    gccvme=`echo $gccver | cut -d . -f2`
+    gccvlo=`echo $gccver | cut -d . -f3`
+    compiler_num=`(expr $gccvhi "*" 100 + $gccvme "*" 10 + $gccvlo) 2>/dev/null`
     flags_dbg_all="-g -g0 -g1 -g2 -g3"
     flags_dbg_all="$flags_dbg_all -ggdb"
     flags_dbg_all="$flags_dbg_all -gstabs"
@bagder
Copy link
Member

@bagder bagder commented Mar 10, 2020

For (1), yes that seems correct.

For (2), that seems insufficient. On my machine:

$ gcc -dumpversion 
9
$ gcc --version
gcc (Debian 9.2.1-30) 9.2.1 20200224
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -v 2>&1 | grep ^gcc
gcc version 9.2.1 20200224 (Debian 9.2.1-30) 

Checking older gcc versions it seems configure is okay:

$ gcc-4.7 -dumpversion
4.7
$ gcc-5 -dumpversion
5.5.0
$ gcc-6 -dumpversion
6.5.0
$ gcc-7 -dumpversion
7
$ gcc-8 -dumpversion
8
@bagder bagder added the build label Mar 10, 2020
@bagder
Copy link
Member

@bagder bagder commented Mar 10, 2020

BTW, why is (2) a problem in your case? The number logic makes 1.2.3 into "102" but that's intended. It should work fine for gcc < 7.

bagder added a commit that referenced this issue Mar 10, 2020
If --enable-werror is used.

Follow-up to d5c0351 which added it too early in the configure
script before $compiler_num was set correctly and thus this option was
never used.

Reported-by: Stepan Efremov
Fixes #5067
@fullincome
Copy link
Contributor Author

@fullincome fullincome commented Mar 10, 2020

No problem for me anymore, thanks.

(2) - If it intended - ok. Translation of version 1.2.3 -> 102 confused me a little .
With gcc >= 7 there is still a mistake.

bagder added a commit that referenced this issue Mar 10, 2020
The CURL_CHECK_COMPILER_GNU_C function sets the number to MAJOR*100 +
MINOR and ignores the patch version, and since gcc version 7 it only
sets it to MAJOR*100.

Ref: #5067
bagder added a commit that referenced this issue Mar 10, 2020
The CURL_CHECK_COMPILER_GNU_C function sets the number to MAJOR*100 +
MINOR and ignores the patch version, and since gcc version 7 it only
sets it to MAJOR*100.

Reported-by: Stepan Efremov
Ref: #5067
@bagder
Copy link
Member

@bagder bagder commented Mar 10, 2020

For (2) it's not really a mistake either since nothing depends on the minor version to be in the number, so I made sure to better document how the number is created in #5069

@fullincome
Copy link
Contributor Author

@fullincome fullincome commented Mar 10, 2020

👍

bagder added a commit that referenced this issue Mar 11, 2020
The CURL_CHECK_COMPILER_GNU_C function sets the number to MAJOR*100 +
MINOR and ignores the patch version, and since gcc version 7 it only
sets it to MAJOR*100.

Reported-by: Stepan Efremov
Ref: #5067
Closes #5069
@bagder bagder closed this in 77b62fe Mar 11, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.