homebrew-core icon indicating copy to clipboard operation
homebrew-core copied to clipboard

perl, ruby: failed to build from source on Ubuntu 20.04 LTS

Open XuehaiPan opened this issue 1 year ago โ€ข 15 comments

brew gist-logs <formula> link OR brew config AND brew doctor output

linuxbrew@ubuntu:~$ brew config
HOMEBREW_VERSION: 3.6.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: 6e2b162c4786e075323f038d46bfb566d91889e7
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 7c25c1f10892efbe18368ac7a7db2cfcaa8a70f0
Core tap last commit: 39 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 32
Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8_1/bin/ruby
CPU: 32-core 64-bit zen3
Clang: N/A
Git: 2.37.3 => /bin/git
Curl: 7.68.0 => /bin/curl
Kernel: Linux 5.10.102.1-microsoft-standard-WSL2 x86_64 GNU/Linux
OS: Unknown
Host glibc: 2.31
/usr/bin/gcc: 9.4.0
/usr/bin/ruby: N/A
glibc: 2.35
gcc@11: 11.3.0
xorg: N/A

linuxbrew@ubuntu:~$ brew doctor
Your system is ready to brew.

Verification

  • [X] I ran brew update and am still able to reproduce my issue.
  • [X] I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

Install perl from the source. My HOMEBREW_PREFIX is not /home/linuxbrew/.linuxbrew, so I cannot use bottles.

What happened (include all command output)?

$ docker run -it --rm --pull=always -h ubuntu ghcr.io/homebrew/ubuntu20.04:latest
latest: Pulling from homebrew/ubuntu20.04
675920708c8b: Already exists 
46179ed504be: Pull complete 
5006ef91680a: Pull complete 
e776bca6ba8d: Pull complete 
Digest: sha256:81348fae67609f94264c18ba0c2bc2bd36a3dc4fdf15b128828a98a68195f273
Status: Downloaded newer image for ghcr.io/homebrew/ubuntu20.04:latest
linuxbrew@ubuntu:~$ brew install -s perl
Running `brew update --auto-update`...
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
antidote                apophenia               cargo-zigbuild          commitlint              [email protected]                objconv                 xctesthtmlreport        xwin

==> Downloading https://ghcr.io/v2/homebrew/core/glibc/manifests/2.35
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/glibc/blobs/sha256:cd51b67e67b9a5d27880efc06a2b01b71e0b7b8b2cc207e6e961e46c423018e3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:cd51b67e67b9a5d27880efc06a2b01b71e0b7b8b2cc207e6e961e46c423018e3?se=2022-09-13T10%3A55%3A00Z&sig=VIGkp5Uxzc
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.2.6
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:607a3d993f45efe858d3e4f002603e323a1b1f0c87b4db6fb57d1280f479809d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:607a3d993f45efe858d3e4f002603e323a1b1f0c87b4db6fb57d1280f479809d?se=2022-09-13T10%3A55%3A00Z&sig=C6wUtKJBBF
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2022-07-19_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:9e0df163364a5ae07f3ee2cf39083cd74bcb38eeb5250b706e1c02f878d8d632
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9e0df163364a5ae07f3ee2cf39083cd74bcb38eeb5250b706e1c02f878d8d632?se=2022-09-13T10%3A55%3A00Z&sig=5bDGEMPxis
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1q
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:abec715f01eb20edda202463ca91403e3fa767afcba0fe732ef8e072bb99d2fd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:abec715f01eb20edda202463ca91403e3fa767afcba0fe732ef8e072bb99d2fd?se=2022-09-13T10%3A55%3A00Z&sig=3WejXEx2jQ
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/manifests/6.2.1_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c?se=2022-09-13T10%3A55%3A00Z&sig=0T%2BxbNk%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/isl/manifests/0.25
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/isl/blobs/sha256:c0244c95ed9cc89b826868de83bec3150fcc120add1265017176770150757083
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c0244c95ed9cc89b826868de83bec3150fcc120add1265017176770150757083?se=2022-09-13T10%3A55%3A00Z&sig=4Xf0HtOTVD
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mpfr/manifests/4.1.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mpfr/blobs/sha256:4c5f1cfd038e8fbd640795e34e5e23c11244be3eca7781979600ec0d50bb9c0b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:4c5f1cfd038e8fbd640795e34e5e23c11244be3eca7781979600ec0d50bb9c0b?se=2022-09-13T10%3A55%3A00Z&sig=WWylNRkXSm
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libmpc/manifests/1.2.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libmpc/blobs/sha256:d74eb5f1377d8fa72fad88baca1bd5f00c29d45ba186fbec89ad690c1d1f721f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d74eb5f1377d8fa72fad88baca1bd5f00c29d45ba186fbec89ad690c1d1f721f?se=2022-09-13T10%3A55%3A00Z&sig=%2Fbd%2Ff7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:1757fefc3840e11c4822e4c2a95aa62aca44a4eaccce6f5c414ea51d1e58bf8e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1757fefc3840e11c4822e4c2a95aa62aca44a4eaccce6f5c414ea51d1e58bf8e?se=2022-09-13T10%3A55%3A00Z&sig=HTeqxQvjJP
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.12
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:23b1d8f0500bbccdf5cc466e7acbd7eddc40cd1465687239af423389abe4f46e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:23b1d8f0500bbccdf5cc466e7acbd7eddc40cd1465687239af423389abe4f46e?se=2022-09-13T10%3A55%3A00Z&sig=STz8bZZOl%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.2-3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:006b5ab6a4616a8b6f59953cb9efb546d312e3ba231c303bb56749e7f66f56df
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:006b5ab6a4616a8b6f59953cb9efb546d312e3ba231c303bb56749e7f66f56df?se=2022-09-13T10%3A55%3A00Z&sig=qYIwUHC%2B
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/binutils/manifests/2.39_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/binutils/blobs/sha256:efa7497e2ea56d9b68ce41363cdc1a41cad032b3ae2fa2cbe819459011651809
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:efa7497e2ea56d9b68ce41363cdc1a41cad032b3ae2fa2cbe819459011651809?se=2022-09-13T10%3A55%3A00Z&sig=m26uX74fRW
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/11/manifests/11.3.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/11/blobs/sha256:64d9c853ddbe63e0361a993560da8b7883bde57854bef20a0f07afa4aa597b34
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:64d9c853ddbe63e0361a993560da8b7883bde57854bef20a0f07afa4aa597b34?se=2022-09-13T11%3A00%3A00Z&sig=%2Fwq9wo86
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/berkeley-db/manifests/18.1.40_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/berkeley-db/blobs/sha256:ed8bbe73f3996dce31e082f325cb5230e6026d2067824e6ceaaceeafc146ff0c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ed8bbe73f3996dce31e082f325cb5230e6026d2067824e6ceaaceeafc146ff0c?se=2022-09-13T11%3A00%3A00Z&sig=l1QOyZsWoL
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/manifests/1.23
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/blobs/sha256:7d5728174c3de6c048a233459a1b8ac9e8c53645ca14962d9a1deb60fd58a568
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7d5728174c3de6c048a233459a1b8ac9e8c53645ca14962d9a1deb60fd58a568?se=2022-09-13T11%3A00%3A00Z&sig=V%2Bd1hgBn
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/expat/manifests/2.4.8
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/expat/blobs/sha256:db13166d6a5bd0e19f82e9cd19f4a951ffff40cdfc29197e8143780444d0c204
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:db13166d6a5bd0e19f82e9cd19f4a951ffff40cdfc29197e8143780444d0c204?se=2022-09-13T11%3A00%3A00Z&sig=Ta%2B%2BG%
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxcrypt/manifests/4.4.28
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxcrypt/blobs/sha256:84269a82afe1a9e94ba6828c983a4b8e65d8d672d36d88232daac832017ab327
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:84269a82afe1a9e94ba6828c983a4b8e65d8d672d36d88232daac832017ab327?se=2022-09-13T11%3A00%3A00Z&sig=YqDwzctzWB
######################################################################## 100.0%
==> Downloading https://github.com/Perl/perl5/commit/7e19816aa8661ce0e984742e2df11dd20dcdff18.patch?full_index=1
######################################################################## 100.0%
==> Downloading https://www.cpan.org/src/5.0/perl-5.34.0.tar.xz
######################################################################## 100.0%
==> Installing dependencies for perl: glibc, xz, ca-certificates, [email protected], gmp, isl, mpfr, libmpc, lz4, zlib, zstd, binutils, gcc@11, berkeley-db, gdbm, expat and libxcrypt
==> Installing perl dependency: glibc
==> Pouring glibc--2.35.x86_64_linux.bottle.tar.gz
==> Installing locale data for en_US.UTF-8
==> /home/linuxbrew/.linuxbrew/Cellar/glibc/2.35/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/glibc/2.35: 1,401 files, 47MB
==> Installing perl dependency: xz
==> Pouring xz--5.2.6.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/xz/5.2.6: 150 files, 2.4MB
==> Installing perl dependency: ca-certificates
==> Pouring ca-certificates--2022-07-19_1.all.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/ca-certificates/2022-07-19_1: 3 files, 238.3KB
==> Installing perl dependency: [email protected]
==> Pouring [email protected]_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/[email protected]/1.1.1q: 8,411 files, 24.3MB
==> Installing perl dependency: gmp
==> Pouring gmp--6.2.1_1.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/gmp/6.2.1_1: 23 files, 3.9MB
==> Installing perl dependency: isl
==> Pouring isl--0.25.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/isl/0.25: 74 files, 9.2MB
==> Installing perl dependency: mpfr
==> Pouring mpfr--4.1.0.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/mpfr/4.1.0: 31 files, 7.9MB
==> Installing perl dependency: libmpc
==> Pouring libmpc--1.2.1.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/libmpc/1.2.1: 13 files, 550KB
==> Installing perl dependency: lz4
==> Pouring lz4--1.9.4.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/lz4/1.9.4: 22 files, 695.4KB
==> Installing perl dependency: zlib
==> Pouring zlib--1.2.12.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.12: 12 files, 464.4KB
==> Installing perl dependency: zstd
==> Pouring zstd--1.5.2.x86_64_linux.bottle.3.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/zstd/1.5.2: 31 files, 2.6MB
==> Installing perl dependency: binutils
==> Pouring binutils--2.39_1.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/binutils/2.39_1: 4,687 files, 370.5MB
==> Installing perl dependency: gcc@11
==> Pouring [email protected]_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0/bin/../lib/gcc/11/gcc/x86_64-pc-linux-gnu/11/specs
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/gcc@11/11.3.0: 2,187 files, 347.3MB
==> Installing perl dependency: berkeley-db
==> Pouring berkeley-db--18.1.40_1.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/berkeley-db/18.1.40_1: 44 files, 8MB
==> Installing perl dependency: gdbm
==> Pouring gdbm--1.23.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/gdbm/1.23: 40 files, 1.3MB
==> Installing perl dependency: expat
==> Pouring expat--2.4.8.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/expat/2.4.8: 21 files, 842.8KB
==> Installing perl dependency: libxcrypt
==> Pouring libxcrypt--4.4.28.x86_64_linux.bottle.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/libxcrypt/4.4.28: 24 files, 362.8KB
==> Installing perl
==> Patching
==> Applying 7e19816aa8661ce0e984742e2df11dd20dcdff18.patch
File Configure is read-only; trying to patch anyway
patching file Configure
Hunk #1 succeeded at 1493 (offset -12 lines).
==> ./Configure -des -Dinstallprefix=/home/linuxbrew/.linuxbrew/Cellar/perl/5.34.0_1 -Dprefix=/home/linuxbrew/.linuxbrew/opt/perl -Dprivlib=/home/linuxbrew/.linuxbrew/opt/perl/lib/perl5/5.34 -
==> make
Last 15 lines from /home/linuxbrew/.cache/Homebrew/Logs/perl/02.make:
make[1]: Leaving directory '/tmp/perl-20220913-6369-1ujw0j/perl-5.34.0'
make: *** [Makefile:748: makefile] Error 2
make: *** [Makefile:251: dump.o] Error 1
make: *** [Makefile:251: doio.o] Error 1
make: *** [Makefile:251: deb.o] Error 1
In file included from /home/linuxbrew/.linuxbrew/include/bits/posix1_lim.h:161,
                 from /home/linuxbrew/.linuxbrew/include/limits.h:195,
                 from perl.h:907,
                 from locale.c:49:
