Project

General

Profile

Actions

Bug #19585

closed

Ruby Fails to Build on macOS with --enable-shared and --with-jemalloc

Added by eviljoel (evil joel) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
3.2.2, 3.1.3
[ruby-core:113160]

Description

Ruby fails to build on macOS 12.6.4 when configured with --enable-shared and --with-jemalloc. I receive the following linking error:

building spec/ruby/optional/capi/ext/bignum_spec.bundle
Undefined symbols for architecture x86_64:
  "_je_free", referenced from:
      _bignum_spec_rb_big_pack_array in bignum_spec-f7dc36.o
  "_je_malloc", referenced from:
      _bignum_spec_rb_big_pack_array in bignum_spec-f7dc36.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [spec/ruby/optional/capi/ext/bignum_spec.bundle] Error 1

It appears that the bignum C API spec requires "-undefined dynamic_lookup" to be enabled. I can get the build to succeed with:

./configure --enable-shared --with-jemalloc DLDFLAGS='-Wl,-undefined,dynamic_lookup'

I’ve created several bash scripts to demonstrate that:

  1. This is an error with the current production release of Ruby. Running jemallocBug-ruby3.2.2-20230407.sh demonstrates that building Ruby with these parameters fails in Ruby 3.2.2.
  2. This is a regression in at least the Ruby 3.1 branch. Running jemallocSucceeds-ruby3.1.2-20230407.sh demonstrates that building Ruby with these parameters worked with Ruby 3.1.2 and running jemallocBug-ruby3.1.3-20230407.sh demonstrates that building Ruby with these parameters fails in Ruby 3.1.3.

In the Ruby 3.1 branch, the first commit where this broke appears to be 2244fc9aa7ef8e03ac966e59b581baa021106b46.

ld version information:

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-820.1
BUILD 20:07:01 Nov  7 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 14.0.0, (clang-1400.0.29.202) (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 14.0.0 (tapi-1400.0.11)
$

clang version information:

$ clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$

I’m using jemalloc version 5.3.0.

MacBook Specs are:

Model: MacBook Pro (16-inch, 2019)
Processor: 2.4 GHz 8-Core Intel Core i9
Memory: 32 GB 2667 MHz DDR4
Graphics: AMD Radeon Pro 5300M 4 GB and Intel UHD Graphics 630 1536 MB

I’ve attached the config.log and config.status for the failed Ruby 3.2.2 build.

Please let me know if you need any more information.


Files

jemallocSucceeds-ruby3.1.2-20230407.sh (804 Bytes) jemallocSucceeds-ruby3.1.2-20230407.sh eviljoel (evil joel), 04/07/2023 11:27 PM
jemallocBug-ruby3.2.2-20230407.sh (804 Bytes) jemallocBug-ruby3.2.2-20230407.sh eviljoel (evil joel), 04/07/2023 11:27 PM
jemallocBug-ruby3.1.3-20230407.sh (804 Bytes) jemallocBug-ruby3.1.3-20230407.sh eviljoel (evil joel), 04/07/2023 11:27 PM
ruby-3.2.2-config.status (34.4 KB) ruby-3.2.2-config.status eviljoel (evil joel), 04/07/2023 11:27 PM
ruby-3.2.2-config.log (1.57 MB) ruby-3.2.2-config.log eviljoel (evil joel), 04/07/2023 11:27 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0