Project

General

Profile

Actions

Bug #19239

closed

miniruby is not built by default when cross-compiling ruby 3.2.0-rc1

Added by mdalessio (Mike Dalessio) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

When cross-compiling Ruby for darwin, the default make target doesn't build miniruby, even though it's needed for symbol resolution since https://github.com/ruby/ruby/commit/50d81bf

A workaround is to run make miniruby && make but I'm opening this issue to discuss if something needs to be fixed.

Here is a dockerfile that reproduces the issue:

FROM larskanis/rake-compiler-dock-mri-x86_64-darwin:1.2.2

RUN wget https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0-rc1.tar.gz
RUN tar -zxf ruby-3.2.0-rc1.tar.gz

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && \
    apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config autoconf libyaml-dev

ENV CC x86_64-apple-darwin-clang

RUN bash -c " \
      rvm use 3.1.0 && \
      cd ruby-3.2.0-rc1 && \
      ./configure \
        --host=x86_64-apple-darwin \
        --target=x86_64-apple-darwin \
        --build=x86_64-pc-linux-gnu \
        --disable-jit-support \
    "

RUN bash -c " \
      rvm use 3.1.0 && \
      cd ruby-3.2.0-rc1 && \
      make V=1 \
    "

Failure emits errors like this:

x86_64-apple-darwin-clang -dynamic -bundle -o ../../../.ext/x86_64-darwin/-test-/RUBY_ALIGNOF.bundle c.o cpp.o -L. -L../../.. -L. -fstack-protector-strong -Wl,-multiply_defined,suppress -Wl,-undefined,dynamic_lookup -bundle_loader '../../../miniruby'   -lpthread  
ld: file not found: ../../../miniruby
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: Leaving directory '/ruby-3.2.0-rc1/ext/-test-/RUBY_ALIGNOF'
make[2]: *** [Makefile:271: ../../../.ext/x86_64-darwin/-test-/RUBY_ALIGNOF.bundle] Error 1
make[1]: Leaving directory '/ruby-3.2.0-rc1'
make[1]: *** [exts.mk:100: ext/-test-/RUBY_ALIGNOF/all] Error 2
make: *** [uncommon.mk:330: build-ext] Error 2

The error stems from the LD flag -bundle_loader '$(BUILTRUBY)' which points at miniruby, even though miniruby has not been built.

Replacing the last command with this will successfully build Ruby:

RUN bash -c " \
      rvm use 3.1.0 && \
      cd ruby-3.2.0-rc1 && \
      make miniruby V=1 && \
      make V=1 \
    "

This is also happening on master HEAD.

cc @katei (Yuta Saito) and @alanwu (Alan Wu) who seem to be familiar with the bundle_loader functionality.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0