summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYuta Saito <kateinoigakukun@gmail.com>2022-07-28 17:19:28 +0900
committerYuta Saito <kateinoigakukun@gmail.com>2022-08-04 16:29:22 +0900
commit50d81bfbc19d9b2e3d4be511c26c3dff317e2f8e (patch)
tree30f2ccd30240c6f60c393c3ee44db06650226e3c /lib
parent542040fb8375ffd74096ae0615a33bbc90524cb3 (diff)
Link ext bundles with bundle loader option for newer ld64
ld64 shipped with Xcode 14 emits a warning when using `-undefined dynamic_lookup`. ``` ld: warning: -undefined dynamic_lookup may not work with chained fixups ``` Actually, `-undefined dynamic_lookup` doesn't work when: 1. Link a *shared library* with the option 2. Link it with a program that uses the chained-fixup introduced from macOS 12 and iOS 15 because `-undefined dynamic_lookup` uses lazy-bindings and they won't be bound while dyld fixes-up by traversing chained-fixup info. However, we build exts as *bundles* and they are loaded only through `dlopen`, so it's safe to use `-undefined dynamic_lookup` in theory. So the warning produced by ld64 is false-positive, and it results failure of option checking in configuration. Therefore, it would be an option to ignore the warning during our configuration. On the other hand, `-undefined dynamic_lookup` is already deprecated on all darwin platforms except for macOS, so it's good time to get rid of the option. ld64 also provides `-bundle_loader <executable>` option, which allows to resolve symbols defined in the executable symtab while linking. It behaves almost the same with `-undefined dynamic_lookup`, but it makes the following changes: 1. Require that unresolved symbols among input objects must be defined in the executable. 2. Lazy symbol binding will lookup only the symtab of the bundle loader executable. (`-undefined dynamic_lookup` lookups all symtab as flat namespace) This patch adds `-bundle_loader $(RUBY)` when non-EXTSTATIC configuration by assuming ruby executable can be linked before building exts. See "New Features" subsection under "Linking" section for chained fixup https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6193
Diffstat (limited to 'lib')
-rw-r--r--lib/mkmf.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index a6ec9bae5d..79bb96ba75 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -2076,6 +2076,7 @@ sitearch = #{CONFIG['sitearch']}
ruby_version = #{RbConfig::CONFIG['ruby_version']}
ruby = #{$ruby.sub(%r[\A#{Regexp.quote(RbConfig::CONFIG['bindir'])}(?=/|\z)]) {'$(bindir)'}}
RUBY = $(ruby#{sep})
+BUILTRUBY = $(RUBY)
ruby_headers = #{headers.join(' ')}
RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'}