diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ce2c32bc..2716bc025 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: run: mx.trufflesqueak/utils.sh set-up-dependencies java${{ matrix.java }} - name: Build TruffleSqueak JVM component run: mx.trufflesqueak/utils.sh build-component trufflesqueak-jvm SMALLTALK_INSTALLABLE_JAVA${{ matrix.java }} ${{ env.INSTALLABLE_JVM_TARGET }} - if: ${{ matrix.os != 'windows-latest' }} + if: ${{ env.BUILD_SVM != 'true' && matrix.os != 'windows-latest' }} - name: Build TruffleSqueak JVM component via cmd.exe shell: cmd run: | @@ -88,16 +88,17 @@ jobs: - name: Build TruffleSqueak SVM component run: mx.trufflesqueak/utils.sh build-component trufflesqueak-svm SMALLTALK_INSTALLABLE_SVM_JAVA${{ matrix.java }} ${{ env.INSTALLABLE_SVM_TARGET }} if: ${{ env.BUILD_SVM == 'true' }} - - name: Run SystemReporter on GraalVM + - name: Run SystemReporter on TruffleSqueak in JVM mode shell: bash run: ${{ env.TRUFFLESQUEAK_EXEC }} --jvm --code "SystemReporter new reportText asString" images/test-64bit.image - - name: Run SystemReporter on SubstrateVM + - name: Run SystemReporter on TruffleSqueak in native mode shell: bash run: ${{ env.TRUFFLESQUEAK_EXEC }} --native --code "SystemReporter new reportText asString" images/test-64bit.image if: ${{ env.BUILD_SVM == 'true' }} - name: Upload TruffleSqueak JVM component shell: bash run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.INSTALLABLE_JVM_TARGET }} ${{ secrets.GITHUB_TOKEN }} + if: ${{ env.BUILD_SVM != 'true' && matrix.os != 'windows-latest' }} - name: Upload TruffleSqueak SVM component shell: bash run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.INSTALLABLE_SVM_TARGET }} ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/development.md b/docs/development.md index 0d06652da..9c03ce47e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,7 +39,7 @@ GraalVM Updater, which can be installed with: ```bash $GRAALVM_HOME/bin/gu install -f -L \ - "$(../mx/mx --env trufflesqueak-jvm paths SMALLTALK_INSTALLABLE_JAVA11)" + "$(../mx/mx --env trufflesqueak-jvm paths SMALLTALK_INSTALLABLE_SVM_JAVA11)" ``` diff --git a/mx.trufflesqueak/launchers/trufflesqueak b/mx.trufflesqueak/launchers/trufflesqueak new file mode 100755 index 000000000..7ac4b2570 --- /dev/null +++ b/mx.trufflesqueak/launchers/trufflesqueak @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +while [ -h "$source" ] ; do + prev_source="$source" + source="$(readlink "$source")"; + if [[ "$source" != /* ]]; then + # if the link was relative, it was relative to where it came from + dir="$( cd -P "$( dirname "$prev_source" )" && pwd )" + source="$dir/$source" + fi +done +bin_dir="$( cd -P "$( dirname "$source" )" && pwd )" + +# Increase stack size (`-XX:ThreadStackSize=64M` not working) +extra_args=("--vm.Xss64M") +# Make ReflectionUtils work +extra_args+=("--vm.-add-exports=java.base/jdk.internal.module=ALL-UNNAMED") +# Make Truffle.getRuntime() accessible for VM introspection +extra_args+=("--vm.-add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime=ALL-UNNAMED") +# Enable access to HostObject and others +extra_args+=("--vm.-add-opens=org.graalvm.truffle/com.oracle.truffle.host=ALL-UNNAMED") +# Enable access to Truffle's SourceSection (for retrieving sources through interop) +extra_args+=("--vm.-add-opens=org.graalvm.truffle/com.oracle.truffle.api.source=ALL-UNNAMED") + +if [ "$(uname -s)" == "Darwin" ]; then + extra_args+=("--vm.Xdock:name=TruffleSqueak") +fi + +exec "${bin_dir}/trufflesqueak-launcher" "${extra_args[@]}" "$@" diff --git a/mx.trufflesqueak/launchers/trufflesqueak.cmd b/mx.trufflesqueak/launchers/trufflesqueak.cmd new file mode 100644 index 000000000..d0179e6d6 --- /dev/null +++ b/mx.trufflesqueak/launchers/trufflesqueak.cmd @@ -0,0 +1,35 @@ +@echo off + +setlocal enabledelayedexpansion + +echo %* | findstr = >nul && ( + echo Warning: the '=' character in program arguments is not fully supported. + echo Make sure that command line arguments using it are wrapped in double quotes. + echo Example: + echo "--vm.Dfoo=bar" + echo. +) + +set "tsl_exe=%~dp0trufflesqueak-launcher.exe" +if not exist "%tsl_exe%" ( + echo Error: Cannot find '%TSL_EXE%' + exit /b 1 +) + +@REM Increase stack size (`-XX:ThreadStackSize=64M` not working) +set extra_args=--vm.Xss64M +@REM Make ReflectionUtils work +set extra_args=%extra_args% --vm.-add-exports=java.base/jdk.internal.module=ALL-UNNAMED +@REM Make Truffle.getRuntime() accessible for VM introspection +set extra_args=%extra_args% --vm.-add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime=ALL-UNNAMED +@REM Enable access to HostObject and others +set extra_args=%extra_args% --vm.-add-opens=org.graalvm.truff22le/com.oracle.truffle.host=ALL-UNNAMED +@REM Enable access to Truffle's SourceSection (for retrieving sources through interop) +set extra_args=%extra_args% --vm.-add-opens=org.graalvm.truffle/com.oracle.truffle.api.source=ALL-UNNAMED + + +if "%VERBOSE_GRAALVM_LAUNCHERS%"=="true" echo on + +"%tsl_exe%" %extra_args% %* + +exit /b %errorlevel% diff --git a/mx.trufflesqueak/mx_trufflesqueak.py b/mx.trufflesqueak/mx_trufflesqueak.py index 766f59f65..23950e646 100644 --- a/mx.trufflesqueak/mx_trufflesqueak.py +++ b/mx.trufflesqueak/mx_trufflesqueak.py @@ -531,28 +531,30 @@ def patched_init(self, *args, **kw_args): 'trufflesqueak:TRUFFLESQUEAK', 'trufflesqueak:TRUFFLESQUEAK_SHARED', ], - support_distributions=[ - 'trufflesqueak:TRUFFLESQUEAK_HOME', + support_distributions=['trufflesqueak:TRUFFLESQUEAK_HOME'], + provided_executables=[ + 'bin/', ], - launcher_configs=[ - mx_sdk.LanguageLauncherConfig( + library_configs=[ + mx_sdk.LanguageLibraryConfig( language=LANGUAGE_ID, - destination='bin/', + destination='lib/' % LANGUAGE_ID, + launchers=['bin/'], jar_distributions=['trufflesqueak:TRUFFLESQUEAK_LAUNCHER'], main_class='%s.launcher.TruffleSqueakLauncher' % PACKAGE_NAME, - extra_jvm_args=BASE_VM_ARGS, build_args=[ - # '--pgo-instrument', # (uncomment to enable profiling) - # '--pgo', # (uncomment to recompile with profiling info) + '-H:+DumpThreadStacksOnSignal', + '-H:+DetectUserDirectoriesInImageHeap', + '-H:+TruffleCheckBlockListMethods', ], ) ], - post_install_msg=(None if not _SVM else "\nNOTES:\n---------------\n" + - "TruffleSqueak (SVM) requires SDL2 to be installed on your system:\n" + + stability="experimental", + post_install_msg=(None if not _SVM else "\nTRUFFLESQUEAK NOTE:\n-------------------\n" + + "By default, TruffleSqueak runs in JVM mode (`trufflesqueak --jvm ...`). " + + "Running it in native mode (`trufflesqueak --native` ...) requires SDL2 to be installed on your system:\n" + "- On Debian/Ubuntu, you can install SDL2 via `sudo apt-get install libsdl2-2.0`.\n" + - "- On macOS, you can install SDL2 with Homebrew: `brew install sdl2`.\n\n" + - "The pre-compiled native image is used by default and does not include other languages. " + - "Run TruffleSqueak in JVM mode (via `trufflesqueak --jvm`) for polyglot access."), + "- On macOS, you can install SDL2 with Homebrew: `brew install sdl2`."), )) diff --git a/mx.trufflesqueak/suite.py b/mx.trufflesqueak/suite.py index 494e1e9d8..67288e0d1 100644 --- a/mx.trufflesqueak/suite.py +++ b/mx.trufflesqueak/suite.py @@ -219,6 +219,9 @@ "README_TRUFFLESQUEAK.md": "file:README.md", "lib/": "dependency:de.hpi.swa.trufflesqueak.ffi.native", "native-image.properties": "file:mx.trufflesqueak/native-image.properties", + "bin/" : [ + "file:mx.trufflesqueak/launchers/", + ], }, "maven": False, }, diff --git a/mx.trufflesqueak/utils.sh b/mx.trufflesqueak/utils.sh index b10a1cce9..698beeb02 100755 --- a/mx.trufflesqueak/utils.sh +++ b/mx.trufflesqueak/utils.sh @@ -233,9 +233,10 @@ set-up-dependencies() { ;; esac - set-env "INSTALLABLE_JVM_TARGET" "$(installable-filename "${java_version}" "")" if [[ "${BUILD_SVM:-}" == "true" ]]; then set-env "INSTALLABLE_SVM_TARGET" "$(installable-filename "${java_version}" "-svm")" + else + set-env "INSTALLABLE_JVM_TARGET" "$(installable-filename "${java_version}" "")" fi } diff --git a/src/de.hpi.swa.trufflesqueak.launcher/src/de/hpi/swa/trufflesqueak/launcher/TruffleSqueakLauncher.java b/src/de.hpi.swa.trufflesqueak.launcher/src/de/hpi/swa/trufflesqueak/launcher/TruffleSqueakLauncher.java index 5bb62289b..b0dab89ca 100644 --- a/src/de.hpi.swa.trufflesqueak.launcher/src/de/hpi/swa/trufflesqueak/launcher/TruffleSqueakLauncher.java +++ b/src/de.hpi.swa.trufflesqueak.launcher/src/de/hpi/swa/trufflesqueak/launcher/TruffleSqueakLauncher.java @@ -187,7 +187,7 @@ protected String[] getDefaultLanguages() { @Override protected VMType getDefaultVMType() { - return VMType.Native; + return VMType.JVM; } private static boolean isExistingImageFile(final String fileName) {