Bug #39451 Debug builds broken with Sun Studio compiler
Submitted: 15 Sep 2008 11:27 Modified: 24 Oct 2008 3:51
Reporter: Daniel Fischer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.1-current, 6.0.8-alpha OS:Solaris
Assigned to: Kristofer Pettersson CPU Architecture:Any
Tags: pushbuild

[15 Sep 2008 11:27] Daniel Fischer
Description:
Debug builds of MySQL 5.1 with Sun Studio 12 are broken as of the latest push to mysql-5.1:

"sql_class.cc", line 3507: Error: __FUNCTION__ is not defined.

How to repeat:
Build a debug binary of mysql-5.1 on Solaris with Sun Studio 12.

Suggested fix:
__FUNCTION__ is compiler-specific and there isn't really one way that works everywhere.

For Sun Studio 12, we could use __func__, but this requires a compiler option that would have to be enabled in configure. Something along the lines of:

case $CXX_VERSION in
  *Sun*)
    CXXFLAGS="$CXXFLAGS -features=extensions"
  ;;
esac
[8 Oct 2008 14:45] Kristofer Pettersson
Open question/progress note: Where can I get SunStudio 12? Is it even released yet? If it isn't released, are we sure the above error is a problem with MySQL?
[9 Oct 2008 18:37] Daniel Fischer
The binary was built as follows on Solaris 10 with Sun Studio 12. Note that this bug only affects *debug* binaries as mentioned above.

+ CFLAGS='-g -Xa -xstrconst -mt -D_FORTEC_ -m64'
+ CXXFLAGS='-g -noex -mt -D_FORTEC_ -m64'
+ ASFLAGS='-g -m64'
+ LDFLAGS='-g -m64'
+ export CFLAGS
+ export CXXFLAGS
+ export ASFLAGS
+ export LDFLAGS
+ ./configure --enable-thread-safe-client --enable-local-infile --with-pic --with-client-ldflags=-static --with-mysqld-ldflags=-static --with-zlib-dir=bundled --without-ndb-debug --with-big-tables --with-ssl --with-readline --with-embedded-server --with-archive-storage-engine --with-blackhole-storage-engine --with-csv-storage-engine --with-example-storage-engine --with-federated-storage-engine --with-partition --with-extra-charsets=all --with-innodb --with-ndbcluster --with-debug

Sun Studio 12 has been announced more than a year ago. You can obtain it from here:
http://developers.sun.com/sunstudio/

And yes, I'm *fairly* sure this is a problem with MySQL because we're using an implementation-defined macro with the expectation that all implementations define it (or even define it in the same way), which is not true.
[10 Oct 2008 11:01] 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/56013

2758 Kristofer Pettersson	2008-10-10
      Bug#39451 Debug builds broken with Sun Studio compiler
            
      Debug builds of MySQL 5.1, 6.0 with Sun Studio 12 broke because of
      use of gcc specific feature.
            
      The fix is to replace __FUNCTION__ with the corresponding character
      string
[10 Oct 2008 11:48] Daniel Fischer
This is a very straight-forward fix that can hardly break anything, approved as far as I'm concerned.

There is some magic in my_global.h that could be used to fix this more generally, but a more general fix is not required at this time to make this bug go away.
[10 Oct 2008 14:56] Jon Stephens
Per IRC discussion with Trudy:

Documented bugfix in the 5.1.29 changelog as follows:

        The Sun Studio compiler failed to build debug versions of the server due
        to use of features specific to gcc.

Set status = NDI pending merge to 6.0 tree.
[20 Oct 2008 10:26] Olav Sandstå
This bug has now also been merged into the 6.0 branch. This prevents compiling MySQL on the pushbuild2 "sol10 sparc64 debug-max" platform.

The fix for it needs to be merged to mysql-6.0.
[21 Oct 2008 12:11] 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/56673

2772 Kristofer Pettersson	2008-10-21
      Bug#39451 Debug builds broken with Sun Studio compiler
                  
      Debug builds of MySQL 5.1, 6.0 with Sun Studio 12 broke because of
      use of gcc specific feature.
                  
      The fix is to replace __FUNCTION__ with the corresponding character string
[21 Oct 2008 12:31] 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/56676

2737 Kristofer Pettersson	2008-10-21
      Bug#39451 Debug builds broken with Sun Studio compiler
                  
      Debug builds of MySQL 5.1, 6.0 with Sun Studio 12 broke because of
      use of gcc specific feature.
                 
      The fix is to replace __FUNCTION__ with the corresponding character
      string.
[24 Oct 2008 1:16] Bugs System
Pushed into 5.1.30  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (pib:5)
[24 Oct 2008 1:19] Bugs System
Pushed into 5.1.30  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (pib:5)
[24 Oct 2008 1:19] Bugs System
Pushed into 6.0.8-alpha  (revid:kristofer.pettersson@sun.com-20081021123813-4zmgcj05ueqmbm2q) (version source revid:kristofer.pettersson@sun.com-20081021123813-4zmgcj05ueqmbm2q) (pib:5)
[24 Oct 2008 3:51] Paul DuBois
Noted in 6.0.8 changelog.
[31 Oct 2008 17:18] Bugs System
Pushed into 6.0.8-alpha  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:joerg@mysql.com-20081023123924-xkyodchc58koh6tv) (pib:5)
[10 Nov 2008 10:54] Bugs System
Pushed into 6.0.8-alpha  (revid:kristofer.pettersson@sun.com-20081010110027-am42280ltaea4yj3) (version source revid:kgeorge@mysql.com-20081021085131-2v86qbmg27inufx2) (pib:5)
[10 Nov 2008 11:37] Bugs System
Pushed into 5.1.30  (revid:kristofer.pettersson@sun.com-20081010110027-am42280ltaea4yj3) (version source revid:kgeorge@mysql.com-20081021080008-9xhs5h7niqdhfz4h) (pib:5)
[21 Nov 2008 21:02] Bugs System
Pushed into 5.1.30-ndb-6.2.17  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:tomas.ulin@sun.com-20081121161314-jhz3twf5xjt8stnh) (pib:5)
[21 Nov 2008 23:45] Bugs System
Pushed into 5.1.30-ndb-6.3.20  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:tomas.ulin@sun.com-20081121210644-zas6e9wa5kuj7d6f) (pib:5)
[27 Nov 2008 14:52] Bugs System
Pushed into 5.1.30-ndb-6.4.0  (revid:kristofer.pettersson@sun.com-20081021121838-nokiyenr5aywtkir) (version source revid:tomas.ulin@sun.com-20081126125835-5sohkzk2jjwpq1wp) (pib:5)
[19 Jan 2009 11:30] Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:08] Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:13] Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)