Skip to content

Commit 32132b0

Browse files
setoelkahficlaude
andcommitted
Merge feature/fix-macos-27-beta: valid LC_ID_DYLIB for macOS 26/27 dyld
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2 parents 02606e2 + 12e21ba commit 32132b0

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

sdk/gems/auth/Rakefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,22 @@ RbSys::ExtensionTask.new('auth', GEMSPEC) do |ext|
1111
ext.lib_dir = 'lib/auth'
1212
end
1313

14+
# macOS: the rb_sys/rake-compiler build emits the bundle as an MH_DYLIB with an
15+
# empty LC_ID_DYLIB install name (a plain `cargo build` does not). dyld on macOS
16+
# 15+/Tahoe rejects that with "load command string extends beyond end of load
17+
# command", so the gem fails to load. Stamp a valid install name onto every
18+
# bundle the build produces by enhancing the bundle file tasks themselves (which
19+
# is what `rake native gem` runs, not the top-level `compile`). install_name_tool
20+
# re-signs ad-hoc, ships on the macOS gem-build runners, and works across archs
21+
# (cross-built x86_64 bundles too). Idempotent.
22+
if RbConfig::CONFIG['host_os'] =~ /darwin/
23+
Rake::Task.tasks.each do |t|
24+
next unless t.name.end_with?('auth.bundle')
25+
26+
t.enhance do
27+
sh 'install_name_tool', '-id', '@rpath/auth.bundle', t.name if File.exist?(t.name)
28+
end
29+
end
30+
end
31+
1432
task default: :compile

sdk/gems/auth/ext/auth/extconf.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,15 @@
44
require 'rb_sys/mkmf'
55

66
create_rust_makefile('auth/auth')
7+
8+
# rb-sys (fixup_libnames) appends `install_name_tool -id "" $(DLLIB)` to the
9+
# generated Makefile, blanking the bundle's LC_ID_DYLIB install name. dyld on
10+
# macOS 26/27 rejects an empty dylib-ID string ("load command string extends
11+
# beyond end of load command"), so the extension fails to dlopen. Rewrite that
12+
# step to stamp a valid @rpath id instead. This covers the `gem install`
13+
# (extconf) build path; the Rakefile covers `rake native gem` builds.
14+
if RUBY_PLATFORM.include?('darwin') && File.exist?('Makefile')
15+
makefile = File.read('Makefile')
16+
patched = makefile.gsub('install_name_tool -id ""', 'install_name_tool -id "@rpath/auth.bundle"')
17+
File.write('Makefile', patched) if patched != makefile
18+
end

0 commit comments

Comments
 (0)