Skip to content

Commit d50ca32

Browse files
committed
Recompile psych as it can be necessary on macOS due to no proper system package manager
* Notably Homebrew is not in the default library path on darwin-aarch64: Homebrew/brew#13481 So soname-based lookup just does not work on macOS.
1 parent ea6537d commit d50ca32

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

doc/user/installing-libyaml.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ permalink: /reference-manual/ruby/InstallingLibYAML/
88

99
TruffleRuby requires to have `libyaml` installed, much like CRuby 3.2+ and Psych 5+.
1010

11+
If you experience `psych`-related errors saying it cannot find `libyaml`, it might help to recompile the `psych` gem by running `lib/truffle/post_install_hook.sh`.
12+
This is done automatically by Ruby managers, and mentioned in the post-install message when installing TruffleRuby via `gu install` in GraalVM.
13+
1114
### Fedora-based: RHEL, Oracle Linux, etc
1215

1316
```bash

lib/truffle/post_install_hook.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# Hook run after extraction in the installation directory by a Ruby installer.
33
# Useful to perform tasks that depend on the user machine and
4-
# cannot be generally done in advance before building the release tarball.
4+
# cannot be generally done in advance on another machine.
55

66
set -e
77

@@ -15,24 +15,38 @@ export TRUFFLERUBYOPT="--disable-gems $TRUFFLERUBYOPT"
1515

1616
cd "$root"
1717

18-
function recompile_openssl() {
19-
cd src/main/c/openssl
18+
function recompile() {
19+
ext="$1"
20+
cd "src/main/c/$ext"
2021
truffleruby -w extconf.rb
2122
if [ -z "$CORES" ]; then
2223
CORES=$(getconf _NPROCESSORS_ONLN || echo 1)
2324
fi
2425
make "--jobs=$CORES"
25-
cp "openssl.$(truffleruby -rrbconfig -e "print RbConfig::CONFIG['DLEXT']")" "$root/lib/mri"
26+
cp "$ext.$(truffleruby -rrbconfig -e "print RbConfig::CONFIG['DLEXT']")" "$root/lib/mri"
27+
cd "$root"
28+
echo
2629
}
2730

2831
if [ "$TRUFFLERUBY_RECOMPILE_OPENSSL" == "false" ]; then
29-
echo "Skipping recompilation of the OpenSSL extension (TRUFFLERUBY_RECOMPILE_OPENSSL=false)"
32+
echo "Skipping recompilation of the OpenSSL C extension (TRUFFLERUBY_RECOMPILE_OPENSSL=false)"
3033
elif [ "$TRUFFLERUBY_RECOMPILE_OPENSSL" == "true" ]; then
3134
echo "Recompiling the OpenSSL C extension (TRUFFLERUBY_RECOMPILE_OPENSSL=true)"
32-
recompile_openssl
35+
recompile openssl
3336
else
3437
echo "Recompiling the OpenSSL C extension (against the installed libssl)"
35-
recompile_openssl
38+
recompile openssl
39+
fi
40+
41+
# Recompiling psych is needed on macOS if a non-default Homebrew prefix or not using Homebrew (e.g. MacPorts)
42+
if [ "$TRUFFLERUBY_RECOMPILE_PSYCH" == "false" ]; then
43+
echo "Skipping recompilation of the Psych C extension (TRUFFLERUBY_RECOMPILE_PSYCH=false)"
44+
elif [ "$TRUFFLERUBY_RECOMPILE_PSYCH" == "true" ]; then
45+
echo "Recompiling the Psych C extension (TRUFFLERUBY_RECOMPILE_PSYCH=true)"
46+
recompile psych
47+
else
48+
echo "Recompiling the Psych C extension (against the installed libyaml)"
49+
recompile psych
3650
fi
3751

3852
echo "TruffleRuby was successfully installed in $root"

mx.truffleruby/suite.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@
530530
"file:src/main/c/openssl/ossl*.h",
531531
"file:src/main/c/openssl/openssl_missing.h",
532532
],
533+
"src/main/c/psych/": [
534+
"file:src/main/c/psych/extconf.rb",
535+
"file:src/main/c/psych/*.c",
536+
"file:src/main/c/psych/psych*.h",
537+
],
533538
},
534539
},
535540

0 commit comments

Comments
 (0)