/home/linuxbrew/.linuxbrew/include/bits/local_lim.h:38:10: fatal error: linux/limits.h: No such file or directory
   38 | #include <linux/limits.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:251: pp.o] Error 1
make: *** [Makefile:251: locale.o] Error 1

READ THIS: https://docs.brew.sh/Troubleshooting

These open issues may also help:
perl, apt: use berkeley-db@5 https://github.com/Homebrew/homebrew-core/pull/107303
perl 5.36.0 grokj2k 9.7.8 rxvt-unicode 9.30 https://github.com/Homebrew/homebrew-core/pull/102549

What did you expect to happen?

Install perl from the source.

Step-by-step reproduction instructions (by running brew commands)

$ docker run -it --rm --pull=always -h ubuntu ghcr.io/homebrew/ubuntu20.04:latest
linuxbrew@ubuntu:~$ brew install -s perl

XuehaiPan avatar Sep 13 '22 11:09 XuehaiPan

I was able to build perl successfully by installing linux-headers in advance (on Ubuntu 20.04 LTS):

linuxbrew@ubuntu:~$ brew install linux-headers
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

==> Downloading https://ghcr.io/v2/homebrew/core/linux-headers/5.15/manifests/5.15.57-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/linux-headers/5.15/blobs/sha256:8692682830cbb1fb74bb61190b644da9de0f4c3a40cf18653a9b4a85bc5ce50d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8692682830cbb1fb74bb61190b644da9de0f4c3a40cf18653a9b4a85bc5ce50d?se=2022-09-13T11%3A35%3A00Z&sig=s%2BPYEDUc
######################################################################## 100.0%
==> Pouring [email protected]_64_linux.bottle.1.tar.gz
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/[email protected]/5.15.57: 963 files, 5.7MB
==> Running `brew cleanup [email protected]`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

