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

macOS linking error when Ruby has been built with Xcode 14 #88

Closed
matsadler opened this issue Oct 20, 2022 · 1 comment · Fixed by #89
Closed

macOS linking error when Ruby has been built with Xcode 14 #88

matsadler opened this issue Oct 20, 2022 · 1 comment · Fixed by #89

Comments

@matsadler
Copy link
Contributor

Hey, I’m seeing errors in linking on macOS (12.6) when Ruby has been built with Xcode 14 (well, command line developer tools, same difference).

This only happens with a copy of Ruby built after installing/updating Xcode/command line tools. A Ruby built with an earlier version of Xcode will not exhibit this problem, even after Xcode/CLTools has been updated.

This seems to be because -Wl,-undefined,dynamic_lookup no longer appears in RbConfig::CONFIG["DLDFLAGS”], which seems to be due to a new warning output when -undefined dynamic_lookup is specified tripping up Ruby’s configure script.

Here’s the relevant Ruby bug report: https://bugs.ruby-lang.org/issues/19005

I’ve tried with Ruby head and the change doesn’t seem to have fixed it for me.

The discussion on the bug report mentions some outer possible fixes for a few gems tripped up by this. Possibly rb-sys could adopt one of these?

Here’s the full output of a quick test using the oxi-test gem (lightly edited to replace my home directory with ~).

~/src> pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 14.0.0.0.1.1661618636
volume: /
location: /
install-time: [1664992797](tel:1664992797)
groups: com.apple.FindSystemFiles.pkg-group 
~/src> ruby-build --version
ruby-build 20221004
~/src> ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
~/s/oxi-test> ruby -e 'puts RbConfig::CONFIG["DLDFLAGS"]'
-L~/.rbenv/versions/3.1.2/lib  -Wl,-multiply_defined,suppress
~/src> git clone git@github.com:oxidize-rb/oxi-test.git
Cloning into 'oxi-test'...
remote: Enumerating objects: 214, done.
remote: Counting objects: 100% (214/214), done.
remote: Compressing objects: 100% (132/132), done.
remote: Total 214 (delta 79), reused 174 (delta 40), pack-reused 0
Receiving objects: 100% (214/214), 47.97 KiB | 399.00 KiB/s, done.
Resolving deltas: 100% (79/79), done.
~/src> cd oxi-test/
~/s/oxi-test> bundle
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching rake 13.0.6
Installing rake 13.0.6
Using bundler 2.3.7
Fetching minitest 5.16.3
Fetching rb_sys 0.9.32
Fetching rake-compiler 1.2.0
Installing rb_sys 0.9.32
Installing rake-compiler 1.2.0
Using oxi-test 0.1.0 from source at `.`
Installing minitest 5.16.3
Bundle complete! 5 Gemfile dependencies, 6 gems now installed.
Bundled gems are installed into `./.bundle`
~/s/oxi-test> rake compile
mkdir -p tmp/arm64-darwin21/ext/3.1.2
cd tmp/arm64-darwin21/ext/3.1.2
~/.rbenv/versions/3.1.2/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/extconf.rb
cd -
cd tmp/arm64-darwin21/ext/3.1.2
/usr/bin/make
creating target directory (~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release)
generating ~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/ext-arm64-darwin21.def
generating ~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/libext.dylib (release)
   Compiling memchr v2.5.0
   Compiling glob v0.3.0
   Compiling proc-macro2 v1.0.46
   Compiling libc v0.2.134
   Compiling cfg-if v1.0.0
   Compiling minimal-lexical v0.2.1
   Compiling unicode-ident v1.0.4
   Compiling quote v1.0.21
   Compiling regex-syntax v0.6.27
   Compiling bindgen v0.60.1
   Compiling lazycell v1.3.0
   Compiling peeking_take_while v0.1.2
   Compiling bitflags v1.3.2
   Compiling shlex v1.1.0
   Compiling shell-words v1.1.0
   Compiling lazy_static v1.4.0
   Compiling rustc-hash v1.1.0
   Compiling libloading v0.7.3
   Compiling clang-sys v1.4.0
   Compiling aho-corasick v0.7.19
   Compiling nom v7.1.1
   Compiling linkify v0.9.0
   Compiling regex v1.6.0
   Compiling rb-sys-build v0.9.31
   Compiling cexpr v0.6.0
   Compiling rb-sys v0.9.31
   Compiling ext v0.1.0 (~/src/oxi-test/ext)
error: linking with `clang` failed: exit status: 1
  |
  = note: "clang" "-Wl,-exported_symbols_list,/var/folders/7k/k5j5vcld6_d147vtfb4zj15w0000gq/T/rustcCMR5B9/list" "-arch" "arm64" "/var/folders/7k/k5j5vcld6_d147vtfb4zj15w0000gq/T/rustcCMR5B9/symbols.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.0.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.1.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.2.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.3.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.4.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.ext.5b99f978-cgu.5.rcgu.o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/ext.x36acqfc6zdarfn.rcgu.o" "-L" "~/.rbenv/versions/3.1.2/lib" "-L" "~/.rbenv/versions/3.1.2/lib" "-L" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps" "-L" "~/.rbenv/versions/3.1.2/lib" "-L" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/librb_sys-ee71a17f679bda72.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-f6811f31090e0239.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-585aa2ea4819ce90.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-1b4ea1dc4a3823f8.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-f653b27121920f5c.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-ef1f6d7964edf865.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-8d0a95997d48da47.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-68d9470ea5ba2fa3.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-d4ed7f63db7e9953.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-d2ad324cf0492211.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-a00c8eba7ff52d83.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libadler-92e25d254b309fb5.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-9cf27ed549592a86.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-ebee0ebd9a510319.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-718033b8fe200c22.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-5ec3532fb120beec.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-80ef5ce8d4cd7e19.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-b5600cb14c277fae.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-760870d297bc6b81.rlib" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-931e7dc6a4f959e6.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "~/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/deps/libext.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" "-Wl,-multiply_defined,suppress"
  = note: Undefined symbols for architecture arm64:
            "_rb_define_module", referenced from:
                _Init_ext in ext.ext.5b99f978-cgu.2.rcgu.o
            "_rb_define_module_under", referenced from:
                _Init_ext in ext.ext.5b99f978-cgu.2.rcgu.o
            "_rb_define_singleton_method", referenced from:
                _Init_ext in ext.ext.5b99f978-cgu.2.rcgu.o
            "_rb_str_buf_append", referenced from:
                ext::hello::hc9f574f40dfe3854 in ext.ext.5b99f978-cgu.2.rcgu.o
            "_rb_utf8_str_new_cstr", referenced from:
                ext::hello::hc9f574f40dfe3854 in ext.ext.5b99f978-cgu.2.rcgu.o
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `ext` due to previous error
make: *** [~/src/oxi-test/tmp/arm64-darwin21/ext/3.1.2/target/release/libext.dylib] Error 101
rake aborted!
Command failed with status (2): [/usr/bin/make...]
~/src/oxi-test/.bundle/ruby/3.1.0/gems/rake-compiler-1.2.0/lib/rake/extensiontask.rb:181:in `block (2 levels) in define_compile_tasks'
~/src/oxi-test/.bundle/ruby/3.1.0/gems/rake-compiler-1.2.0/lib/rake/extensiontask.rb:180:in `block in define_compile_tasks'
~/src/oxi-test/.bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Tasks: TOP => compile => compile:arm64-darwin21 => compile:ext:arm64-darwin21 => copy:ext:arm64-darwin21:3.1.2 => tmp/arm64-darwin21/ext/3.1.2/ext.bundle
(See full trace by running task with --trace)
~/s/oxi-test>
@ianks
Copy link
Collaborator

ianks commented Oct 20, 2022

Thanks for the heads up. Will handle this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants