Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] YJIT Support #3

Open
Nathan-MV opened this issue Apr 27, 2024 · 1 comment
Open

[FEATURE] YJIT Support #3

Nathan-MV opened this issue Apr 27, 2024 · 1 comment

Comments

@Nathan-MV
Copy link

I suppose it's just a matter of building with Rust installed?

@YOU54F
Copy link
Owner

YOU54F commented May 10, 2024

Building against latest version of rust in linux, results in a linking error. Tried with the first supported version of rust for yjit (1.58) (source) and that built fine.

root@978169b38f7a:/# ./home/output/3.3.1-arm64/bin/ruby --yjit -v
ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [aarch64-linux]

OSX requires rust installing, (ideally in the runtime dir, as part of ./setup-runtime.sh rather than using the users home install (the purpose of the runtime is to provide a self-contained jail for building against, with nothing other than macos std tools). The linker needed a tweak, as the rpath settings would conflict when building yjit.a

traveling-ruby/osx on  main [$!] on ☁️  (eu-west-2)
🕙23:00:52 [🧱 INT] ❯./output/3.3.1-arm64/bin/ruby --yjit -v  
ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [arm64-darwin22]

Patch

diff --git a/linux/internal/build-ruby.sh b/linux/internal/build-ruby.sh
index 718831c..10d95d2 100755
--- a/linux/internal/build-ruby.sh
+++ b/linux/internal/build-ruby.sh
@@ -97,9 +97,14 @@ if [ "$(uname -m)" = "x86_64" ]; then
 	export SHLIB_LDFLAGS="$SHLIB_LDFLAGS -L/hbb_shlib/lib64"
 	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/hbb_shlib/lib64/pkgconfig"
 fi
-
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
 
 run openssl version
+export PATH="$HOME/.cargo/bin:$PATH"
+run rustc --version
+run rustup install 1.58.0
+run rustup default 1.58.0
+run rustc --version
 # -fvisibility=hidden interferes with native extension compilation
 export CFLAGS="${CFLAGS//-fvisibility=hidden/}"
 export CXXFLAGS="${CXXFLAGS//-fvisibility=hidden/}"
diff --git a/osx/internal/bin/c++ b/osx/internal/bin/c++
index 3db2b88..ebfd925 100755
--- a/osx/internal/bin/c++
+++ b/osx/internal/bin/c++
@@ -16,12 +16,12 @@ if [[ "$@" =~ $REGEX ]]; then
 	fi
 	exec "${CXX[@]}" "${ARGS[@]}" "$@"
 else
-	if [[ "$RUNTIME_DIR" != "" ]]; then
+	if [[ "$RUNTIME_DIR" != "" && ! "$@" =~ "yjit.a" ]]; then
 		ARGS+=(-rpath "$RUNTIME_DIR/lib" "-L$RUNTIME_DIR/lib")
 	fi
+	if [[ "$RUNTIME_DIR" != "" && ! "$@" =~ "yjit.a" ]]; then
+		EXTRA_ARGS+=("-Wl,-headerpad_max_install_names" -rpath "@executable_path/../lib" -rpath "@loader_path")
+	fi
 	exec "${CXX[@]}" \
-		-Wl,-headerpad_max_install_names \
-		-rpath "@executable_path/../lib" \
-		-rpath "@loader_path" \
-		"${ARGS[@]}" "$@"
+		"${EXTRA_ARGS[@]}" "${ARGS[@]}" "$@"
 fi
diff --git a/osx/internal/bin/cc b/osx/internal/bin/cc
index 2ccf263..fab4df8 100755
--- a/osx/internal/bin/cc
+++ b/osx/internal/bin/cc
@@ -16,12 +16,12 @@ if [[ "$@" =~ $REGEX ]]; then
 	fi
 	exec "${CC[@]}" "${ARGS[@]}" "$@"
 else
-	if [[ "$RUNTIME_DIR" != "" ]]; then
+	if [[ "$RUNTIME_DIR" != "" && ! "$@" =~ "yjit.a" ]]; then
 		ARGS+=(-rpath "$RUNTIME_DIR/lib" "-L$RUNTIME_DIR/lib")
 	fi
+	if [[ "$RUNTIME_DIR" != "" && ! "$@" =~ "yjit.a" ]]; then
+		EXTRA_ARGS+=("-Wl,-headerpad_max_install_names" -rpath "@executable_path/../lib" -rpath "@loader_path")
+	fi
 	exec "${CC[@]}" \
-		-Wl,-headerpad_max_install_names \
-		-rpath "@executable_path/../lib" \
-		-rpath "@loader_path" \
-		"${ARGS[@]}" "$@"
+		"${EXTRA_ARGS[@]}" "${ARGS[@]}" "$@"
 fi
diff --git a/osx/internal/reset_environment.sh b/osx/internal/reset_environment.sh
index 19873d4..73d0fbb 100644
--- a/osx/internal/reset_environment.sh
+++ b/osx/internal/reset_environment.sh
@@ -6,7 +6,7 @@
 # FIXME: a full list of deployment targets on ARM64
 # FIXME: not used at all?
 # export MACOSX_COMPATIBLE_DEPLOYMENT_TARGETS="10.14 10.15 11.0 11.1 11.2 11.3 11.4 11.5 11.6 12.0 12.1"
-export PATH="$SELFDIR/internal/bin":/usr/bin:/bin:/usr/sbin:/sbin
+export PATH="$SELFDIR/internal/bin":$HOME/.cargo/bin:/usr/bin:/bin:/usr/sbin:/sbin
 export CC="$SELFDIR/internal/bin/cc"
 export CXX="$SELFDIR/internal/bin/c++"
 unset DYLD_LIBRARY_PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants