This repository has been archived by the owner. It is now read-only.

mysql_config emits unknown compiler option #20788

Closed
zimbatm opened this Issue Jun 25, 2013 · 33 comments

Comments

7 participants
@zimbatm
Contributor

zimbatm commented Jun 25, 2013

gem install mysql2 would fail, claiming that it couldn't find "mysql.h" but I had 5.6.12 install with homebrew

After tracking it down, it turns out that mysql_config --cflags was returning a "-Wno-null-conversion" flag which i686-apple-darwin11-llvm-gcc-4.2 doesn't understand.
This is a problem with how ruby builds the extensions but the small header detection program wouldn't compile for that reason giving the misleading message that mysql.h doesn't exist.

mysql v5.6.12 was installed using the homebrew bottle so I made a build on the machine but no success.

my current workaround is to replace /usr/local/bin/mysql_config with the following little script:

#!/bin/sh
/usr/local/opt/mysql/bin/mysql_config "$@" | sed 's/-Wno-null-conversion //g'
@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jun 26, 2013

Contributor

This seems like a bug that mysql should fix; non-portable compiler flags shouldn't be recorded

Contributor

jacknagel commented Jun 26, 2013

This seems like a bug that mysql should fix; non-portable compiler flags shouldn't be recorded

@mcfilib

This comment has been minimized.

Show comment
Hide comment
@mcfilib

mcfilib Jun 27, 2013

Contributor

Has anyone reported this upstream?

Contributor

mcfilib commented Jun 27, 2013

Has anyone reported this upstream?

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jun 27, 2013

Contributor

Is it possible that mysql is compiled with a different compiler and so is emitting incompatible options ?

For reference, here is the mysql bug tracker, horrible search: http://bugs.mysql.com/

I also found these people having the same issues on the web:

Apparently the mysql_config is a shell script so you can also remove the flags directly in the file.

Contributor

zimbatm commented Jun 27, 2013

Is it possible that mysql is compiled with a different compiler and so is emitting incompatible options ?

For reference, here is the mysql bug tracker, horrible search: http://bugs.mysql.com/

I also found these people having the same issues on the web:

Apparently the mysql_config is a shell script so you can also remove the flags directly in the file.

@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jun 27, 2013

Contributor

We used to do this to filter out exotic optimization flags, but we stopped doing this and started compiling with ENV.minimal_optimization instead.

I am somewhat concerned that it is spitting out warning flags at all, though; I can understand the rationale for using the same options and optimization settings, but warning flags? What's the point?

Contributor

jacknagel commented Jun 27, 2013

We used to do this to filter out exotic optimization flags, but we stopped doing this and started compiling with ENV.minimal_optimization instead.

I am somewhat concerned that it is spitting out warning flags at all, though; I can understand the rationale for using the same options and optimization settings, but warning flags? What's the point?

@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jul 1, 2013

Contributor

Can someone gist the contents of mysql_config immediately after the build?

Contributor

jacknagel commented Jul 1, 2013

Can someone gist the contents of mysql_config immediately after the build?

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 2, 2013

Contributor

This is what got installed when I made a local build: https://gist.github.com/anonymous/a14ae0e2f6e8140a9b14

Contributor

zimbatm commented Jul 2, 2013

This is what got installed when I made a local build: https://gist.github.com/anonymous/a14ae0e2f6e8140a9b14

@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jul 2, 2013

Contributor

This is a bug in mysql_config. There is code to remove all -Wfoo options, but it is not robust enough and fails:

cflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
include="-I$pkgincludedir"

# Remove some options that a client doesn't have to care about
for remove in DDBUG_OFF DSAFE_MUTEX DFORCE_INIT_OF_VARS \
              DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
              'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
              unroll2 ip mp restrict
do
  # The first option we might strip will always have a space before it because
  # we set -I$pkgincludedir as the first option
  cflags=`echo "$cflags"|sed -e "s/ -$remove  */ /g"`
  cxxflags=`echo "$cxxflags"|sed -e "s/ -$remove  */ /g"`
done

When I run it, I see:

$ ./mysql_config --cflags
-I/usr/local/Cellar/mysql/5.6.12/include  -Wno-null-conversion -Os -g -fno-strict-aliasing
Contributor

jacknagel commented Jul 2, 2013

This is a bug in mysql_config. There is code to remove all -Wfoo options, but it is not robust enough and fails:

cflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
include="-I$pkgincludedir"

# Remove some options that a client doesn't have to care about
for remove in DDBUG_OFF DSAFE_MUTEX DFORCE_INIT_OF_VARS \
              DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
              'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
              unroll2 ip mp restrict
