Bug #35929 MySQL 6.0.4 fails to compile with Sun Studio compiler due to using gcc options
Submitted: 9 Apr 2008 11:53 Modified: 9 Oct 2008 13:48
Reporter: Olav Sandstaa
Status: Closed
Category:Server: Falcon Severity:S3 (Non-critical)
Version:6.0.4 OS:Sun Solaris
Assigned to: Bugs System Target Version:
Tags: Sun Studio
Triage: D2 (Serious)

[9 Apr 2008 11:53] Olav Sandstaa
Description:
When trying to compile the source for MySQL 6.0.4 using the Sun Studio 12 C and C++
compilers I get a compile error due to a gcc specific argument (-fexceptions) is passed
to the C++ compiler. The error message I get is:

/opt/studio12/SUNWspro/bin/CC -m32 -mt -DHAVE_RWLOCK_T -o mysql mysql.o readline.o
sql_string.o completion_hash.o -fexceptions  ../cmd-line-utils/libedit/libedit.a
-lncurses -lpthread -lthread ../libmysql/.libs/libmysqlclient.a -lm
/usr/local/lib/libstdc++.so
-L/usr/local/src/gcc/urd23gcc-3.4.2/i386-pc-solaris2.9/libstdc++-v3/src
-L/usr/local/src/gcc/urd23gcc-3.4.2/i386-pc-solaris2.9/libstdc++-v3/src/.libs -lm -lm -lm
-L/usr/local/src/gcc/urd23gcc-3.4.2/gcc -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib
-lgcc_s -lgcc_s -lm -lgcc_s -lgcc_s -lrt -lgen -lsocket -lnsl -lm -lz
CC: Warning: Option -fexceptions passed to ld, if ld is invoked, ignored otherwise
ld: fatal: option -f and building a dynamic executable are incompatible
ld: fatal: Flags processing errors
*** Error code 1
make: Fatal error: Command failed for target `mysql'

How to repeat:
The command I used for configure is:

./configure CC=/opt/studio12/SUNWspro/bin/cc CXX=/opt/studio12/SUNWspro/bin/CC
CFLAGS="-Xa -m32 -mt" CXXFLAGS="-m32 -mt" --prefix=/home/os136802/install/mysql
--with-mysqld-libs --with-named-curses=-lcurses --with-mysql-ldflags=-static
--with-client-ldflags=-static --with-plugins=myisam,innobase

and to make:

make

Suggested fix:
The reason for this gcc option to be added to the C++ option list is due to the following
in the configure script:

  # Falcon uses exceptions and STL.
  CXXLDFLAGS="$CXXLDFLAGS -fexceptions -lstdc++"
  FALCON_CXXFLAGS="$falcon_cxx_no_invalid_offsetof -fexceptions"

It would be great if the configure script was able to set the necessary options to enable
support for exceptions based on which compiler that is used instead of hard coding it for
gcc.

Another comment: the comment in the configure script indicates that this is needed for
Falcon but it seems that this option also is added when linking client commands (in this
case mysql). Is that intentionally?
[9 Apr 2008 13:07] Hakan Kuecuekyilmaz
Putting to Falcon category for better tracking.
[15 Apr 2008 15:14] Hakan Kuecuekyilmaz
I get a similar error from Sun Studio 12 compiler running on Solaris 9/Sparc:

/opt/SUNWspro/bin/CC -m32 -mt -D_FILE_OFFSET_BITS=64 -DHAVE_RWLOCK_T -o mysqld sql_lex.o
sql_handler.o sql_partition.o item.o item_sum.o item_buff.o item_func.o item_cmpfunc.o
item_strfunc.o item_timefunc.o thr_malloc.o item_create.o item_subselect.o item_row.o
item_geofunc.o item_xmlfunc.o field.o strfunc.o key.o sql_class.o sql_list.o net_serv.o
protocol.o sql_state.o lock.o my_lock.o sql_string.o sql_manager.o sql_map.o mysqld.o
password.o hash_filo.o hostname.o sql_connect.o scheduler.o sql_parse.o set_var.o
sql_yacc.o sql_base.o table.o sql_select.o sql_insert.o sql_profile.o sql_prepare.o
sql_error.o sql_locale.o sql_update.o sql_delete.o uniques.o sql_do.o procedure.o
sql_test.o log.o init.o derror.o sql_acl.o unireg.o des_key_file.o log_event.o
rpl_record.o log_event_old.o rpl_record_old.o discover.o time.o opt_range.o opt_sum.o
records.o filesort.o handler.o ha_partition.o sql_db.o sql_table.o sql_rename.o
sql_crypt.o sql_load.o mf_iocache.o field_conv.o sql_show.o sql_udf.o sql_analyse.o
sql_cache.o slave.o sql_repl.o rpl_filter.o rpl_tblmap.o rpl_utility.o rpl_injector.o
rpl_rli.o rpl_mi.o rpl_reporting.o sql_union.o sql_derived.o sql_client.o stacktrace.o
repl_failsafe.o sql_olap.o sql_view.o gstream.o spatial.o sql_help.o sql_cursor.o
tztime.o my_decimal.o sp_head.o sp_pcontext.o sp_rcontext.o sp.o sp_cache.o parse_file.o
sql_trigger.o event_scheduler.o event_data_objects.o event_queue.o event_db_repository.o
events.o sql_plugin.o sql_binlog.o sql_builtin.o sql_tablespace.o partition_info.o
sql_servers.o sql_audit.o sha2.o ddl_blocker.o si_objects.o mini_client_errors.o pack.o
client.o my_time.o my_user.o yes  ./.libs/libndb.a -lpthread -lthread -lpthread -lthread
-lpthread -lthread -lpthread -lthread ../storage/csv/libcsv.a ../storage/heap/libheap.a
../storage/innobase/libinnobase.a ../storage/myisammrg/libmyisammrg.a
../storage/myisam/libmyisam.a ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a
../regex/libregex.a ../strings/libmystrings.a ../zlib/.libs/libzlt.a -ldl
backup/.libs/libbackup.a -lpthread -lthread -lpthread -lthread -lpthread -lthread
-lpthread -lthread -lpthread -lthread -lpthread -lthread -lpthread -lthread -lpthread
-lthread -lpthread -lthread -lrt -lresolv -lgen -lsocket -lnsl -lm -lpthread -lthread
ld: fatal: file yes: open failed: No such file or directory
ld: fatal: File processing errors. No output written to mysqld
[17 Apr 2008 11:59] Hakan Kuecuekyilmaz
Leaving out --with-mysqld-libs solves my linker problem with "yes". Thanks to Danny for
figuring this one out.
[28 Apr 2008 6:55] Hakan Kuecuekyilmaz
Pushed fixes in configure scripts to mysql-6.0-falcon and mysql-6.0-falcon-team tree.

Olav, can you please verify the fix?
[30 Apr 2008 18:30] Olav Sandstaa
I have tested with the latest version in mysql-6.0-falcon-team tree and can confirm that
the gcc options that were added when running Sun Studio compiler are now gone.

Thanks for fixing this, Hakan!
[29 Aug 2008 3:41] Kevin Lewis
This fix is in version 6.0.6
[9 Oct 2008 13:48] Jon Stephens
Documented in the 6.0.6 changelog as follows:

        MySQL could not be built using the Sun Studio compiler due to the use
        of compiler options specific to gcc.