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
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