linuxbrew@ubuntu:~$ brew install -s perl
==> Downloading https://github.com/Perl/perl5/commit/7e19816aa8661ce0e984742e2df11dd20dcdff18.patch?full_index=1
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/7f32311b27d50333920999cd093f656926711401ab1fb378a60622e1e6d84b49--7e19816aa8661ce0e984742e2df11dd20dcdff18.patch
==> Downloading https://www.cpan.org/src/5.0/perl-5.34.0.tar.xz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/e63d63c5214f5a24ffe7f619702c992ae7be35b2900dc9e6794296ef8fc3d471--perl-5.34.0.tar.xz
==> Patching
==> Applying 7e19816aa8661ce0e984742e2df11dd20dcdff18.patch
File Configure is read-only; trying to patch anyway
patching file Configure
Hunk #1 succeeded at 1493 (offset -12 lines).
==> ./Configure -des -Dinstallprefix=/home/linuxbrew/.linuxbrew/Cellar/perl/5.34.0_1 -Dprefix=/home/linuxbrew/.linuxbrew/opt/perl -Dprivlib=/home/linuxbrew/.linuxbrew/opt/perl/lib/perl5/5.34 -
==> make
==> make install
==> Caveats
By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.

You can set that up like this:
  PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"' >> ~/.profile
