Project

General

Profile

Actions

Bug #20088

closed

Ruby 3.3.0 does not cross-complie on arm64-darwin

Added by stanhu (Stan Hu) 12 months ago. Updated 5 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:115910]

Description

To reproduce:

docker run -it ghcr.io/rake-compiler/rake-compiler-dock-image:1.4.0.rc2-mri-arm64-darwin bash
cd /tmp
export CPPFLAGS=''
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong '
export LDFLAGS='-pipe '
export CC=aarch64-apple-darwin-clang
export MAKE='make V=1'
rake-compiler cross-ruby VERSION=3.3.0 HOST=aarch64-apple-darwin

This errors out with:

aarch64-apple-darwin-clang  -O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong  -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef  -pipe -march=arm64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE -I. -I.ext/include/arm64-darwin -I/usr/local/rake-compiler/sources/ruby-3.3.0/include -I/usr/local/rake-compiler/sources/ruby-3.3.0 -I/usr/local/rake-compiler/sources/ruby-3.3.0/prism -I/usr/local/rake-compiler/sources/ruby-3.3.0/enc/unicode/15.0.0   -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -o main.o -c /usr/local/rake-compiler/sources/ruby-3.3.0/main.c
clang: error: the clang compiler does not support '-march=arm64'
make: *** [uncommon.mk:1291: main.o] Error 1

This appears to be a regression due to https://github.com/ruby/ruby/pull/9250. RUBY_DEFAULT_ARCH("$target_cpu") is called, and this case statement is hit:

AS_CASE([$build_os],
        [darwin*], [ARCH_FLAG="-arch "$1],
        [ARCH_FLAG=-march=$1]

I'm not sure this test is correct, since $build_os appears to be linux-gnu. This results in -march=arm64 being used, which is not a valid option even in clang 15.0.0.

Should $target_cpu and $target_os be considered instead?

The configure output shows:

Configuration summary for ruby version 3.3.0

   * Installation prefix: /usr/local/rake-compiler/ruby/aarch64-apple-darwin/ruby-3.3.0
   * exec prefix:         ${prefix}
   * arch:                arm64-darwin
   * site arch:           ${arch}
   * RUBY_BASE_NAME:      ruby
   * enable shared:       no
   * ruby lib prefix:     ${libdir}/${RUBY_BASE_NAME}
   * site libraries path: ${rubylibprefix}/${sitearch}
   * vendor path:         ${rubylibprefix}/vendor_ruby
   * target OS:           darwin
   * compiler:            aarch64-apple-darwin-clang
   * with thread:         pthread
   * with coroutine:      arm64
   * enable shared libs:  no
   * dynamic library ext: bundle
   * CFLAGS:              -fdeclspec ${optflags} ${debugflags} ${warnflags}
   * LDFLAGS:             -L. -pipe  -fstack-protector-strong
   * DLDFLAGS:            -pipe  -Wl,-multiply_defined,suppress -Wl,-undefined,dynamic_lookup
   * optflags:            -O3 -fno-fast-math
   * debugflags:          -ggdb3
   * warnflags:           -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition \
                          -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter \
                          -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef
   * strip command:       aarch64-apple-darwin-strip -A -n
   * install doc:         no
   * YJIT support:        no
   * RJIT support:        no
   * man page type:       man
   * BASERUBY -v:         ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux]

The configure statement for reference:

./configure --host=aarch64-apple-darwin --target=aarch64-apple-darwin --build=x86_64-pc-linux-gnu --enable-install-static-library --disable-jit-support --disable-install-doc --with-ext= --enable-static --disable-shared --prefix=/usr/local/rake-compiler/ruby/aarch64-apple-darwin/ruby-3.3.0

This was first reported in a CI failure in https://github.com/rake-compiler/rake-compiler-dock/pull/112#issuecomment-1869367367.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like1