do
  # The first option we might strip will always have a space before it because
  # we set -I$pkgincludedir as the first option
  cflags=`echo "$cflags"|sed -e "s/ -$remove  */ /g"`
  cxxflags=`echo "$cxxflags"|sed -e "s/ -$remove  */ /g"`
done

When I run it, I see:

$ ./mysql_config --cflags
-I/usr/local/Cellar/mysql/5.6.12/include  -Wno-null-conversion -Os -g -fno-strict-aliasing
@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 2, 2013

Contributor

See #20957
Solution is to elide the two compiler flags from cflags AND cxxflags

-Wno-null-conversion -Wno-unused-private-field

from mysql_config in the Cellar then retry.
Notice that this bug does not appear when compiling the native extension agains ruby-2.0.0 (because in that case llvm compiler is used)

Contributor

ruurd commented Jul 2, 2013

See #20957
Solution is to elide the two compiler flags from cflags AND cxxflags

-Wno-null-conversion -Wno-unused-private-field

from mysql_config in the Cellar then retry.
Notice that this bug does not appear when compiling the native extension agains ruby-2.0.0 (because in that case llvm compiler is used)

@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Jul 2, 2013

Member

Why on earth aren't they using Clang? LLVM is going away in 10.9 and Xcode 5. Muppets.

Member

MikeMcQuaid commented Jul 2, 2013

Why on earth aren't they using Clang? LLVM is going away in 10.9 and Xcode 5. Muppets.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 2, 2013

Contributor

On 2 jul. 2013, at 12:13, Mike McQuaid notifications@github.com wrote:

Why on earth aren't they using Clang? LLVM is going away in 10.9 and Xcode 5. Muppets.

Oh. Got me wires crossed. They are using clang. Duh.

Regards,
Ruurd

Ruurd Pels, Boogerd 1, 1791 GW Den Burg - Texel, The Netherlands
rfpels@gmail.com http://about.me/ruurdpels +31612914545

Contributor

ruurd commented Jul 2, 2013

On 2 jul. 2013, at 12:13, Mike McQuaid notifications@github.com wrote:

Why on earth aren't they using Clang? LLVM is going away in 10.9 and Xcode 5. Muppets.

Oh. Got me wires crossed. They are using clang. Duh.

Regards,
Ruurd

Ruurd Pels, Boogerd 1, 1791 GW Den Burg - Texel, The Netherlands
rfpels@gmail.com http://about.me/ruurdpels +31612914545

@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Jul 2, 2013

Member

Phew, thanks @ruurd.

Member

MikeMcQuaid commented Jul 2, 2013

Phew, thanks @ruurd.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 2, 2013

Contributor

I don't know if it's related but when I build mysql with -vd I see a lot of these:

