Skip to content

Commit

Permalink
Build TruffleSqueak standalone
Browse files Browse the repository at this point in the history
instead of shipping TruffleSqueak Native with installables.
  • Loading branch information
fniephaus committed Oct 29, 2022
1 parent 128dcf3 commit dba8c34
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 103 deletions.
106 changes: 71 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Clone TruffleSqueak repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up dependencies
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Check style and perform full build
run: mx gate --strict-mode --tags style,fullbuild

builds:
build-jar:
strategy:
fail-fast: false
matrix:
Expand All @@ -55,67 +55,49 @@ jobs:
env:
RUN_TESTS: "${{ matrix.os == 'ubuntu-20.04' || matrix.java == 17 }}"
RUN_WITH_COVERAGE: "${{ matrix.os == 'ubuntu-20.04' && matrix.java == 17 }}"
TRUFFLESQUEAK_EXEC: "${{ matrix.os == 'windows-2019' && 'trufflesqueak.cmd' || 'trufflesqueak' }}"
TS_INFIX: "${{ matrix.java == 11 && '_SVM' || '' }}"
MX_ENV: "${{ matrix.java == 11 && 'trufflesqueak-svm' || 'trufflesqueak-jvm' }}"
MX_ENV: "trufflesqueak-jar"
VERBOSE_GRAALVM_LAUNCHERS: true
name: ${{ matrix.os }} + JDK${{ matrix.java }}
name: JAR ${{ matrix.os }} + JDK${{ matrix.java }}
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Clone TruffleSqueak repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up dependencies
shell: bash
run: mx.trufflesqueak/utils.sh set-up-dependencies java${{ matrix.java }}
- name: Build TruffleSqueak component
run: mx.trufflesqueak/utils.sh build-component ${{ env.MX_ENV }} ${{ matrix.java }} ${{ env.INSTALLABLE_TARGET }}
run: mx.trufflesqueak/utils.sh set-up-dependencies java${{ matrix.java }} false
- name: Build TruffleSqueak installable
run: mx.trufflesqueak/utils.sh build-installable ${{ matrix.java }}
if: ${{ matrix.os != 'windows-2019' }}
- name: Configure pagefile # this reduces OOM kills on Windows
uses: al-cheb/[email protected]
with:
minimum-size: 8GB
disk-root: "C:"
if: ${{ matrix.os == 'windows-2019' }}
- name: Build TruffleSqueak component via cmd.exe
- name: Build TruffleSqueak installable via cmd.exe
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
call mx --env ${{ env.MX_ENV }} --no-download-progress build --dependencies SMALLTALK_INSTALLABLE${{ env.TS_INFIX }}_JAVA${{ matrix.java }},GRAALVM_TRUFFLESQUEAK${{ env.TS_INFIX }}_JAVA${{ matrix.java }}
call mx --env ${{ env.MX_ENV }} --no-download-progress build --dependencies SMALLTALK_INSTALLABLE_JAVA${{ matrix.java }},GRAALVM_TRUFFLESQUEAK_JAR_JAVA${{ matrix.java }}
call mx --env ${{ env.MX_ENV }} graalvm-home > graalvm-home-with-forward-slashes.txt
set /p GRAALVM_HOME=<graalvm-home-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "GRAALVM_HOME=%GRAALVM_HOME:/=\%"
echo %GRAALVM_HOME%\bin>>%GITHUB_PATH%
echo GRAALVM_HOME=%GRAALVM_HOME%>>%GITHUB_ENV%
echo [%GRAALVM_HOME% set as $GRAALVM_HOME]
call mx --env ${{ env.MX_ENV }} paths SMALLTALK_INSTALLABLE${{ env.TS_INFIX }}_JAVA${{ matrix.java }} > installable-path-with-forward-slashes.txt
call mx --env ${{ env.MX_ENV }} paths SMALLTALK_INSTALLABLE_JAVA${{ matrix.java }} > installable-path-with-forward-slashes.txt
set /p INSTALLABLE_PATH=<installable-path-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "INSTALLABLE_PATH=%INSTALLABLE_PATH:/=\%"
copy %INSTALLABLE_PATH% ${{ env.INSTALLABLE_TARGET }}
if: ${{ matrix.os == 'windows-2019' }}
- 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 TruffleSqueak in native mode
shell: bash
run: ${{ env.TRUFFLESQUEAK_EXEC }} --native --code "SystemReporter new reportText asString" images/test-64bit.image
if: ${{ matrix.java == 11 }}
- name: Upload TruffleSqueak component
- name: Run SystemReporter on TruffleSqueak
run: trufflesqueak --code "SystemReporter new reportText asString" images/test-64bit.image
- name: Upload TruffleSqueak installable
shell: bash
run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.INSTALLABLE_TARGET }} ${{ secrets.GITHUB_TOKEN }}
- name: Run Cuis-Smalltalk tests on TruffleSqueak in native mode
run: |
mx.trufflesqueak/utils.sh download-cuis-test-image
trufflesqueak --native --headless --experimental-options --smalltalk.resource-summary=true --engine.CompilationFailureAction=ExitVM --engine.TreatPerformanceWarningsAsErrors=all --engine.CompilationStatistics images/Cuis6.0-????.image -s src/de.hpi.swa.trufflesqueak.test/src/de/hpi/swa/trufflesqueak/test/runCuisTests.st
if: ${{ matrix.os == 'macos-11' && matrix.java == 11 }}
- name: Clone Graal.js repository
shell: bash
run: mx.trufflesqueak/utils.sh shallow-clone-graaljs
Expand Down Expand Up @@ -144,10 +126,64 @@ jobs:
run: "[[ -d graal_dumps ]] && zip -r graal_dumps.zip graal_dumps || true"
if: ${{ env.RUN_TESTS == 'true' }}
- name: Upload Graal compiler dumps
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: graal_dumps
path: graal_dumps.zip
if-no-files-found: ignore
retention-days: 5
if: ${{ env.RUN_TESTS == 'true' }}

