Project

General

Profile

Actions

Bug #21792

open

4.0.0-preview3: Build fails with `--with-ext=` when ENABLE_SHARED=yes: ruby/digest.h not found for rubyspec CAPI extensions

Bug #21792: 4.0.0-preview3: Build fails with `--with-ext=` when ENABLE_SHARED=yes: ruby/digest.h not found for rubyspec CAPI extensions

Added by mdalessio (Mike Dalessio) 1 day ago. Updated about 6 hours ago.

Status:
Open
Assignee:
-
Target version:
ruby -v:
Backport:
[ruby-core:124292]

Description

When building Ruby with --enable-shared and --with-ext= (empty, to disable all extensions), the build fails because spec/ruby/optional/capi/ext/digest_spec.c cannot find ruby/digest.h.

This affects cross-compilation tooling like rake-compiler which uses these configure options to build a minimal Ruby for cross-compiling native gems.

Reproducing

Download and extract ruby-4.0.0-preview2 source code.

cd ruby-4.0.0-preview2
./configure --enable-shared --disable-install-doc --with-ext=
make

Or alternatively, use rake-compiler:

mkdir ~/.rake-compiler
rake-compiler cross-ruby VERSION=4.0.0-preview2 HOST=x86_64-linux-gnu

Either way, you will see:

spec/ruby/optional/capi/ext/digest_spec.c:4:10: fatal error: ruby/digest.h: No such file or directory
    4 | #include "ruby/digest.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [defs/gmake.mk:521: spec/ruby/optional/capi/ext/digest_spec.so] Error 1

Root Cause

I believe the root cause is:

  1. defs/gmake.mk:531-532 unconditionally adds rubyspec-capiext to the exts target when ENABLE_SHARED=yes:
ifeq ($(ENABLE_SHARED),yes)
exts: rubyspec-capiext
endif
  1. rubyspec-capiext builds all *.c files in spec/ruby/optional/capi/ext/, including digest_spec.c
  2. digest_spec.c (line 4) includes ruby/digest.h
  3. ruby/digest.h is only installed when the digest extension is built. From ext/digest/extconf.rb:7-9:
$INSTALLFILES = {
  "digest.h" => "$(HDRDIR)"
} if $extmk
  1. With --with-ext= (empty), the digest extension is not built, so digest.h is never copied to .ext/include/ruby/
  2. The build fails because digest_spec.c requires a header that was never installed

Note that before 269ad29d, no rubyspec CAPI extension required extension-specific headers, so this configuration worked.

Actions

Also available in: PDF Atom