[ 84%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_data_change.cc.o
brew: superenv removed: -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g
Contributor

zimbatm commented Jul 2, 2013

I don't know if it's related but when I build mysql with -vd I see a lot of these:

[ 84%] Building CXX object libmysqld/CMakeFiles/sql_embedded.dir/__/sql/sql_data_change.cc.o
brew: superenv removed: -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g
@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 2, 2013

Contributor

If you want, putting a inreplace "scripts/mysql_config", / -W[\w-]+ /, ' ' line between the make and make-install fixes the symptoms.

Contributor

zimbatm commented Jul 2, 2013

If you want, putting a inreplace "scripts/mysql_config", / -W[\w-]+ /, ' ' line between the make and make-install fixes the symptoms.

@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jul 2, 2013

Contributor

We can carry a fix for this, but it would be really great if someone reported it to the mysql folks.

Contributor

jacknagel commented Jul 2, 2013

We can carry a fix for this, but it would be really great if someone reported it to the mysql folks.

@ruurd

This comment has been minimized.

Show comment
Hide comment
Contributor

ruurd commented Jul 2, 2013

@jacknagel

This comment has been minimized.

Show comment
Hide comment
@jacknagel

jacknagel Jul 2, 2013

Contributor

Awesome, thanks.

Contributor

jacknagel commented Jul 2, 2013

Awesome, thanks.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 2, 2013

Contributor

I'm a good boy... sometimes :-)

Contributor

ruurd commented Jul 2, 2013

I'm a good boy... sometimes :-)

vito added a commit to vito/homebrew that referenced this issue Jul 4, 2013

workaround for mysql 5.6.12's mysql_config
mysql_config from mysql 5.6.12 includes various -W flags that are not supposed by OS X's gcc. this just trims them out. hopefully it gets fixed upstream though.

thanks to @zimbatm - see #20788

@adamv adamv closed this in 5c0ea90 Jul 18, 2013

@pftg

This comment has been minimized.

Show comment
Hide comment
@pftg

pftg Jul 19, 2013

This issue still present. Even after cleanup cache.

pftg commented Jul 19, 2013

This issue still present. Even after cleanup cache.

@mcfilib

This comment has been minimized.

Show comment
Hide comment
@mcfilib

mcfilib Jul 19, 2013

Contributor

Possibly because the regex referenced behaves like this.

irb(main):020:0> string = "-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
=> "-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):021:0> string.gsub(/ -W[\w-]+ /, " ")
=> "-I$pkgincludedir  -Wno-null-conversion -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):022:0>
Contributor

mcfilib commented Jul 19, 2013

Possibly because the regex referenced behaves like this.

irb(main):020:0> string = "-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
=> "-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):021:0> string.gsub(/ -W[\w-]+ /, " ")
=> "-I$pkgincludedir  -Wno-null-conversion -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):022:0>
@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 19, 2013

Contributor

My fault !

Try using the following regexp instead:

string.gsub(/ +-W[\w-]+/, '')

On 19 July 2013 08:06, Philip Cunningham notifications@github.com wrote:

Possibly because the regex referenced behaves like this.

irb(main):020:0> string = "-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
=> "-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):021:0> string.gsub(/ -W[\w-]+ /, " ")
=> "-I$pkgincludedir -Wno-null-conversion -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):022:0>


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21234677
.

Contributor

zimbatm commented Jul 19, 2013

My fault !

Try using the following regexp instead:

string.gsub(/ +-W[\w-]+/, '')

On 19 July 2013 08:06, Philip Cunningham notifications@github.com wrote:

Possibly because the regex referenced behaves like this.

irb(main):020:0> string = "-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
=> "-I$pkgincludedir -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):021:0> string.gsub(/ -W[\w-]+ /, " ")
=> "-I$pkgincludedir -Wno-null-conversion -Os -g -fno-strict-aliasing -DDBUG_OFF "
irb(main):022:0>


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21234677
.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 19, 2013

Contributor

Hmmmm. You know - I'll keep my big mouth shut. BTDTGTT :-)

Contributor

ruurd commented Jul 19, 2013

Hmmmm. You know - I'll keep my big mouth shut. BTDTGTT :-)

@mcfilib

This comment has been minimized.

Show comment
Hide comment
@mcfilib

mcfilib Jul 19, 2013

Contributor

@zimbatm Happens to the best of us but I don't think that's quite right either because it will also strip the -Wall flag which is used to emit warnings.

How about:

string.gsub(/ +-Wno[\w-]+/, "")
Contributor

mcfilib commented Jul 19, 2013

@zimbatm Happens to the best of us but I don't think that's quite right either because it will also strip the -Wall flag which is used to emit warnings.

How about:

string.gsub(/ +-Wno[\w-]+/, "")
@mistydemeo

This comment has been minimized.

Show comment
Hide comment
@mistydemeo

mistydemeo Jul 22, 2013

Contributor

@MikeMcQuaid Can we get new bottles for mysql?

Contributor

mistydemeo commented Jul 22, 2013

@MikeMcQuaid Can we get new bottles for mysql?

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 23, 2013

Contributor

OK looks good to me. Although a bit of a meta question but why should
liking to a library change the warning flags at all ? It seems like it's
something you want to set in your own cflags and not get imported because
you're using mysql. That said I'm no C expert.
On Jul 19, 2013 12:08 PM, "Philip Cunningham" notifications@github.com
wrote:

@zimbatm https://github.com/zimbatm Happens to the best of us but I
don't think that's quite right either because it will also strip the -Wallflag.

How about:

string.gsub(/ +-Wno[\w-]+/, "")

unsymbol@f4b83bfhttps://github.com/unsymbol/homebrew/commit/f4b83bfd3707ff319e1c76c7965af2c9b874b274


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21244013
.

Contributor

zimbatm commented Jul 23, 2013

OK looks good to me. Although a bit of a meta question but why should
liking to a library change the warning flags at all ? It seems like it's
something you want to set in your own cflags and not get imported because
you're using mysql. That said I'm no C expert.
On Jul 19, 2013 12:08 PM, "Philip Cunningham" notifications@github.com
wrote:

@zimbatm https://github.com/zimbatm Happens to the best of us but I
don't think that's quite right either because it will also strip the -Wallflag.

How about:

string.gsub(/ +-Wno[\w-]+/, "")

unsymbol@f4b83bfhttps://github.com/unsymbol/homebrew/commit/f4b83bfd3707ff319e1c76c7965af2c9b874b274


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21244013
.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 23, 2013

Contributor

Well in this case it is of no consequence because it only deals with warning flags but other flags might have influence on code generation. That is why the flags are specified in pkgconfig.

Contributor

ruurd commented Jul 23, 2013

Well in this case it is of no consequence because it only deals with warning flags but other flags might have influence on code generation. That is why the flags are specified in pkgconfig.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 23, 2013

Contributor

So the -Wall can also be ignored right ? I don't think it hurts to have it
but just to know on the theoretical level.
On Jul 23, 2013 9:03 AM, "Ruurd Pels" notifications@github.com wrote:

Well in this case it is of no consequence because it only deals with
warning flags but other flags might have influence on code generation. That
is why the flags are specified in pkgconfig.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21398815
.

Contributor

zimbatm commented Jul 23, 2013

So the -Wall can also be ignored right ? I don't think it hurts to have it
but just to know on the theoretical level.
On Jul 23, 2013 9:03 AM, "Ruurd Pels" notifications@github.com wrote:

Well in this case it is of no consequence because it only deals with
warning flags but other flags might have influence on code generation. That
is why the flags are specified in pkgconfig.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21398815
.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 23, 2013

Contributor

Preferably no. Since that turns of a lot of warnings. And if you use similar compiler flags in your own piece of code that might lead to unwanted surprises.

Contributor

ruurd commented Jul 23, 2013

Preferably no. Since that turns of a lot of warnings. And if you use similar compiler flags in your own piece of code that might lead to unwanted surprises.

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 23, 2013

Contributor

Oh BTW, run 'man gcc' if you really want to know.

Contributor

ruurd commented Jul 23, 2013

Oh BTW, run 'man gcc' if you really want to know.

@zimbatm

This comment has been minimized.

Show comment
Hide comment
@zimbatm

zimbatm Jul 23, 2013

Contributor

OK thanks, sorry for the noise :)
On Jul 23, 2013 9:13 AM, "Ruurd Pels" notifications@github.com wrote:

Oh BTW, run 'man gcc' if you really want to know.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21399230
.

Contributor

zimbatm commented Jul 23, 2013

OK thanks, sorry for the noise :)
On Jul 23, 2013 9:13 AM, "Ruurd Pels" notifications@github.com wrote:

Oh BTW, run 'man gcc' if you really want to know.


Reply to this email directly or view it on GitHubhttps://github.com/mxcl/homebrew/issues/20788#issuecomment-21399230
.

@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Jul 23, 2013

Member

@mistydemeo Ok but might take a wee bit. I wanted to see if this was definitely the right approach first?

Member

MikeMcQuaid commented Jul 23, 2013

@mistydemeo Ok but might take a wee bit. I wanted to see if this was definitely the right approach first?

@mistydemeo

This comment has been minimized.

Show comment
Hide comment
@mistydemeo

mistydemeo Jul 23, 2013

Contributor

@MikeMcQuaid The "right" approach is to get Oracle to fix it, but we'll see how that goes. Meanwhile mysql users will be unable to build things like bindings in other languages without a fix like this. :/

Contributor

mistydemeo commented Jul 23, 2013

@MikeMcQuaid The "right" approach is to get Oracle to fix it, but we'll see how that goes. Meanwhile mysql users will be unable to build things like bindings in other languages without a fix like this. :/

@ruurd

This comment has been minimized.

Show comment
Hide comment
@ruurd

ruurd Jul 24, 2013

Contributor

That is why I also posted it upstream. BTW if you install the gem in ruby-2.0.0 on OSX which uses clang there is no problem. Misty you're right however the problem is connected to the old gcc that is used on OSX for ruby < 2

Contributor

ruurd commented Jul 24, 2013

That is why I also posted it upstream. BTW if you install the gem in ruby-2.0.0 on OSX which uses clang there is no problem. Misty you're right however the problem is connected to the old gcc that is used on OSX for ruby < 2

@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid
Member

MikeMcQuaid commented Jul 27, 2013

@mistydemeo Done.

handyman5 pushed a commit to handyman5/homebrew that referenced this issue Oct 7, 2013

mysql: workaround for 5.6.12's mysql_config
mysql_config from mysql 5.6.12 includes various -W flags that are not supposed
by OS X's gcc. this just trims them out. hopefully it gets fixed upstream
though.

Closes #20788.
Closes #21011.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

simeonwillbanks pushed a commit to simeonwillbanks/homebrew that referenced this issue Oct 30, 2013

mysql: strip invalid flags from mysql_config.
note: regex in previous commit did not strip all invalid flags and stripped out
      an additional flag "-Wall." this commit resolves this.

previous commit : vito@9dd1c38
discussion      : Homebrew#20788 (comment)

Closes #21324.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

@Homebrew Homebrew locked and limited conversation to collaborators Feb 17, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.