build-standalone:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-20.04-aarch64, macos-11, windows-2019]
env:
JAVA_VERSION: "11"
MX_ENV: "trufflesqueak-standalone"
VERBOSE_GRAALVM_LAUNCHERS: true
name: Standalone ${{ matrix.os }}
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Clone TruffleSqueak repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up dependencies
shell: bash
run: mx.trufflesqueak/utils.sh set-up-dependencies java${{ env.JAVA_VERSION }} true
- name: Build TruffleSqueak standalone
run: mx.trufflesqueak/utils.sh build-standalone ${{ env.JAVA_VERSION }}
if: ${{ matrix.os != 'windows-2019' }}
- name: Build TruffleSqueak standalone via cmd.exe
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
call mx --env ${{ env.MX_ENV }} --no-download-progress build --dependencies SMALLTALK_STANDALONE_SVM_JAVA${{ env.JAVA_VERSION }},GRAALVM_TRUFFLESQUEAK_STANDALONE_JAVA${{ env.JAVA_VERSION }}
call mx --env ${{ env.MX_ENV }} standalone-home smalltalk > standalone-home-with-forward-slashes.txt
set /p STANDALONE_HOME=<standalone-home-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "STANDALONE_HOME=%STANDALONE_HOME:/=\%"
echo %STANDALONE_HOME%\bin>>%GITHUB_PATH%
echo [%STANDALONE_HOME%\bin added to $PATH]
call mx --env ${{ env.MX_ENV }} paths SMALLTALK_STANDALONE_SVM_JAVA${{ env.JAVA_VERSION }} > standalone-path-with-forward-slashes.txt
set /p STANDALONE_PATH=<standalone-path-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "STANDALONE_PATH=%STANDALONE_PATH:/=\%"
copy %STANDALONE_PATH% ${{ env.STANDALONE_TARGET }}
if: ${{ matrix.os == 'windows-2019' }}
- name: Run SystemReporter on TruffleSqueak standalone
run: trufflesqueak --code "SystemReporter new reportText asString" images/test-64bit.image
- name: Upload TruffleSqueak standalone
shell: bash
run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.STANDALONE_TARGET }} ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.os != 'macos-11' }} # GraalVM Native Image does not support AWT on macOS yet (https://github.com/oracle/graal/issues/4921)
- name: Run Cuis-Smalltalk tests on TruffleSqueak standalone
run: |
mx.trufflesqueak/utils.sh download-cuis-test-image
trufflesqueak --headless --experimental-options --smalltalk.resource-summary=true --engine.CompilationFailureAction=ExitVM --engine.TreatPerformanceWarningsAsErrors=all --engine.CompilationStatistics images/Cuis6.0-????.image -s src/de.hpi.swa.trufflesqueak.test/src/de/hpi/swa/trufflesqueak/test/runCuisTests.st
if: ${{ matrix.os == 'ubuntu-20.04' }}
26 changes: 12 additions & 14 deletions mx.trufflesqueak/launchers/trufflesqueak
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ bin_dir="$( cd -P "$( dirname "$source" )" && pwd )"
# Increase stack size (`-XX:ThreadStackSize=64M` not working)
extra_args=("--vm.Xss64M")

if [[ "$*" != *"--native"* ]]; then
# Default to polyglot launcher in JVM mode
extra_args+=("--jvm" "--polyglot")
# 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")
# Default to polyglot launcher in JVM mode
extra_args+=("--jvm" "--polyglot")
# 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
if [[ "$(uname -s)" == "Darwin" ]]; then
extra_args+=("--vm.Xdock:name=TruffleSqueak")
fi

