From 56e00aaf4bd16bc3b5d07a329624a10f0f90dea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasieka?= Date: Mon, 13 Sep 2021 10:12:03 +0200 Subject: [PATCH 1/2] fix g++ C++0x/C++11 support check --- lib/nmatrix/mkmf.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/nmatrix/mkmf.rb b/lib/nmatrix/mkmf.rb index 8c5d0526..3bb24d52 100644 --- a/lib/nmatrix/mkmf.rb +++ b/lib/nmatrix/mkmf.rb @@ -29,6 +29,11 @@ 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 < 0 + # legacy approach, check version 4: [9,8,7,6,5,4,3].each do |minor| ver = "4.#{minor}" gpp = "g++-#{ver}" @@ -48,11 +53,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 From 37b0bc059f3b9205facd8f46be013e8bd5520402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasieka?= Date: Mon, 13 Sep 2021 10:22:48 +0200 Subject: [PATCH 2/2] typo fix --- lib/nmatrix/mkmf.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/nmatrix/mkmf.rb b/lib/nmatrix/mkmf.rb index 3bb24d52..ae3b00b2 100644 --- a/lib/nmatrix/mkmf.rb +++ b/lib/nmatrix/mkmf.rb @@ -32,13 +32,15 @@ def find_newer_gplusplus #:nodoc: major_version = gplusplus_version.split(".").first.to_i # modern GCC has that return true if major_version > 4 - return false if major_version < 0 + 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']