==> Summary
๐Ÿบ  /home/linuxbrew/.linuxbrew/Cellar/perl/5.34.0_1: 2,485 files, 73.4MB, built in 1 minute 19 seconds
==> Running `brew cleanup perl`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`)

XuehaiPan avatar Sep 13 '22 11:09 XuehaiPan

Also failed to build ruby from source (with/without linux-headers installed) on Ubuntu 20.04 LTS (docker image ghcr.io/homebrew/ubuntu20.04:latest):

linuxbrew@ubuntu:~$ brew config
HOMEBREW_VERSION: 3.6.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: 6e2b162c4786e075323f038d46bfb566d91889e7
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: fa1535802c6db67a924ad1df424e6314bcc184bd
Core tap last commit: 59 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 32
Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8_1/bin/ruby
CPU: 32-core 64-bit zen3
Clang: N/A
Git: 2.37.3 => /bin/git
Curl: 7.68.0 => /bin/curl
Kernel: Linux 5.10.102.1-microsoft-standard-WSL2 x86_64 GNU/Linux
OS: Unknown
Host glibc: 2.31
/usr/bin/gcc: 9.4.0
/usr/bin/ruby: N/A
glibc: 2.35
gcc@11: 11.3.0
xorg: N/A
linuxbrew@ubuntu:~$ brew install -s ruby
==> Downloading https://rubygems.org/rubygems/rubygems-3.3.11.tgz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/59ef2cf81d4e5a65435e511cdb583d771384dacc0d6e1a919efb5012c4261b05--rubygems-3.3.11.tgz
==> Downloading https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
Already downloaded: /home/linuxbrew/.cache/Homebrew/downloads/fafc7c035257faae96f55cfa022167b3ec8df66fe692de2d92b8e163c40139eb--ruby-3.1.2.tar.gz
==> ./configure --prefix=/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1 --enable-shared --with-sitedir=/home/linuxbrew
==> make
==> make install
Last 15 lines from /home/linuxbrew/.cache/Homebrew/Logs/ruby/03.make:
        from /tmp/ruby-20220913-478-vb29tc/ruby-3.1.2/lib/rubygems/ext/builder.rb:195:in `block in build_extensions'
        from /tmp/ruby-20220913-478-vb29tc/ruby-3.1.2/lib/rubygems/ext/builder.rb:192:in `each'
        from /tmp/ruby-20220913-478-vb29tc/ruby-3.1.2/lib/rubygems/ext/builder.rb:192:in `build_extensions'
        from /tmp/ruby-20220913-478-vb29tc/ruby-3.1.2/lib/rubygems/installer.rb:853:in `build_extensions'
        from /tmp/ruby-20220913-478-vb29tc/ruby-3.1.2/lib/rubygems/installer.rb:328:in `install'
        from ./tool/rbinstall.rb:899:in `block in install'
        from ./tool/rbinstall.rb:713:in `no_write'
        from ./tool/rbinstall.rb:899:in `install'
        from ./tool/rbinstall.rb:1068:in `block (2 levels) in <main>'
        from ./tool/rbinstall.rb:1043:in `foreach'
        from ./tool/rbinstall.rb:1043:in `block in <main>'
        from ./tool/rbinstall.rb:1127:in `block in <main>'
        from ./tool/rbinstall.rb:1124:in `each'
        from ./tool/rbinstall.rb:1124:in `<main>'
make: *** [uncommon.mk:383: do-install-all] Error 1

READ THIS: https://docs.brew.sh/Troubleshooting

These open issues may also help:
licensefinder: use `ruby` on Linux and pre-Catalina https://github.com/Homebrew/homebrew-core/pull/108211

Full gist-log: https://gist.github.com/XuehaiPan/d675e7efb49b2272cb57752ceb1a6f8e

I could build from source successfully on Ubuntu 22.04 LTS (docker image ghcr.io/homebrew/ubuntu22.04:latest).

XuehaiPan avatar Sep 13 '22 13:09 XuehaiPan

linux-headers is supposed to be installed automatically when glibc is installed, which should happen on Ubuntu 20.04. The ruby issue is known - the problem is that ruby builds a static temporarily libruby.so in its build directory that incorrectly uses the system ld.so instead of the brewed one. I can post a more detailed output from this shortly.

danielnachun avatar Sep 13 '22 17:09 danielnachun

linux-headers is supposed to be installed automatically when glibc is installed, which should happen on Ubuntu 20.04.

linux-headers is build-only dependency of glibc. It will not be installed if using bottles. It may also be removed by brew autoremove.

https://github.com/Homebrew/homebrew-core/blob/379fea565f21d730cf01987f5571fa0dc4823792/Formula/glibc.rb#L58-L61

XuehaiPan avatar Sep 14 '22 08:09 XuehaiPan

linux-headers is supposed to be installed automatically when glibc is installed, which should happen on Ubuntu 20.04.

It should either be added to specific formulae that need it (preferred) or made a non-build dependency.

MikeMcQuaid avatar Sep 14 '22 11:09 MikeMcQuaid

It was supposed to be a non-build dependency. I don't know how that got changed but it shouldn't have been.

danielnachun avatar Sep 15 '22 22:09 danielnachun

@danielnachun I changed it in https://github.com/Homebrew/homebrew-core/commit/6c2842a7dcda0cf65dc31394253f7f34053b3f1a and @carlocab gave it a โœ…. I specifically requested you and @sjackman for review assuming you'd point out of that was a problem.

It still doesn't really seem to me to be an actual runtime dependency for glibc but instead something that some packages that depend on glibc also need.

That said, I'm fine with my commit just being reverted if it's the easiest fix.

MikeMcQuaid avatar Sep 16 '22 07:09 MikeMcQuaid

@danielnachun I changed it in https://github.com/Homebrew/homebrew-core/commit/6c2842a7dcda0cf65dc31394253f7f34053b3f1a and @carlocab gave it a โœ….

Yes, I was aware of the motivation for making it a runtime dependency when I approved 6c2842a7dcda0cf65dc31394253f7f34053b3f1a, because I do think that it's not a good idea to stick it all over the dep tree, and adding it there feels a bit heavy-handed.

I won't argue if you'd like to revert it, but I'd like to see us explore more elegant solutions to this.

carlocab avatar Sep 16 '22 09:09 carlocab

Yes, I was aware of the motivation for making it a runtime dependency when I approved 6c2842a, because I do think that it's not a good idea to stick it all over the dep tree, and adding it there feels a bit heavy-handed.

Can you explain what you would like? Do you think it should be a :build dependency on glibc and added on individual formulae, a runtime dependency on glibc or something else? If, what is that something else ๐Ÿ˜

MikeMcQuaid avatar Sep 16 '22 11:09 MikeMcQuaid

it should be a :build dependency on glibc and added on individual formulae, a runtime dependency on glibc

I'm open to this. My concern is that it feels like the dependency should depend on what's available on the host system: if the host provides kernel headers that are new enough (our CI should, IIUC), then we should use those.

or something else? If, what is that something else ๐Ÿ˜

No specific ideas yet! But let me think a bit more about this...

carlocab avatar Sep 16 '22 15:09 carlocab

For now we should revert it, but I'm not opposed to finding a better long term solution as well. I think it will be quite difficult to verify the host Linux actually has new enough headers.

Another option is to vendor [email protected] in glibc so it doesn't add to the dependency tree. Not sure what we think about this, but the kernel headers must be pinned to this version anyway.

danielnachun avatar Sep 16 '22 20:09 danielnachun

My concern is that it feels like the dependency should depend on what's available on the host system: if the host provides kernel headers that are new enough (our CI should, IIUC), then we should use those.

Agreed.

Another option is to vendor [email protected] in glibc so it doesn't add to the dependency tree. Not sure what we think about this, but the kernel headers must be pinned to this version anyway.

This is another reasonable option.

MikeMcQuaid avatar Sep 18 '22 12:09 MikeMcQuaid

I've made [email protected] a runtime dependency again for now at least. If there's a motivation for doing so another way in the long term, please open a brew issue.

I think the only thing left here is the ruby BFS error.

Bo98 avatar Sep 19 '22 07:09 Bo98

This might be the same issue? CentOS 7, no sudo, fresh-ish brew install, [email protected] installed. perl built fine but ruby failed:

ad-user-ads-11 ~ โ˜… brew install vim
... [buncha other downloads] ...
Warning: Building ruby from source as the bottle needs:
- HOMEBREW_CELLAR: /home/linuxbrew/.linuxbrew/Cellar (yours is /data/shared/lusers/jacktose/.linuxbrew/Cellar)
- HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew (yours is /data/shared/lusers/jacktose/.linuxbrew)
==> Downloading https://rubygems.org/rubygems/rubygems-3.3.11.tgz
######################################################################## 100.0%
==> Downloading https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
######################################################################## 100.0%
Warning: Building vim from source as the bottle needs:
- HOMEBREW_CELLAR: /home/linuxbrew/.linuxbrew/Cellar (yours is /data/shared/lusers/jacktose/.linuxbrew/Cellar)
- HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew (yours is /data/shared/lusers/jacktose/.linuxbrew)
==> Downloading https://github.com/vim/vim/archive/v9.0.0350.tar.gz
Already downloaded: /usr/lusers/jacktose/.cache/Homebrew/downloads/edc8a60e1d9e052fdbc8f2f333b8fc7df498eb6afd582a86fdbf2a44b997ba86--vim-9.0.0350.tar.gz
==> Installing dependencies for vim: icu4c, pkg-config, gpatch, ncurses, readline, libxml2, gettext, lua, ca-certificates, [email protected], berkeley-db, gdbm, expat, libxcrypt, perl, mpdecimal, sqlite, bzip2, libffi, unzip, m4, bison, krb5, libtirpc, libnsl, [email protected], libyaml and ruby
... [buncha other installsโ€”some bottled, some builtโ€”including successful `perl` build] ...
==> Installing vim dependency: ruby
==> ./configure --prefix=/data/shared/lusers/jacktose/.linuxbrew/Cellar/ruby/3.1.2_1 --enable-shared --with-sitedir=/data/shared/lusers/jacktose/.linuxbrew/lib/ruby/site_ruby --with-vendordir=/data/shared/lusers/jacktose/.linuxbrew/
==> make
==> make install
Last 15 lines from /usr/lusers/jacktose/.cache/Homebrew/Logs/ruby/03.make:
        from /tmp/ruby-20220919-1587-1i10tuf/ruby-3.1.2/lib/rubygems/ext/builder.rb:195:in `block in build_extensions'
        from /tmp/ruby-20220919-1587-1i10tuf/ruby-3.1.2/lib/rubygems/ext/builder.rb:192:in `each'
        from /tmp/ruby-20220919-1587-1i10tuf/ruby-3.1.2/lib/rubygems/ext/builder.rb:192:in `build_extensions'
        from /tmp/ruby-20220919-1587-1i10tuf/ruby-3.1.2/lib/rubygems/installer.rb:853:in `build_extensions'
        from /tmp/ruby-20220919-1587-1i10tuf/ruby-3.1.2/lib/rubygems/installer.rb:328:in `install'
        from ./tool/rbinstall.rb:899:in `block in install'
        from ./tool/rbinstall.rb:713:in `no_write'
        from ./tool/rbinstall.rb:899:in `install'
        from ./tool/rbinstall.rb:1068:in `block (2 levels) in <main>'
        from ./tool/rbinstall.rb:1043:in `foreach'
        from ./tool/rbinstall.rb:1043:in `block in <main>'
        from ./tool/rbinstall.rb:1127:in `block in <main>'
        from ./tool/rbinstall.rb:1124:in `each'
        from ./tool/rbinstall.rb:1124:in `<main>'
make: *** [do-install-all] Error 1

READ THIS: https://docs.brew.sh/Troubleshooting

These open issues may also help:
perl, ruby: failed to build from source on Ubuntu 20.04 LTS https://github.com/Homebrew/homebrew-core/issues/110558

Note that ruby was successful for me in a previous brew instance on this machine: Built from source on 2022-08-29 at 18:21:31, but I know there were changes to gcc & glibc since then.

I'm happy to grab full output & logs, and/or replicate this in a totally fresh brew instance, if it helps.

jacktose avatar Sep 19 '22 20:09 jacktose

I deleted --enable-shared in brew edit ruby and it worked.

rishabh-ranjan avatar Sep 22 '22 21:09 rishabh-ranjan

I deleted --enable-shared in brew edit ruby and it worked.

This worked for me too.

lewis6991 avatar Sep 23 '22 11:09 lewis6991

I deleted --enable-shared in brew edit ruby and it worked.

This worked for me as well. Thanks!

BenjaminTJohnson avatar Sep 29 '22 17:09 BenjaminTJohnson

I deleted --enable-shared in brew edit ruby and it worked.

This seems to break vim

homebrew/bin/vim: error while loading shared libraries: libruby.so.3.1: cannot open shared object file: No such file or directory

user799595 avatar Oct 04 '22 20:10 user799595

There is clearly a problem with how libruby.so.3.1 is being built when using brewed glibc. I haven't been able to hunt down exactly what it is, but I suspect there is a shim bypass or some other missing/incorrect flag.

danielnachun avatar Oct 04 '22 22:10 danielnachun

There is clearly a problem with how libruby.so.3.1 is being built when using brewed glibc.

Error
Building native extensions. This could take a while...
/tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/lib/rubygems/ext/builder.rb:95:in `run': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)

    current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/bin/ruby --disable\\=gems -I/home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/x86_64-linux -I /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/lib -r ./siteconf20221005-6511-s98q6z.rb extconf.rb
