Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assume gcc. #13

Closed
wants to merge 1 commit into from
Closed

Don't assume gcc. #13

wants to merge 1 commit into from

Conversation

djberg96
Copy link

This lets things work with Visual Studio, the Sun Studio compiler and so on. :)

@yorickpeterse
Copy link
Owner

eh, it didn't expect gcc in the first place, while it now only adds the flags for gcc (and not clang and everything else). Is Visual Studio so braindead that it doesn't support -Wall and such? If so a better way would be to not add the flags for just visual studio, instead of only adding it for gcc. So basically something like

unless RbConfig::CONFIG['cc'] == 'visual-studio-something'

end

@djberg96
Copy link
Author

I'm not sure I follow. With my patch it only adds the flags if gcc.

Visual Studio actually does support -Wall, but really you want -W3. However, the ruby-core team specifically overrides anything above -W2 (since Ruby 2.0 I think), so it wouldn't do any good anyway.

@djberg96
Copy link
Author

The actual problem was the -Wextra switch, which isn't supported by Visual Studio. I doubt other compilers support it, either.

@yorickpeterse
Copy link
Owner

I'm not sure I follow. With my patch it only adds the flags if gcc.

That's exactly the problem, it only adds the flags when gcc is used. While I'm not sure if MRI can be compiled with clang these days you can compile Rubinius with it (it's actually recommended and my current default compiler for it).

The actual problem was the -Wextra switch, which isn't supported by Visual Studio. I doubt other compilers support it, either.

clang and gcc support it just fine. If this is the only option not supported by visual studio it can be skipped in case of VS, but simply not adding any flags is a bit too much if you'd ask me.

@yorickpeterse
Copy link
Owner

Put it this way:

  • Does VS support -Wall and -Wpedantic?
  • What does RbConfig::CONFIG['gcc'] report in case you're compiling with VS?

@djberg96
Copy link
Author

It supports -Wall but not -Wpedantic. By other compilers, I meant the Sun Studio compiler and the HP-UX compiler. I don't know if those options are supported for those compilers.

RbConfig::CONFIG['GCC'] returns nil for a Ruby compiled with Visual Studio and "yes" for the one-click installer.

@yorickpeterse
Copy link
Owner

Errr woops, I meant RbConfig::CONFIG['cc'].

@djberg96
Copy link
Author

RbConfig::CONFIG['CC'] # => "cl -nologo"

"cl" is the command line compiler name. The -nologo thing is just to make it shut up about copyright.

BTW, the analogue to -g for VS is "-Z7" for debugging symbols in an .obj file. Or you can use "-Zi" and it will generate a .pdb file instead. It looks like -Od is the equivalent of -O0.

@yorickpeterse yorickpeterse mentioned this pull request Mar 21, 2015
@yorickpeterse
Copy link
Owner

Moving this over to #14. I'll look into adjusting the extconf.rb as well.

@djberg96
Copy link
Author

Ok, thanks. BTW, I think you want 'CC', not 'cc'.

@yorickpeterse
Copy link
Owner

@djberg96 Gah, you're right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants