Skip to content

Latest commit

 

History

History
405 lines (339 loc) · 23.8 KB

BUILD.md

File metadata and controls

405 lines (339 loc) · 23.8 KB

Building TruffleSqueak on Microsoft Windows

LLVM TruffleSqueak is a Squeak/Smalltalk implementation for the GraalVM.
This repository gathers several build scripts (batch files, bash scripts) for experimenting with TruffleSqueak on a Windows machine.

This document is part of a series of topics related to TruffleSqueak on Windows:

Project dependencies

This project depends on the following external software for the Microsoft Windows plaform:

For instance our development environment looks as follows (July 2024) 1:

C:\opt\jdk-graalvm-ce-21_35.1\                        (695 MB)
C:\opt\Git\                                           (367 MB)
C:\opt\Python-3.11.1\                                 (116 MB)
C:\Program Files\Microsoft SDKs\Windows\v7.1\         (333 MB)
C:\Program Files (x86)\Microsoft Visual Studio\2019\  (3.1 GB)

Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we defined C:\opt\ as the installation directory for optional software tools (in reference to the /opt/ directory on Unix).

Directory structure

This project is organized as follows:

bin\trufflesqueak\
docs\
examples\README.md
graal\          (created by mx.trufflesqueak)
trufflesqueak\  (Git submodule)[2]
mx\             (created by setenv.bat)
BUILD.md
README.md
setenv.bat

where

We also define a virtual drive – e.g. drive K: – in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).

🔎 We use the Windows external command subst to create virtual drives; for instance:

> subst K: %USERPROFILE%\workspace\trufflesqueak-examples

In the next section we give a brief description of the batch files present in this project.

Batch/Bash commands

We distinguish different sets of batch commands:

  1. setenv.bat - This batch command makes external tools such as python.exe and git.exe directly available from the command prompt (see section Project dependencies).

    > setenv help
    Usage: setenv { <option> | <subcommand> }
     
      Options:
        -bash       start Git bash shell instead of Windows command prompt
        -debug      print commands executed by this script
        -verbose    print progress messages
     
      Subcommands:
        help        print this help message
  2. bin\trufflesqueak\build.bat - This batch command generates the TruffleSqueak installable component from the Windows command prompt.

    > build help
    Usage: build { <option> | <subcommand> }
     
      Options:
        -debug      print commands executed by this script
        -timer      print total execution time
        -verbose    print progress messages
     
      Subcommands:
        clean       delete generated files
        dist        generate the TruffleSqueak component
        help        print this help message
        update      fetch/merge local directories graal/mx
  3. bin\trufflesqueak\build - This bash script generates the TruffleSqueak installable component from the Git bash shell.

    🔎 Bash script build behaves the same as batch file build.bat. We have to use the ./ notation here since, unlike the Windows command prompt, Unix-like shells do not check the current directory for executables before checking the PATH environment variable.

    $ ./build help
    Usage: build { <option> | <subcommand> }
     
      Options:
        -debug      print commands executed by this script
        -timer      print total execution time
        -verbose    print progress messages
     
      Subcommands:
        clean       delete generated files
        dist        generate the TruffleSqueak component
        help        print this help message

Contributions

In this section we resume the pull requests we submitted due to issues with the generation and the execution of the TruffleSqueak installable component.

Pull requestRequest statusContextModified file(s)
#73mergedbuild compilemake_component.(sh|bat)
#75mergedComponentsymlinks
#81mergedComponentLICENSE-GRAALSQUEAK.txt
#82mergedComponentrelease
#83mergedbuild compiletemplate.trufflesqueak.cmd
#84mergedbuild compilemake_component.bat
#85mergedbuild compilemake_component.bat
#90mergedbuild compilemake_component.sh

Usage examples

setenv.bat

We execute command setenv once to setup our development environment; it makes external tools such as python.exe, mx.cmd and git.exe directly available from the command prompt:

> setenv
Tool versions:
   python 3.11.1, pylint 2.17.1
   git 2.45.2, diff 3.10,bash 5.2.26(1)

> where python pylint sh
C:\opt\Python-3.11.1\python.exe
C:\opt\Python-3.11.0\Scripts\pylint.exe
C:\opt\Git\bin\sh.exe
C:\opt\Git\usr\bin\sh.exe

Command setenv -verbose also displays the tool paths:

> setenv -verbose
Tool versions:
   python 3.11.1, pylint 2.17.1
   git 2.45.2, diff 3.10,bash 5.2.26(1)
Tool paths:
   C:\opt\Python-3.11.1\python.exe
   C:\opt\Python-3.11.1\Scripts\pylint.exe
   C:\opt\Git\bin\git.exe
   C:\opt\Git\mingw64\bin\git.exe
   C:\opt\Git\bin\bash.exe
Environment variables:
   "GIT_HOME=C:\opt\Git"
   "GRAALVM_HOME=C:\opt\graalvm-ce-java11-22.3.0"
   "JAVA_HOME=C:\opt\graalvm-ce-java11-22.3.0"
   "MSVC_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC"
   "MSVS_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2017"
   "PYTHON_HOME=C:\opt\Python-3.11.1"

trufflesqueak\build.bat

Directory trufflesqueak\ contains our fork of the hpi-swa/trufflesqueak repository; it is setup as follows when executing commands in the Windows Command shell:

> cp bin\trufflesqueak\build.bat trufflesqueak
> cd trufflesqueak

Command build.bat -verbose clean dist generates several archive files including the TruffleSqueak component.

> cd
K:\trufflesqueak
 
> build -verbose clean dist
MX_VERSION: 6.23.8
Build Java archives
JAVA_HOME: C:\opt\graalvm-ce-java11-22.3.0
EXTRA_JAVA_HOMES:
Dependencies removed from build:
 project com.oracle.truffle.dsl.processor.jdk9 was removed as JDK 9 is not available
 project com.oracle.mxtool.junit.jdk9 was removed as JDK 9 is not available
Non-default dependencies removed from build (use mx build --all to build them):
 JACOCOREPORT_0.8.4
[...]
Executing script scripts\make_component.bat
SUCCESS! The component is located at 'K:\GRAALS~1\scripts\..\trufflesqueak-installable-windows-amd64-1.0.0-rc9-38-gfc82d131-for-GraalVM-22.3.0.jar'.

The generated archive files are either Zip archives or Java archives (.zip files contain the source code of the corresponding .jar files):

> cd
K:\trufflesqueak
 
> dir /o mxbuild\dists\jdk1.8 | findstr /e "jar zip"
09.12.2019  12:06        13 652 401 trufflesqueak.jar
09.12.2019  12:06         7 689 787 trufflesqueak.src.zip
09.12.2019  12:07         5 126 160 trufflesqueak-installable-windows-amd64-1.0.0-rc9-for-GraalVM-22.1.0.jar
09.12.2019  12:06            16 363 trufflesqueak-launcher.jar
09.12.2019  12:06            11 723 trufflesqueak-launcher.src.zip
09.12.2019  12:04               883 trufflesqueak-shared.jar
09.12.2019  12:04               786 trufflesqueak-shared.src.zip
09.12.2019  12:06             9 242 trufflesqueak-tck.jar
09.12.2019  12:06             9 004 trufflesqueak-tck.src.zip
09.12.2019  12:06           379 165 trufflesqueak-test.jar
09.12.2019  12:06           102 781 trufflesqueak-test.src.zip

The TruffleSqueak component is packed into the installable component archive trufflesqueak-installable-java11-windows-amd64-22.3.0.jar whose contents looks as follows:

