Bug #33536 Option "--print-libgcc-file" does not work with ICC compiler
Submitted: 27 Dec 2007 14:36 Modified: 14 Mar 2008 1:58
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S2 (Serious)
Version:4.1 and up OS:Linux (icc)
Assigned to: Joerg Bruehe CPU Architecture:Any

[27 Dec 2007 14:36] Joerg Bruehe
Description:
Starting from 4.1, the tool "scripts/make_binary_distribution.sh" contains a line
      gcclib=`@CC@ @CFLAGS@ --print-libgcc-file`

There are two problems with that if the compiler used is ICC:
1) The option "--print-libgcc-file" is silently ignored.
2) The compiler will fail because it is not given a source file.

This still works in older versions (4.1 and 5.0), because the script checks the compiler return code and will not use the value of "$gcclib" if that return code is non-zero.

However, it becomes a problem when the script gets a "set -e" added, as now this failing compiler call makes the whole tool abort.

This was done for version 5.1 and up,
but even in the older versions the tool should not simply ignore a failing call.
Also, the output should be checked before it is assumed to be a file name.

How to repeat:
Detected in the build of 6.0.4-alpha.

Suggested fix:
Original code in that script:

#
# If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
#

if [ x"@GXX@" = x"yes" ] ; then
  gcclib=`@CC@ @CFLAGS@ --print-libgcc-file`
  if [ $? -ne 0 ] ; then
    echo "Warning: Couldn't find libgcc.a!"
  else
    $CP $gcclib $BASE/lib/libmygcc.a
  fi
fi

Proposed new code:

#
# If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
#

if [ x"@GXX@" = x"yes" ] ; then
  gcclib=`@CC@ @CFLAGS@ --print-libgcc-file 2>/dev/null` || true
  if [ -z "$gcclib" ] ; then
    echo "Warning: Compiler doesn't tell libgcc.a!"
  elif [ -f "$gcclib" ] ; then
    $CP $gcclib $BASE/lib/libmygcc.a
  else
    echo "Warning: Compiler result '$gcclib' not found / no file!"
  fi
fi
[27 Dec 2007 14:42] Joerg Bruehe
P2, because it will affect all upcoming ICC builds in 5.1 and up,
and in lower releases it relies on the tool ignoring failing calls.
[27 Dec 2007 18:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40431

ChangeSet@1.2703, 2007-12-27 19:51:06+01:00, joerg@trift2. +1 -0
  scripts/make_binary_distribution.sh:
  
  Fix the code to get the "libgcc" file name so that the failure of Intel's ICC
  to provide this information does not cause any problems.
  
  This fixes  bug#33536  Option "--print-libgcc-file" does not work with ICC compiler
[27 Dec 2007 19:19] Joerg Bruehe
<joerg> bteam:  If you want to review something ...    
        http://lists.mysql.com/commits/40431
<kent>  joerg: Approved

(IRC #engineering, 2007-12-27, 20:10 CET)
[28 Dec 2007 15:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/40451

ChangeSet@1.2650, 2007-12-28 16:10:17+01:00, joerg@trift2. +1 -0
  scripts/make_binary_distribution.sh
      After-merge fix for bug#33536: The target to copy to is now called "$DEST".
[25 Feb 2008 15:58] Bugs System
Pushed into 5.1.24-rc
[25 Feb 2008 16:04] Bugs System
Pushed into 6.0.5-alpha
[25 Feb 2008 16:05] Bugs System
Pushed into 5.0.58
[25 Feb 2008 16:07] Bugs System
Pushed into 4.1.24
[26 Feb 2008 12:56] Joerg Bruehe
I don't see any need to document this fix for users.

The script failure caused the packaging of ICC binaries to abort,
and this is now corrected.

But as ICC does not tell a gcc library name, no such lib will be included in ICC packages, even with this fix.
[14 Mar 2008 1:58] Paul DuBois
Noted in 4.1.24, 5.0.58, 5.1.24, 6.0.5 changelogs.

make_binary_distribution passed the --print-libgcc-file option to the
C compiler, but this does not work with the ICC compiler.
[2 Apr 2008 16:13] Jon Stephens
Fix also noted in the 5.1.23-ndb-6.3.11 changelog.