rake-compiler / rake-compiler-dock

Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.
MIT License
77 stars 30 forks source link

How to use gnu11 #24

Closed TeBoring closed 5 years ago

TeBoring commented 5 years ago

Our code currently depend on strptime which is only provided by posix. How to use -std=gnu11 in Rakefile? Thanks!

TeBoring commented 5 years ago

https://stackoverflow.com/questions/43460876/trouble-including-function-declaration-for-strptime?rq=1 Some context

larskanis commented 5 years ago

Usually you do this in extconf.rb like here and make it conditionally depending on on one the RCD environment variables.

But it should also work to properly set the CFLAGS environment variable from the Rakefile.

TeBoring commented 5 years ago

I tried to set CFLAGS in extconf.rb, but didn't work. How to set it it Rakefile?

larskanis commented 5 years ago

CFLAGS can be set in the Rakefile like so:

RakeCompilerDock.sh "bundle --local && rake cross native gem CFLAGS=-std=gnu11" 

But if it doesn't work in extconf.rb per $CFLAGS, there's probably something other wrong.

TeBoring commented 5 years ago

https://github.com/protocolbuffers/protobuf/pull/5660

TeBoring commented 5 years ago

Still doesn't work

TeBoring commented 5 years ago

Are you able to build an extension which uses strptime?

TeBoring commented 5 years ago

I am confused why our test doesn't have such a problem. However, the job to use docker to build ruby gem has such a problem.

TeBoring commented 5 years ago

Is that related to cross compiling?

TeBoring commented 5 years ago

Seems only fail with x86-mingw32.

TeBoring commented 5 years ago

ok, seems mingw doesn't have strptime.

larskanis commented 5 years ago

MINGW has some small POSIX additions, but isn't really POSIX compliant. Makes sense!