Bug #37743 BUILD/check-cpu fails on openSUSE Linux 11.0
Submitted: 30 Jun 2008 15:36 Modified: 30 Sep 2008 7:24
Reporter: Lenz Grimmer Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0 and up OS:Linux (openSUSE 11.0)
Assigned to: Assigned Account CPU Architecture:Any
Tags: compiling, Contribution, gcc, opensuse, patch

[30 Jun 2008 15:36] Lenz Grimmer
Description:
When trying to compile the MySQL Server on openSUSE 11.0 using any of the BUILD/* compile scripts, the script fails with an error:

lenz@thebe:~/my/bzr/mysql-server/mysql-5.0> ./BUILD/compile-pentium-debug-max
expr: syntax error

I was able to chase it down to the root cause: the script "BUILD/check-cpu" chokes on the version string of the gcc compiler installed on this distribution:

lenz@thebe:~/my/bzr/mysql-server/mysql-5.0> sh -x BUILD/check-cpu 2>&1 | tail -20
+ test -z ''
+ cc=gcc
++ gcc --version
++ sed 1q
+ cc_ver='gcc (SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]'
++ echo gcc '(SUSE' 'Linux)' 4.3.1 20080507 '(prerelease)' '[gcc-4_3-branch' revision '135036]'
++ sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g;        s/^ *//g; s/ .*//g'
+ cc_verno=43
++ echo 43
++ tr . ' '
+ set -- 43
+ cc_major=43
+ cc_minor=
+ cc_patch=
++ expr 43 '*' 100 +
expr: syntax error
+ cc_comp=
+ case "$cc_ver--$cc_verno" in
+ check_cpu_cflags=
+ return

How to repeat:
Call BUILD/check-cpu in any given MySQL Server tree on openSUSE 11.0, observe the error above. The string "[gcc-4_3-branch" causes the "^.*gcc" pattern match to fail.

Suggested fix:
Fix the regular expression that performs the pattern matching on the compiler version string. It seems the first pattern matching against "gcc" is too greedy and truncates too much of the version string. It may be better to change this part to match against "any text, followed by text in brackets" (but only the first match).
[30 Jun 2008 17:50] Sveta Smirnova
Thank you for the report.

Please indicate which shell do you use.
[1 Jul 2008 6:02] Lenz Grimmer
Hi Sveta, thanks for your message. Not that I think it matters, I usually use zsh. However, the scripts in the BUILD subdirectory all use #!/bin/sh and this is what I used to debug and isolate the problem as well.

It's not a shell problem, the sed call in line 172 that tries to determine the gcc version fails on openSUSE 11.0, because the first regexp is too greedy and matches on the second "gcc".

This is the code in question:

  cc_ver=`$cc --version | sed 1q`
  cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g;  s/^ *//g; s/ .*//g'`

The "s/^.*gcc/gcc/g" removes too much of the "gcc (SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]" string (as "gcc" occurs a second time at the end of the string")
[1 Jul 2008 8:26] Lenz Grimmer
Setting it to verified as per our IRC discussion.
[1 Jul 2008 11:01] Lenz Grimmer
Patch to fix BUG#37743 - correct the regexp to match the compiler string on openSUSE 11.0

Attachment: check-cpu.patch (text/x-patch), 444 bytes.

[1 Jul 2008 11:03] Lenz Grimmer
The patch attached fixes the issue (thanks to Daniel for the suggestion). Please apply! Thanks.
[29 Sep 2008 9:35] Lenz Grimmer
Seems like this is a duplicate of Bug#36519 (check-cpu fails with gcc 4.3.1) - I can not reproduce it anymore. Sorry for the noise!