From 945d6d6b52cb8e07bde164afe8cd9290bea17911 Mon Sep 17 00:00:00 2001 From: yoshoku Date: Sun, 27 Nov 2022 23:24:49 +0900 Subject: [PATCH] Add dynamic_lookup linker option for macOS and Ruby 3.1 --- ext/numo/linalg/blas/extconf.rb | 6 ++++++ ext/numo/linalg/lapack/extconf.rb | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ext/numo/linalg/blas/extconf.rb b/ext/numo/linalg/blas/extconf.rb index 62d38a1..fa76b5f 100644 --- a/ext/numo/linalg/blas/extconf.rb +++ b/ext/numo/linalg/blas/extconf.rb @@ -28,6 +28,12 @@ end end +if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION) + if try_link('int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup') + $LDFLAGS << ' -Wl,-undefined,dynamic_lookup' + end +end + if have_header("dlfcn.h") exit(1) unless have_library("dl") exit(1) unless have_func("dlopen") diff --git a/ext/numo/linalg/lapack/extconf.rb b/ext/numo/linalg/lapack/extconf.rb index edb20c7..424d25b 100644 --- a/ext/numo/linalg/lapack/extconf.rb +++ b/ext/numo/linalg/lapack/extconf.rb @@ -29,6 +29,12 @@ end end +if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION) + if try_link('int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup') + $LDFLAGS << ' -Wl,-undefined,dynamic_lookup' + end +end + if have_header("dlfcn.h") exit(1) unless have_library("dl") exit(1) unless have_func("dlopen")