exec "${bin_dir}/trufflesqueak-launcher" "${extra_args[@]}" "$@"
22 changes: 10 additions & 12 deletions mx.trufflesqueak/launchers/trufflesqueak.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ if not exist "%tsl_exe%" (
@REM Increase stack size (`-XX:ThreadStackSize=64M` not working)
set extra_args=--vm.Xss64M

echo %* | findstr \-\-native >nul || (
@REM Default to polyglot launcher in JVM mode
set extra_args=%extra_args% --jvm --polyglot
@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.truffle/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
)
@REM Default to polyglot launcher in JVM mode
set extra_args=%extra_args% --jvm --polyglot
@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.truffle/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

Expand Down
18 changes: 9 additions & 9 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,32 @@ def patched_init(self, *args, **kw_args):

_enable_local_compression()

mx_sdk_vm.register_vm_config('trufflesqueak', ['nfi', 'nfi-libffi', 'sdk', 'st', 'tfl'],
_SUITE, env_file='trufflesqueak-jvm')
mx_sdk_vm.register_vm_config('trufflesqueak-svm', ['cmp', 'nfi', 'nfi-libffi', 'sdk', 'st', 'svm', 'svmnfi', 'svmsl', 'tfl', 'tflm'],
_SUITE, env_file='trufflesqueak-svm')
mx_sdk_vm.register_vm_config('trufflesqueak-jar', ['sdk', 'st', 'tfl'],
_SUITE, env_file='trufflesqueak-jar')
mx_sdk_vm.register_vm_config('trufflesqueak-standalone', ['cmp', 'nfi', 'nfi-libffi', 'sdk', 'st', 'tfl'],
_SUITE, env_file='trufflesqueak-standalone')

mx_sdk.register_graalvm_component(mx_sdk.GraalVmLanguage(
suite=_SUITE,
name='TruffleSqueak',
short_name='st',
dir_name=LANGUAGE_ID,
standalone_dir_name='trufflesqueak-<version>-<graalvm_os>-<arch>',
license_files=[], # already included in `TRUFFLESQUEAK_HOME`.
third_party_license_files=[],
dependencies=['Truffle'],
standalone_dependencies={},
truffle_jars=[
'trufflesqueak:TRUFFLESQUEAK',
'trufflesqueak:TRUFFLESQUEAK_SHARED',
],
support_distributions=['trufflesqueak:TRUFFLESQUEAK_HOME'],
provided_executables=[
'bin/<cmd:trufflesqueak>',
],
support_distributions=['trufflesqueak:TRUFFLESQUEAK_HOME'] + [] if _SVM else ['trufflesqueak:TRUFFLESQUEAK_LAUNCHER_SCRIPTS'],
provided_executables=[] if _SVM else ['bin/<cmd:trufflesqueak>'],
library_configs=[
mx_sdk.LanguageLibraryConfig(
language=LANGUAGE_ID,
destination='lib/<lib:%svm>' % LANGUAGE_ID,
launchers=['bin/<exe:trufflesqueak-launcher>'],
launchers=['bin/<exe:trufflesqueak>'] if _SVM else ['bin/<exe:trufflesqueak-launcher>'],
jar_distributions=['trufflesqueak:TRUFFLESQUEAK_LAUNCHER'],
main_class='%s.launcher.TruffleSqueakLauncher' % PACKAGE_NAME,
build_args=[
Expand Down
13 changes: 10 additions & 3 deletions mx.trufflesqueak/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,6 @@
"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 All @@ -243,6 +240,16 @@
],
},

"TRUFFLESQUEAK_LAUNCHER_SCRIPTS": {
"native": True,
"platformDependent": True,
"description": "TruffleSqueak home distribution",
"layout": {
"bin/": ["file:mx.trufflesqueak/launchers/<cmd:trufflesqueak>"],
},
"maven": False,
},

"TRUFFLESQUEAK_SHARED": {
"description": "TruffleSqueak shared distribution",
"moduleInfo": {
Expand Down
3 changes: 3 additions & 0 deletions mx.trufflesqueak/trufflesqueak-jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPONENTS=TruffleSqueak
DEFAULT_DYNAMIC_IMPORTS=/trufflesqueak,/vm
DISABLE_INSTALLABLES=false
2 changes: 0 additions & 2 deletions mx.trufflesqueak/trufflesqueak-jvm

This file was deleted.

4 changes: 4 additions & 0 deletions mx.trufflesqueak/trufflesqueak-standalone
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
COMPONENTS=TruffleSqueak,GraalVM compiler,Truffle NFI LIBFFI
DISABLE_INSTALLABLES=false
DYNAMIC_IMPORTS=/compiler,/substratevm,/vm
NATIVE_IMAGES=lib:smalltalkvm
2 changes: 0 additions & 2 deletions mx.trufflesqueak/trufflesqueak-svm

This file was deleted.

Loading

0 comments on commit dba8c34

Please sign in to comment.