Skip to content
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
Closed

mysql_config emits unknown compiler option #20788

zimbatm opened this issue Jun 25, 2013 · 33 comments

Comments

@zimbatm
Copy link
Contributor

@zimbatm 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
Copy link
Contributor

@jacknagel jacknagel commented Jun 26, 2013

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

@mcfilib
Copy link
Contributor

@mcfilib mcfilib commented Jun 27, 2013

Has anyone reported this upstream?

@zimbatm
Copy link
Contributor Author

@zimbatm 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
Copy link
Contributor

@jacknagel 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
Copy link
Contributor

@jacknagel jacknagel commented Jul 1, 2013

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

@zimbatm
Copy link
Contributor Author

@zimbatm zimbatm commented Jul 2, 2013

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

@jacknagel
Copy link
Contributor

@jacknagel 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
Copy link
Contributor

@ruurd 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
Copy link
Member

@MikeMcQuaid 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
Copy link
Contributor

@ruurd 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
Copy link
Member

@MikeMcQuaid MikeMcQuaid commented Jul 2, 2013

Phew, thanks @ruurd.

@zimbatm
Copy link
Contributor Author

@zimbatm 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
Copy link
Contributor Author

@zimbatm 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
Copy link
Contributor

@jacknagel 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
Copy link
Contributor

@ruurd ruurd commented Jul 2, 2013

@jacknagel
Copy link
Contributor

@jacknagel jacknagel commented Jul 2, 2013

Awesome, thanks.

@ruurd
Copy link
Contributor

@ruurd 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
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 Homebrew#20788
@adamv adamv closed this in 5c0ea90 Jul 18, 2013
@pftg
Copy link

@pftg pftg commented Jul 19, 2013

This issue still present. Even after cleanup cache.

@mcfilib
Copy link
Contributor

@mcfilib 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
Copy link
Contributor Author

@zimbatm 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//issues/20788#issuecomment-21234677
.

@ruurd
Copy link
Contributor

@ruurd ruurd commented Jul 19, 2013

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

@mcfilib
Copy link
Contributor

@mcfilib 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
Copy link
Member

@mistydemeo mistydemeo commented Jul 22, 2013

@MikeMcQuaid Can we get new bottles for mysql?

@zimbatm
Copy link
Contributor Author

@zimbatm 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//issues/20788#issuecomment-21244013
.

@ruurd
Copy link
Contributor

@ruurd 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
Copy link
Contributor Author

@zimbatm 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//issues/20788#issuecomment-21398815
.

@ruurd
Copy link
Contributor

@ruurd 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
Copy link
Contributor

@ruurd ruurd commented Jul 23, 2013

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

@zimbatm
Copy link
Contributor Author

@zimbatm 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//issues/20788#issuecomment-21399230
.

@MikeMcQuaid
Copy link
Member

@MikeMcQuaid 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
Copy link
Member

@mistydemeo 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
Copy link
Contributor

@ruurd 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
Copy link
Member

@MikeMcQuaid MikeMcQuaid commented Jul 27, 2013

@mistydemeo Done.

handyman5 pushed a commit to handyman5/homebrew that referenced this issue Oct 7, 2013
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 Homebrew#20788.
Closes Homebrew#21011.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
simeonwillbanks pushed a commit to simeonwillbanks/homebrew that referenced this issue Oct 30, 2013
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 Homebrew#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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants