Bug #6964 mysql_config script incorrectly removes -Wl, flags

Submitted: 2 Dec 2004 20:45 Modified: 11 Jan 2005 20:20
Reporter: Michael Pyne Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.22 OS:Linux (GNU/Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[2 Dec 2004 20:45] Michael Pyne
Description:
The mysql_config script incorrectly filters -Wl, flags from the CFLAGS, which can cause client software using mysql_config to be unable to build.  I experienced this trying to build Samba.

In my case, the CFLAGS used to compile MySQL was:
-I/usr/include/mysql -Os -march=athlon-xp -pipe -Wl,-O1 -DHAVE_ERRNO_AS_DEFINE=1 -DUSE_OLD_FUNCTIONS

After running the mysql_config --cflags command, the output was:
-I/usr/include/mysql -Os -march=athlon-xp -pipe -Wl,-DHAVE_ERRNO_AS_DEFINE=1 -DUSE_OLD_FUNCTIONS

Notice that the -Wl, flag has merged with the next one.  This causes ld to bail out with an error.

How to repeat:
Add a -Wl, option to your CFLAGS, where the option being passed to the linker is included in the list of flags to remove.  For example, -Wl,-O1.

Of course, one could argue that you should add the flags to your LDFLAGS instead, but many broken build scripts just dump the LDFLAGS back into the CFLAGS anyways.

Suggested fix:
Applying the following patch to mysql_config fixes the problem for me:
--- mysql_config    2004-12-02 15:43:16.664738000 -0500
+++ mysql_config        2004-12-02 15:42:52.866355904 -0500
@@ -98,7 +98,7 @@
 # Remove some options that a client doesn't have to care about
 for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
               DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
-              DEXTRA_DEBUG DHAVE_purify 'O[0-9s]' 'W[-A-Za-z]*'
+              DEXTRA_DEBUG DHAVE_purify 'Wl,[-0-9A-Za-z_,=]*' 'O[0-9s]' 'W[-A-Za-z]*'
 do
   cflags=`echo "$cflags"|sed -e "s/-$remove  *//g"`
 done
[5 Jan 2005 2:44] Jim Winstead
Took a different approach: don't strip out anything that isn't a complete option. This means that 
-Wl,-O1 and similar constructs will be left intact.

(Note two versions of this patch were committed. Correct one is at http://lists.mysql.com/
internals/20286.)
[11 Jan 2005 20:20] Paul DuBois
Mentioned in 4.1.9 change notes.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.