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

Fix gcc capability check #632

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/nmatrix/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ def create_conf_h(file) #:nodoc:

def find_newer_gplusplus #:nodoc:
print "checking for apparent GNU g++ binary with C++0x/C++11 support... "
major_version = gplusplus_version.split(".").first.to_i
# modern GCC has that
return true if major_version > 4
return false if major_version < 4

# legacy approach, check version 4:
[9,8,7,6,5,4,3].each do |minor|
ver = "4.#{minor}"
gpp = "g++-#{ver}"
result = `which #{gpp}`
next if result.empty?

CONFIG['CXX'] = gpp
puts ver
return CONFIG['CXX']
Expand All @@ -48,11 +55,11 @@ def gplusplus_version
patch = cxxvar.call('__GNUC_PATCHLEVEL__')

raise("unable to determine g++ version (match to get version was nil)") if major.nil? || minor.nil? || patch.nil?

"#{major}.#{minor}.#{patch}"
ver = "#{major}.#{minor}.#{patch}"
puts "g++ version discovered: " + ver
ver
end


if /cygwin|mingw/ =~ RUBY_PLATFORM
CONFIG["DLDFLAGS"] << " --output-lib libnmatrix.a"
end
Expand Down