Bug #52514 mysql 5.1 do_abi_check does not compile w/ gcc4.5 due to GCC preprocessor change
Submitted: 31 Mar 2010 20:00 Modified: 14 Oct 2010 14:40
Reporter: Robin Johnson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any
Tags: gcc-4.5
Triage: Triaged: D2 (Serious)

[31 Mar 2010 20:00] Robin Johnson
Description:
The failure occurs during an ABI-change check designed for internal MySQL
developers.  The failure results from a change in behavior of GCC's
preprocessor.  Previously, when the preprocessor was unable to #include a
header, it would leave the #include intact and issue an error on stderr, but
continue to process the file.  With GCC 4.5, the preprocessor immediately
aborts and does not complete the preprocessing.  Here's a comparison:

cd /var/tmp/portage/dev-db/mysql-5.1.45-r1/work/mysql

/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.3/gcc -E -nostdinc -dI -I./include
-I./include/mysql -I./sql -I./include -I./include/mysql -I./sql include/mysql.h
include/mysql.h:47:23: error: sys/types.h: No such file or directory
<much valid preprocessed output, snipped>

/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0-pre9999/gcc -E -nostdinc -dI -I./include
-I./include/mysql -I./sql -I./include -I./include/mysql -I./sql include/mysql.h
include/mysql.h:47:23: fatal error: sys/types.h: No such file or directory
compilation terminated.
# 1 "include/mysql.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "include/mysql.h"
# 47 "include/mysql.h"
#include <sys/types.h>

...
make[2]: *** [do_abi_check] Error 1
make[2]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.1.45-r1/work/mysql'
make[1]: *** [abi_check] Error 2
make[1]: Leaving directory `/var/tmp/portage/dev-db/mysql-5.1.45-r1/work/mysql'
make: *** [all-recursive] Error 1
...

Full build output will be attached.

How to repeat:
Try to compile with GCC 4.5.

Suggested fix:
Pick one:

A)
Don't call do_abi_check during normal build.
(patch will be attached).

B)
Drop the system includes maybe.
[31 Mar 2010 20:03] Robin Johnson
mysql-5.1-gcc45-apicheck-failure.log

Attachment: mysql-5.1-gcc45-apicheck-failure.log (text/plain), 69.03 KiB.

[31 Mar 2010 20:04] Robin Johnson
mysql-5.1-gcc45-apicheck.patch

Attachment: mysql-5.1-gcc45-apicheck.patch (text/x-patch), 1.12 KiB.

[1 Apr 2010 19:41] Sveta Smirnova
Thank you for the report.

Verified as described.
[8 Jun 2010 13:48] Sammie Taunton
Tested with 5.1.47 and the bug exists there too. Same errors apply as recently reported. I attempted to resolve with the patch but still no luck.

gcc version 4.5.0 20100520 (archlinux)

The only options used to configure were:
./configure
make
[8 Jun 2010 13:57] Sammie Taunton
mysql-5.1.47-gcc-4.5.0-do_abi_check-failure.log

Attachment: mysql-5.1.47-gcc-4.5.0-do_abi_check-failure.log (application/octet-stream, text), 26.32 KiB.

[9 Jun 2010 19:41] Todd Rinaldo
The patch provided works fine with gcc 4.5.0 and mysql 5.1.47. I think Sammie Taunton just didn't run automake afterwards. Until this is fixed in source control, Makefile.in is easier to patch while working around this. I'll attach the diff
[9 Jun 2010 19:42] Todd Rinaldo
Makefile.in patch for workaround

Attachment: do_abi_check_off.patch (application/octet-stream, text), 1.16 KiB.

[10 Jun 2010 22:46] Sammie Taunton
Previously I had ran the first patch and automake but returned with the same errors. Now I use both patches without automake and that resolved the issue for me.

I noticed the first patch only patches the Makefile.am but the additional patch does the Makefile.in

Regardless, thanks for posting the patches and getting me back on-track =)
[24 Jun 2010 13:32] Antony Dovgal
Reproducible with MySQL 5.1.* and 5.5.* when compiling it with GCC 4.5.0.
The hack indeed helps.
[24 Jun 2010 13:34] Antony Dovgal
Of course, you need to patch Makefile.am, not Makefile.in, since the latter is generated by automake.
[6 Jul 2010 12:42] Davi Arnaut
I've stumbled upon this, reported a gcc bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44836

Removing contribution tag, patches are not acceptable. In the worst case, should only skip the check for GCC >= 4.5.
[6 Jul 2010 18:36] 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/112967

3466 Davi Arnaut	2010-07-06
      Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5
                 due to GCC preprocessor change
      
      Temporary workaround: disable abi_check if GCC >= 4.5
[6 Jul 2010 21:24] Davi Arnaut
Queued to 5.1-bugteam and up.
[12 Jul 2010 18:35] 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/113390

3478 Davi Arnaut	2010-07-12
      Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5
                 due to GCC preprocessor change
            
      The problem is that newer GCC versions treats missing headers
      as fatal errors. The solution is to use a guard macro to prevent
      the inclusion of system headers when checking the ABI with the
      C Preprocessor.
     @ Makefile.am
        Define guard macro.
     @ configure.in
        Remove workaround.
     @ include/mysql.h
        Guard the header inclusion.
     @ include/mysql.h.pp
        Header is not included anymore.
[13 Jul 2010 22:29] Loic Minier
Hi,

This is also tracked as https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.1/+bug/579909

it's kind of the same issue when building with e.g. the CodeSourcery 2010q1 compiler, since it backports some 4.5 changes.  Short of fixing the abi_check, it would be best to detect the compiler behavior in configure and run the abi_check depending on whether gcc -E breaks on missing #includes.

I tried to come up with a patch for the abi_check, it's not very elegant, but it fixes the check for me here.  I suspect it would need small tweaks for the AIX and Windows builds using gcc 4.5.

I'm attaching the full debdiff I uploaded to Ubuntu to pass the full context, but please skip debian/changelog and Makefile.in when committing to source repo.

Thanks,
[13 Jul 2010 22:30] Loic Minier
fix abi_check with modern gcc versions

Attachment: mysql-abi-check.diff (text/x-diff), 5.22 KiB.

[14 Jul 2010 0:01] Davi Arnaut
Loic,

Your patch looks very similar to mine.. soon I'll push it to 5.1.
[14 Jul 2010 16:12] Loic Minier
Hmm ok, I didn't see a similar patch in the files attached to this bug report, only patches to skip the check entirely.  I guess you committed something nicer to the mainline
[20 Jul 2010 17:44] 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/113968

3493 Davi Arnaut	2010-07-20
      Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5
                 due to GCC preprocessor change
            
      The problem is that newer GCC versions treats missing headers
      as fatal errors. The solution is to use a guard macro to prevent
      the inclusion of system headers when checking the ABI with the
      C Preprocessor.
      
      Reference: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15638
                 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44836
     @ Makefile.am
        Define guard macro.
     @ configure.in
        Remove workaround.
     @ include/mysql.h
        Guard the header inclusion.
     @ include/mysql.h.pp
        Header is not included anymore.
[20 Jul 2010 17:51] Davi Arnaut
Queued to mysql-5.1-bugteam
[20 Jul 2010 19:34] 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/113982

3137 Davi Arnaut	2010-07-20
      Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5
                 due to GCC preprocessor change
      
      Addendum for trunk: do not include system header when checking
      the ABI.
[20 Jul 2010 19:53] 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/113987

3138 Davi Arnaut	2010-07-20
      Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5
                 due to GCC preprocessor change
            
      Addendum for trunk: add -DMYSQL_ABI_CHECK to the cmake ABI check.
[23 Jul 2010 11:00] MC Brown
A note has been added to the 5.1.50 and 5.5.6 changelog: 

    The ABI check for MySQL would fail to compile with gcc 4.5.
[23 Jul 2010 12:27] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100723121820-jryu2fuw3pc53q9w) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:18)
[23 Jul 2010 12:34] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100723121929-90e9zemk3jkr2ocy) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (pib:18)
[23 Jul 2010 13:38] MC Brown
Already noted in changelog
[4 Aug 2010 7:49] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:alik@sun.com-20100731074942-o840woifuqioxxe4) (merge vers: 5.5.6-m3) (pib:18)
[4 Aug 2010 8:09] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100731075120-qz9z8c25zum2wgmm) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:25] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100731075120-qz9z8c25zum2wgmm) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 9:04] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:alik@sun.com-20100731075120-qz9z8c25zum2wgmm) (pib:20)
[4 Aug 2010 16:48] Paul Dubois
Not present in any released 5.6.x version.
[19 Aug 2010 7:18] Jon Stephens
This issue currently affects Cluster as well (merged only up to MySQL Server version 5.147).
[19 Aug 2010 8:17] Jon Stephens
NOTE: If you run into this problem with gcc 4.5 and Cluster based on 5.1.47 or earlier, just comment out the line

all-local:		@ABI_CHECK@

in the top-level Makefile.am before running make. WFM.
[19 Aug 2010 15:40] Bugs System
Pushed into mysql-5.1 5.1.51 (revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (version source revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (merge vers: 5.1.51) (pib:20)
[14 Oct 2010 8:33] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:48] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 9:02] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[14 Oct 2010 14:40] Jon Stephens
Already documented in the 5.1.50 changelog; no new changelog entries required. setting back to Closed state.