> jar tf trufflesqueak-installable-java11-windows-amd64-22.3.0.jar
bin/trufflesqueak.cmd
jre/bin/trufflesqueak.cmd
jre/languages/smalltalk/trufflesqueak.jar
jre/languages/smalltalk/trufflesqueak-shared.jar
jre/languages/smalltalk/trufflesqueak.src.zip
jre/languages/smalltalk/trufflesqueak-shared.src.zip
jre/languages/smalltalk/LICENSE_TRUFFLESQUEAK.txt
jre/languages/smalltalk/README_TRUFFLESQUEAK.md
jre/languages/smalltalk/lib/SqueakFFIPrims.dll
jre/languages/smalltalk/native-image.properties
jre/languages/smalltalk/resources/SqueakV50.sources
jre/languages/smalltalk/resources/TruffleSqueak-22.3.0.changes
jre/languages/smalltalk/resources/TruffleSqueak-22.3.0.image
jre/languages/smalltalk/polyglot.config
jre/languages/smalltalk/bin/trufflesqueak.cmd
jre/languages/smalltalk/release
jre/lib/graalvm/trufflesqueak-launcher.jar
jre/lib/graalvm/trufflesqueak-launcher.src.zip
META-INF/MANIFEST.MF
META-INF/permissions
META-INF/symlinks

We present the installation of the generated TruffleSqueak component archive in document README.md.

Command build -verbose update ensures both directories mx\ and trufflesqueak\ are update-to-date (Github clones):

> build -verbose update
 Current directory is K:\\mx
 Update MX directory K:\\mx
 Update MX directory K:\\mx
Already up to date.
 Current directory is K:\trufflesqueak\
 Update TruffleSqueak directory K:\trufflesqueak\
From https://github.com/hpi-swa/trufflesqueak
 * branch              dev        -> FETCH_HEAD
 Update TruffleSqueak directory K:\trufflesqueak\
Already up to date.

trufflesqueak\build

Directory trufflesqueak\ contains our fork of the hpi-swa/trufflesqueak repository; it is setup as follows when executing commands in the Git bash shell (started with option -bash):

> setenv -bash
$ cp bin/trufflesqueak/build trufflesqueak
$ cd trufflesqueak

Command build clean dist generates several archive files including the TruffleSqueak component.

$ ./build clean dist
JAVA_HOME: C:\opt\graalvm-ce-java11-22.3.0
EXTRA_JAVA_HOMES:
Dependencies removed from build:
 project com.oracle.truffle.dsl.processor.jdk9 was removed as JDK 9 is not available
 project com.oracle.mxtool.junit.jdk9 was removed as JDK 9 is not available
Non-default dependencies removed from build (use mx build --all to build them):
 JACOCOREPORT_0.8.4
[...]
SUCCESS! The component is located at '/k/trufflesqueak/scripts/../trufflesqueak-installable-windows-amd64-1.0.0-rc5-59-g656c1823-for-GraalVM-20.1.0.jar'.

Troubleshooting

In this section we list some issues we encountered in this project:

  • Command build dist generates the error message FAILED: trufflenfi.dll:

    > build dist
    JAVA_HOME: C:\opt\graalvm-ce-java11-22.3.0
    [...]
    Building com.oracle.truffle.nfi.native_amd64 with Ninja...
    [1/1] LINK trufflenfi.dll
    FAILED: trufflenfi.dll
    link -nologo -dll -out:trufflenfi.dll src\api.obj src\closure.obj src\intrinsics.obj src\jni.obj src\lookup.obj src\lookup_win32.obj src\signature.obj C:\Users\michelou\workspace-perso\trufflesqueak-examples\graal\truffle\mxbuild\windows-amd64\src\libffi\amd64\ffi.lib
    link: unknown option -- n
    Try 'link --help' for more information.
    ninja: build stopped: subcommand failed.

    The error is due to a wrong executable path for link.exe (see issue #1554 in oracle/graal project):

    > where link
    C:\opt\Git\usr\bin\link.exe
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe

Footnotes

[1] Downloads

In our case we downloaded the following installation files (see section 1):
trufflesqueak-installable-java11-windows-amd64-22.3.0.jar  (135 MB)
graalvm-ce-java11-windows-amd64-22.3.0.zip          (154 MB)
python-3.11.1.amd64.msi                             ( 19 MB)
Squeak6.0-22104-64bit-202206021410-Windows-x64.zip  ( 26 MB)

[2] Github submodule

Defining trufflesqueak as a Github submodule allows us to make changes to this project independently from our fork of the hpi-swa/trufflesqueak repository.

mics/July 2024