Skip to content

Commit

Permalink
Deploy TruffleSqueak as language library
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Mar 25, 2022
1 parent 2d58da5 commit 8e33516
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 19 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
```


Expand Down
30 changes: 30 additions & 0 deletions mx.trufflesqueak/launchers/trufflesqueak
Original file line number Diff line number Diff line change
@@ -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[@]}" "$@"
35 changes: 35 additions & 0 deletions mx.trufflesqueak/launchers/trufflesqueak.cmd
Original file line number Diff line number Diff line change
@@ -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%
28 changes: 15 additions & 13 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<cmd:trufflesqueak>',
],
launcher_configs=[
mx_sdk.LanguageLauncherConfig(
library_configs=[
mx_sdk.LanguageLibraryConfig(
language=LANGUAGE_ID,
destination='bin/<exe:trufflesqueak>',
destination='lib/<lib:%svm>' % LANGUAGE_ID,
launchers=['bin/<exe:trufflesqueak-launcher>'],
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`."),
))


Expand Down
3 changes: 3 additions & 0 deletions mx.trufflesqueak/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<cmd:trufflesqueak>",
],
},
"maven": False,
},
Expand Down
3 changes: 2 additions & 1 deletion mx.trufflesqueak/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected String[] getDefaultLanguages() {

@Override
protected VMType getDefaultVMType() {
return VMType.Native;
return VMType.JVM;
}

private static boolean isExistingImageFile(final String fileName) {
Expand Down

0 comments on commit 8e33516

Please sign in to comment.