creating Makefile

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make DESTDIR\\= clean
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make DESTDIR\\=
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221005-25868-115acq7/ruby-3.1.2/libruby.so.3.1.2)

make failed, exit code 1
Makefile

SHELL = /bin/sh

# V=0 quiet, V=1 verbose.  other values don't work.
V = 0
V0 = $(V:0=)
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@ :)
ECHO = $(ECHO1:0=@ echo)
NULLCMD = :

#### Start of system configuration section. ####

srcdir = .
topdir = /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0
hdrdir = $(topdir)
arch_hdrdir = /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux
PATH_SEPARATOR = :
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
prefix = $(DESTDIR)/home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
rubyarchprefix = $(rubylibprefix)/$(arch)
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
exec_prefix = $(prefix)
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
vendorarchdir = $(vendorlibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendordir = $(DESTDIR)/home/PanXuehai/Projects/brew/lib/ruby/vendor_ruby
sitearchdir = $(DESTDIR)./.gem.20221005-27613-85rx5b
sitelibdir = $(DESTDIR)./.gem.20221005-27613-85rx5b
sitedir = $(DESTDIR)/home/PanXuehai/Projects/brew/lib/ruby/site_ruby
rubyarchdir = $(rubylibdir)/$(arch)
rubylibdir = $(rubylibprefix)/$(ruby_version)
sitearchincludedir = $(includedir)/$(sitearch)
archincludedir = $(includedir)/$(arch)
sitearchlibdir = $(libdir)/$(sitearch)
archlibdir = $(libdir)/$(arch)
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(datarootdir)/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(prefix)/include
runstatedir = $(localstatedir)/run
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
archdir = $(rubyarchdir)


CC_WRAPPER = 
CC = gcc-12
CXX = g++-12
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static $(MAINLIBS)
empty =
OUTFLAG = -o $(empty)
COUTFLAG = -o $(empty)
CSRCFLAG = $(empty)

RUBY_EXTCONF_H = 
cflags   = $(optflags) $(debugflags) $(warnflags)
cxxflags = 
optflags = -O3 -fno-fast-math
debugflags = -ggdb3
warnflags = -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef
cppflags = 
CCDLFLAGS = -fPIC
CFLAGS   = $(CCDLFLAGS) $(cflags)  -fPIC $(ARCH_FLAG)
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
DEFS     = 
CPPFLAGS =   -I/home/PanXuehai/Projects/brew/opt/libyaml/include -I/home/PanXuehai/Projects/brew/opt/[email protected]/include -I/home/PanXuehai/Projects/brew/opt/readline/include $(DEFS) $(cppflags)
CXXFLAGS = $(CCDLFLAGS)  $(ARCH_FLAG)
ldflags  = -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -L/home/PanXuehai/Projects/brew/opt/libyaml/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/libyaml/lib -L/home/PanXuehai/Projects/brew/opt/[email protected]/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/[email protected]/lib -L/home/PanXuehai/Projects/brew/opt/readline/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/readline/lib -Wl,--no-as-needed
dldflags = -Wl,--compress-debug-sections=zlib -L/home/PanXuehai/Projects/brew/opt/libyaml/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/libyaml/lib -L/home/PanXuehai/Projects/brew/opt/[email protected]/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/[email protected]/lib -L/home/PanXuehai/Projects/brew/opt/readline/lib  -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/readline/lib 
ARCH_FLAG = 
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
LDSHARED = $(CC) -shared
LDSHAREDXX = $(CXX) -shared
AR = gcc-ar-12
EXEEXT = 

RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
RUBY_SO_NAME = ruby
RUBYW_INSTALL_NAME = 
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
RUBYW_BASE_NAME = rubyw
RUBY_BASE_NAME = ruby

arch = x86_64-linux
sitearch = $(arch)
ruby_version = 3.1.0
ruby = $(bindir)/$(RUBY_BASE_NAME)
RUBY = $(ruby)
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h

RM = rm -f
RM_RF = rm -fr
RMDIRS = rmdir --ignore-fail-on-non-empty -p
MAKEDIRS = /usr/bin/mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
TOUCH = exit >

#### End of system configuration section. ####

preload = 
libpath = . $(libdir) /home/PanXuehai/Projects/brew/opt/libyaml/lib /home/PanXuehai/Projects/brew/opt/[email protected]/lib /home/PanXuehai/Projects/brew/opt/readline/lib
LIBPATH =  -L. -L$(libdir) -Wl,-rpath,$(libdir) -L/home/PanXuehai/Projects/brew/opt/libyaml/lib -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/libyaml/lib -L/home/PanXuehai/Projects/brew/opt/[email protected]/lib -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/[email protected]/lib -L/home/PanXuehai/Projects/brew/opt/readline/lib -Wl,-rpath,/home/PanXuehai/Projects/brew/opt/readline/lib
DEFFILE = 

CLEANFILES = mkmf.log
DISTCLEANFILES = 
DISTCLEANDIRS = 

extout = 
extout_prefix = 
target_prefix = 
LOCAL_LIBS = 
LIBS = $(LIBRUBYARG_SHARED)  -lm  -lc
ORIG_SRCS = constants.c lexer.c lexstate.c location.c main.c parser.c parserstate.c ruby_objs.c unescape.c
SRCS = $(ORIG_SRCS) 
OBJS = constants.o lexer.o lexstate.o location.o main.o parser.o parserstate.o ruby_objs.o unescape.o
HDRS = $(srcdir)/constants.h $(srcdir)/lexer.h $(srcdir)/location.h $(srcdir)/parser.h $(srcdir)/parserstate.h $(srcdir)/rbs_extension.h $(srcdir)/ruby_objs.h
LOCAL_HDRS = 
TARGET = rbs_extension
TARGET_NAME = rbs_extension
TARGET_ENTRY = Init_$(TARGET_NAME)
DLLIB = $(TARGET).so
EXTSTATIC = 
STATIC_LIB = 

TIMESTAMP_DIR = .
BINDIR        = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
HDRDIR        = $(sitehdrdir)$(target_prefix)
ARCHHDRDIR    = $(sitearchhdrdir)$(target_prefix)
TARGET_SO_DIR =
TARGET_SO     = $(TARGET_SO_DIR)$(DLLIB)
CLEANLIBS     = $(TARGET_SO) false
CLEANOBJS     = *.o  *.bak

all:    $(DLLIB)
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-static clean-rb

clean-static::
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-static clean-rb-default clean-rb
		-$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time

distclean-rb-default::
distclean-rb::
distclean-so::
distclean-static::
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
		-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
		-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
		-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true

realclean: distclean
install: install-so install-rb

install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.time
	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
clean-static::
	-$(Q)$(RM) $(STATIC_LIB)
install-rb: pre-install-rb do-install-rb install-rb-default
install-rb-default: pre-install-rb-default do-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
do-install-rb:
do-install-rb-default:
pre-install-rb-default:
	@$(NULLCMD)
$(TIMESTAMP_DIR)/.sitearchdir.time:
	$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
	$(Q) $(TOUCH) $@

site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb

.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S

.cc.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cc.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.mm.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.mm.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.cxx.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cxx.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.cpp.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cpp.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.c.o:
	$(ECHO) compiling $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.c.S:
	$(ECHO) translating $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.m.o:
	$(ECHO) compiling $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.m.S:
	$(ECHO) translating $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

$(TARGET_SO): $(OBJS) Makefile
	$(ECHO) linking shared-object $(DLLIB)
	-$(Q)$(RM) $(@)
	$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)



$(OBJS): $(HDRS) $(ruby_headers)

It seems that the extension Makefile accidentally used the system linker rather than brewed glibc. But I haven't found any suspicious command in the Makefile. Also, I have checked all existing .so files be when the error raises are using brewed libc.so.

Result inside brew install --debug shell:

$ echo "CC='${CC}' CXX='${CXX}' LD='${LD}'"
CC='gcc-12' CXX='g++-12' LD=''

$ which -a gcc-12
/home/PanXuehai/Projects/brew/Library/Homebrew/shims/linux/super/gcc-12
/home/PanXuehai/Projects/brew/opt/gcc/bin/gcc-12

$ which -a g++-12
/home/PanXuehai/Projects/brew/Library/Homebrew/shims/linux/super/g++-12
/home/PanXuehai/Projects/brew/opt/gcc/bin/g++-12

$ which -a ld
/home/PanXuehai/Projects/brew/Library/Homebrew/shims/linux/super/ld
/home/PanXuehai/Projects/brew/opt/binutils/bin/ld
/usr/bin/ld
/bin/ld

$ which -a ldd
/home/PanXuehai/Projects/brew/opt/glibc/bin/ldd
/usr/bin/ldd
/bin/ldd

$ ldd libruby.so.3.1
        linux-vdso.so.1 (0x00007ffc2b7d8000)
        libz.so.1 => /home/PanXuehai/Projects/brew/opt/zlib/lib/libz.so.1 (0x00007f4a12641000)
        libcrypt.so.2 => /home/PanXuehai/Projects/brew/opt/libxcrypt/lib/libcrypt.so.2 (0x00007f4a12400000)
        libm.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libm.so.6 (0x00007f4a1231e000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f4a1210c000)
        /home/PanXuehai/Projects/brew/Cellar/glibc/2.35_1/lib64/ld-linux-x86-64.so.2 (0x00007f4a12a2b000)

$ /usr/bin/ldd libruby.so.3.1
        linux-vdso.so.1 (0x00007ffdbe743000)
        libz.so.1 => /home/PanXuehai/Projects/brew/opt/zlib/lib/libz.so.1 (0x00007fbbd1c9a000)
        libcrypt.so.2 => /home/PanXuehai/Projects/brew/opt/libxcrypt/lib/libcrypt.so.2 (0x00007fbbd1a60000)
        libm.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libm.so.6 (0x00007fbbd197c000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007fbbd176a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fbbd2084000)
$ find . -name '*.so' | xargs -L 1 ldd | grep 'libc.so'
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007fe9e4067000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007ff296433000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f7e70868000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f85f73fc000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007feb4ab1f000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f2ff35f5000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f8635246000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f03af13c000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f5616cd7000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007f9a754c9000)
        ...
`./configure --help`
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-load-relative  resolve load paths at run time
  --disable-werror        don't make warnings into errors even if a compiler
                          support -Werror feature [[disabled by default unless
                          development version]]
  --disable-fortify-source
                          disable -D_FORTIFY_SOURCE=2 option, which causes
                          link error on mingw
  --disable-largefile     omit support for large files
  --enable-mathn          enable canonicalization for mathn
  --enable-setreuid       use setreuid()/setregid() according to need even if
                          obsolete
  --enable-rpath          embed run path into extension libraries. enabled by
                          default on ELF platforms
  --enable-multiarch      enable multiarch compatible directories
  --enable-shared         build a shared library for Ruby
  --disable-pie           disable PIE feature
  --enable-dtrace         enable DTrace for tracing inside ruby. enabled by
                          default on systems having dtrace
  --enable-gcov           enable coverage measurement by gcov
  --disable-install-doc   do not install either rdoc indexes or C API
                          documents during install
  --disable-install-rdoc  do not install rdoc indexes during install
  --disable-install-capi  do not install C API documents during install
  --disable-jit-support   disable JIT features
  --disable-install-static-library
                          do not install static ruby library
  --disable-dln           disable dynamic link feature
  --enable-debug-env      enable RUBY_DEBUG environment variable
  --disable-rubygems      disable rubygems by default

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-baseruby=RUBY    use RUBY as baseruby; RUBY is the pathname of ruby
  --without-git           never use git
  --without-gcc           never use gcc
  --with-os-version-style=TYPE
                          OS version number for target and target_os [[full]]
                          (full|teeny|minor+0|minor|major+0|major|none)
  --with-arch=ARCHS       build an Apple/NeXT Multi Architecture Binary (MAB);
                          ARCHS is a comma-delimited list of architectures for
                          which to build; if this option is disabled or
                          omitted entirely, then the package will be built
                          only for the target platform
  --with-compress-debug-sections=type
                          enable debug section compression
  --with-opt-dir=DIR-LIST add optional headers and libraries directories
                          separated by $PATH_SEPARATOR
  --with-winnt-ver=0xXXXX target Windows NT version (default to 0x0600)
  --without-gmp           disable GNU GMP to accelerate Bignum operations
  --with-jemalloc         use jemalloc allocator
  --with-coroutine=IMPLEMENTATION
                          specify the coroutine implementation to use
  --with-dln-a-out        dln_a_out is deprecated
  --without-mjit-tabs     expand tabs in mjit header
  --without-valgrind      disable valgrind memcheck support
  --with-ext=EXTS         pass to --with-ext option of extmk.rb
  --with-out-ext=EXTS     pass to --without-ext option of extmk.rb
  --with-static-linked-ext
                          link external modules statically
  --with-setup=SETUP      use extension libraries setup
  --with-rubylibprefix=DIR
                          prefix for ruby libraries [[LIBDIR/RUBY_BASE_NAME]]
  --with-soname=SONAME    base name of shared library
  --with-setjmp-type      select setjmp type
  --with-rdoc=ri,html     comma/space separated list of RDoc formats to
                          install
  --with-thread=IMPLEMENTATION
                          specify the thread implementation to use
  --with-rubyarchprefix=DIR
                          prefix for architecture dependent ruby libraries
                          [[RUBYLIBPREFIX/ARCH]]
  --with-rubysitearchprefix=DIR
                          prefix for architecture dependent site libraries
                          [[RUBYLIBPREFIX/SITEARCH]]
  --with-ridir=DIR        ri documentation [[DATAROOTDIR/ri]]
  --with-ruby-version=STR ruby version string for version specific directories
                          [[full]] (full|minor|STR)
  --with-sitedir=DIR      site libraries in DIR [[RUBY_LIB_PREFIX/site_ruby]],
                          "no" to disable site directory
  --with-sitearchdir=DIR  architecture dependent site libraries in DIR
                          [[SITEDIR/SITEARCH]], "no" to disable site directory
  --with-vendordir=DIR    vendor libraries in DIR
                          [[RUBY_LIB_PREFIX/vendor_ruby]], "no" to disable
                          vendor directory
  --with-vendorarchdir=DIR
                          architecture dependent vendor libraries in DIR
                          [[VENDORDIR/SITEARCH]], "no" to disable vendor
                          directory
  --with-search-path=DIR  specify the additional search path
  --with-rubyhdrdir=DIR   core headers in DIR
                          [[INCLUDEDIR/RUBY_BASE_NAME-RUBY_VERSION]]
  --with-rubyarchhdrdir=DIR
                          architecture dependent core headers in DIR
                          [[$(rubyhdrdir)/$(arch)]]
  --with-sitehdrdir=DIR   core site headers in DIR [[RUBYHDRDIR/site_ruby]]
  --with-sitearchhdrdir=DIR
                          architecture dependent core site headers in DIR
                          [[RUBYHDRDIR/site_ruby]]
  --with-vendorhdrdir=DIR core vendor headers in DIR
                          [[RUBYHDRDIR/vendor_ruby]]
  --with-vendorarchhdrdir=DIR
                          architecture dependent core vendor headers in DIR
                          [[RUBYHDRDIR/vendor_ruby]]
  --with-mantype=TYPE     specify man page type; TYPE is one of man and doc
  --with-ruby-pc=FILENAME pc file basename
  --with-destdir=DESTDIR  specify default directory to install

Some influential environment variables:
  cflags      additional CFLAGS (ignored when CFLAGS is given)
  cppflags    additional CPPFLAGS (ignored when CPPFLAGS is given)
  cxxflags    additional CXXFLAGS (ignored when CXXFLAGS is given)
  AR          Archiver command
  AS          Assembler command
  CC          C compiler command
  CXX         C++ compiler command
  LD          Linker command
  NM          Symbol list command
  OBJCOPY     Objcopy command
  OBJDUMP     Objdump command
  RANLIB      Ranlib command
  STRIP       Strip command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CXXFLAGS    C++ compiler flags
  CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.

XuehaiPan avatar Oct 05 '22 14:10 XuehaiPan

Can you try getting make to build verbosely? Probably with V=1.

carlocab avatar Oct 05 '22 16:10 carlocab

Can you try getting make to build verbosely? Probably with V=1.

The Makefile is auto-generated, it will be overwritten each time. I add V=1 to the make arguments in lib/rubygems/ext/builder.rb then rerun make install. It reports the same error:

/tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:97:in `run': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)

    current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/bin/ruby --disable\\=gems -I/home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/3.1.0/x86_64-linux -I /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib -r ./siteconf20221005-107720-v7uly3.rb extconf.rb
creating Makefile

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make V\\=1 DESTDIR\\= clean
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make V\\=1 DESTDIR\\=
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)

make failed, exit code 1

Gem files will remain installed in /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0 for inspection.
Results logged to /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/rbs-2.1.0/gem_make.out
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:46:in `block in make'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:37:in `each'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:37:in `make'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/tempfile.rb:317:in `open'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/ext_conf_builder.rb:26:in `build'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:163:in `build_extension'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:197:in `block in build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:194:in `each'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:194:in `build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/installer.rb:853:in `build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/installer.rb:328:in `install'
        from ./tool/rbinstall.rb:899:in `block in install'
        from ./tool/rbinstall.rb:713:in `no_write'
        from ./tool/rbinstall.rb:899:in `install'
        from ./tool/rbinstall.rb:1068:in `block (2 levels) in <main>'
        from ./tool/rbinstall.rb:1043:in `foreach'
        from ./tool/rbinstall.rb:1043:in `block in <main>'
        from ./tool/rbinstall.rb:1127:in `block in <main>'
        from ./tool/rbinstall.rb:1124:in `each'
        from ./tool/rbinstall.rb:1124:in `<main>'
/tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:97:in `run': make failed, exit code 1 (Gem::InstallError)
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:46:in `block in make'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:37:in `each'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:37:in `make'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/tempfile.rb:317:in `open'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/ext_conf_builder.rb:26:in `build'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:163:in `build_extension'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:197:in `block in build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:194:in `each'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/ext/builder.rb:194:in `build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/installer.rb:853:in `build_extensions'
        from /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/lib/rubygems/installer.rb:328:in `install'
        from ./tool/rbinstall.rb:899:in `block in install'
        from ./tool/rbinstall.rb:713:in `no_write'
        from ./tool/rbinstall.rb:899:in `install'
        from ./tool/rbinstall.rb:1068:in `block (2 levels) in <main>'
        from ./tool/rbinstall.rb:1043:in `foreach'
        from ./tool/rbinstall.rb:1043:in `block in <main>'
        from ./tool/rbinstall.rb:1127:in `block in <main>'
        from ./tool/rbinstall.rb:1124:in `each'
        from ./tool/rbinstall.rb:1124:in `<main>'
make: *** [uncommon.mk:383: do-install-all] Error 1

However, if I ran the errored commands above manually, no errors arise:

$ cd /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension

$ /usr/bin/make V\\=1 DESTDIR\\= clean

$ /usr/bin/make V\\=1 DESTDIR\\=
compiling constants.c
compiling lexer.c
compiling lexstate.c
compiling location.c
compiling main.c
compiling parser.c
compiling parserstate.c
compiling ruby_objs.c
compiling unescape.c
linking shared-object rbs_extension.so

$ ldd rbs_extension.so
        linux-vdso.so.1 (0x00007ffffc34c000)
        libruby.so.3.1 => /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/libruby.so.3.1 (0x00007fb6cbb3b000)
        libm.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libm.so.6 (0x00007fb6cba59000)
        libc.so.6 => /home/PanXuehai/Projects/brew/opt/glibc/lib/libc.so.6 (0x00007fb6cb845000)
        libz.so.1 => /home/PanXuehai/Projects/brew/opt/zlib/lib/libz.so.1 (0x00007fb6cb82a000)
        libcrypt.so.2 => /home/PanXuehai/Projects/brew/opt/libxcrypt/lib/libcrypt.so.2 (0x00007fb6cb400000)
        /home/PanXuehai/Projects/brew/Cellar/glibc/2.35_1/lib64/ld-linux-x86-64.so.2 (0x00007fb6cbf1a000)

XuehaiPan avatar Oct 05 '22 17:10 XuehaiPan

Can you attach the log from /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/rbs-2.1.0/gem_make.out?

carlocab avatar Oct 05 '22 18:10 carlocab

Can you attach the log from /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/rbs-2.1.0/gem_make.out?

It's exactly the same as the console output:

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make V\\=1 DESTDIR\\= clean
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)

current directory: /home/PanXuehai/Projects/brew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/usr/bin/make V\\=1 DESTDIR\\=
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/make: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221006-90311-w15in5/ruby-3.1.2/libruby.so.3.1.2)

XuehaiPan avatar Oct 06 '22 04:10 XuehaiPan

If I had to guess, this is occurring because either the -Wl,--dynamic_linker=HOMEBREW_PREFIX/ld.so argument is being ignored, or isn't even being passed at all.

danielnachun avatar Oct 06 '22 05:10 danielnachun

If I had to guess, this is occurring because either the -Wl,--dynamic_linker=HOMEBREW_PREFIX/ld.so argument is being ignored, or isn't even being passed at all.

Shouldn't that be -Wl,--dynamic-linker=HOMEBREW_PREFIX/opt/glibc/bin/ld.so?

carlocab avatar Oct 06 '22 06:10 carlocab

Actually it's -Wl,--dynamic-linker=HOMEBREW_PREFIX/lib/ld.so and it's either a symlink to HOMEBREW_PREFIX/opt/glibc/bin/ld.so if brewed glibc is installed or the host ld.so if using the host glibc. But the weird thing is that it is added by the superenv so it's supposed to be used regardless of whether you build with the host GCC or brewed GCC.

We should see what the make.cc logs look like to confirm that the flag is actually being added. It's possible that for some reason the superenv doesn't think the linker is being invoked when that the gem is being linked and doesn't add the right LDFLAGS. But that's just speculation.

danielnachun avatar Oct 06 '22 06:10 danielnachun

I was able to let it prompt more information by:

  1. Use brewed make and bash to interpret Makefiles
brew install make bash gcc@11
  1. Add the following lines in ruby.rb to set V = 1:
# Formula/ruby.rb

  def install
    inreplace "lib/mkmf.rb" do |s|
      s.gsub!(%r{^V = 0$}, 'V = 1')
      s.gsub!(%r{^SHELL = /bin/sh$}, "SHELL = #{Formula["bash"].opt_bin}/bash")
      # s.gsub!(%r{^all:}, "print-env:\n\t/usr/bin/env\nall: print-env ")
    end
  
   ...
  1. Run:
brew install --verbose --build-from-source ruby
Output
current directory: /home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/linuxbrew/.linuxbrew/opt/make/bin/make DESTDIR\\= clean
make[1]: Entering directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'
rm -f 
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: [Makefile:193: clean-static] Error 1 (ignored)
rm -fr rbs_extension.so false *.o  *.bak mkmf.log .*.time
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: [Makefile:176: clean] Error 1 (ignored)
make[1]: Leaving directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'

current directory: /home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/linuxbrew/.linuxbrew/opt/make/bin/make DESTDIR\\=
make[1]: Entering directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o constants.o -c constants.c
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o lexer.o -c lexer.c
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o lexstate.o -c lexstate.c
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o location.o -c location.c
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o main.o -c main.c
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o parser.o -c parser.c
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o parserstate.o -c parserstate.c
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
make[1]: *** [Makefile:246: constants.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: lexer.o] Error 1
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o ruby_objs.o -c ruby_objs.c
make[1]: *** [Makefile:246: lexstate.o] Error 1
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
gcc-11 -I. -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/x86_64-linux -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0/ruby/backward -I/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/include/ruby-3.1.0 -I. -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/[email protected]/include -I/home/linuxbrew/.linuxbrew/opt/readline/include   -fPIC -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC  -o unescape.o -c unescape.c
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: location.o] Error 1
make[1]: *** [Makefile:246: main.o] Error 1
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: parserstate.o] Error 1
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: parser.o] Error 1
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: ruby_objs.o] Error 1
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-9328-15prs52/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:246: unescape.o] Error 1
make[1]: Leaving directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'

make failed, exit code 2

It failed to run the rm command in the Makefile (this error has been ignored). Also, shims/linux/super/gcc-11 failed to call the /bin/bash command and returned an error.

  1. Add target print-env to all:
# Formula/ruby.rb

  def install
    inreplace "lib/mkmf.rb" do |s|
      s.gsub!(%r{^V = 0$}, 'V = 1')
      s.gsub!(%r{^SHELL = /bin/sh$}, "SHELL = #{Formula["bash"].opt_bin}/bash")
      s.gsub!(%r{^all:}, "print-env:\n\t/usr/bin/env\nall: print-env ")  # <= uncomment this line
    end
  
   ...
  1. Run:
brew install --verbose --build-from-source ruby
Output
current directory: /home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/linuxbrew/.linuxbrew/opt/make/bin/make DESTDIR\\= clean
make[1]: Entering directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'
rm -f 
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
make[1]: [Makefile:195: clean-static] Error 1 (ignored)
rm -fr rbs_extension.so false *.o  *.bak mkmf.log .*.time
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
make[1]: [Makefile:178: clean] Error 1 (ignored)
make[1]: Leaving directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'

current directory: /home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension
/home/linuxbrew/.linuxbrew/opt/make/bin/make DESTDIR\\=
make[1]: Entering directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'
/usr/bin/env
/home/linuxbrew/.linuxbrew/opt/bash/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/usr/bin/env: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/env: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
/usr/bin/env: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/ruby-20221027-25025-164nazh/ruby-3.1.2/libruby.so.3.1.2)
make[1]: *** [Makefile:167: print-env] Error 1
make[1]: Leaving directory '/home/linuxbrew/.linuxbrew/Cellar/ruby/3.1.2_1/lib/ruby/gems/3.1.0/gems/rbs-2.1.0/ext/rbs_extension'

make failed, exit code 2

As we can see, both rm and /usr/bin/env failed.


The failed make command is called by /tmp/BUILD_DIR/lib/rubygems/ext/builder.rb:

  def self.make(dest_path, results, make_dir = Dir.pwd)
    ...

    ['clean', '', 'install'].each do |target|
      # Pass DESTDIR via command line to override what's in MAKEFLAGS
      cmd = [
        *make_program,
        destdir,
        target,
      ].reject(&:empty?)
      begin
        run(cmd, results, "make #{target}".rstrip, make_dir)
      rescue Gem::InstallError
        raise unless target == 'clean' # ignore clean failure
      end
    end
  end

  def self.run(command, results, command_name = nil, dir = Dir.pwd)
    verbose = Gem.configuration.really_verbose

    begin
      rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
      if verbose
        puts("current directory: #{dir}")
        p(command)
      end
      results << "current directory: #{dir}"
      require "shellwords"
      results << command.shelljoin

      require "open3"
      # Set $SOURCE_DATE_EPOCH for the subprocess.
      env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}
      output, status = begin
                         Open3.capture2e(env, *command, :chdir => dir)
                       rescue => error
                         raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
                       end
      if verbose
        puts output
      else
        results << output
      end
    ensure
      ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
    end

    unless status.success?
      results << "Building has failed. See above output for more information on the failure." if verbose
    end

    yield(status, results) if block_given?

    unless status.success?
      exit_reason =
        if status.exited?
          ", exit code #{status.exitstatus}"
        elsif status.signaled?
          ", uncaught signal #{status.termsig}"
        end

      raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}"
    end
  end

I suspect there is something broken with the Open3.capture2e command or the env environment variable.

UPDATE: adding the following line is not working.

-     env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}
+     env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}.merge(ENV)
      output, status = begin
                         Open3.capture2e(env, *command, :chdir => dir)
                       rescue => error
                         raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
                       end

XuehaiPan avatar Oct 27 '22 12:10 XuehaiPan

I suspect the built ruby's Open3.capture2e is broken, which is linked against the brewed glibc. It failed to call system's /usr/bin/make, /bin/bash, /usr/bin/env and rm, but can successfully invoke brewed make and bash. Unfortunately, the shimmed gcc-11 calls /bin/bash and it fails.

Open3.capture2e calls glibc's fork or vfork declared in unistd.h.

XuehaiPan avatar Oct 27 '22 12:10 XuehaiPan

I successfully built ruby from the source by disabling the bundled gems rbs and debug. Disable it by comment these two lines in gems/bundled_gems:

# Formula/ruby.rb

  def install
    inreplace "gems/bundled_gems" do |s|
      s.gsub!(/^rbs /, '# rbs ')
      s.gsub!(/^debug /, '# debug ')
    end

    ...
  end

The rbs and debug extensions are the only two bundled gems that have C code. They need the Homebrew's shimmed compiler. The source code can be found at {srcdir}/.bundle/gems/rbs-2.1.0 and {srcdir}/.bundle/gems/debug-1.4.0.

XuehaiPan avatar Oct 30 '22 15:10 XuehaiPan