diff --git a/.github/workflows/extra.yml b/.github/workflows/extra.yml index a4be27d6b3..318e55866c 100644 --- a/.github/workflows/extra.yml +++ b/.github/workflows/extra.yml @@ -17,11 +17,11 @@ jobs: fail-fast: false # let them finish bc. different platforms matrix: include: - - arch: { name: win32x86, os: windows-2025, msystem: mingw32, msys-env: i686 } + - arch: { name: win32x86, os: windows-2025 } flavor: squeak.cog.v3 - - arch: { name: win32x86, os: windows-2025, msystem: mingw32, msys-env: i686 } + - arch: { name: win32x86, os: windows-2025 } flavor: squeak.stack.v3 - - arch: { name: win32x86, os: windows-2025, msystem: mingw32, msys-env: i686 } + - arch: { name: win32x86, os: windows-2025 } flavor: squeak.cog.spur.lowcode - arch: { name: linux32x86, os: ubuntu-22.04 } @@ -36,8 +36,6 @@ jobs: FLAVOR: ${{ matrix.flavor }} MODE: fast # no assert or debug here HEARTBEAT: threaded # linux only; no itimer here - MSYS_SYS: ${{ matrix.arch.msystem }} - MSYS_ENV: ${{ matrix.arch.msys-env }} steps: - name: Checkout files uses: actions/checkout@v4 @@ -58,20 +56,22 @@ jobs: if: startsWith(matrix.arch.name, 'win') uses: msys2/setup-msys2@v2 with: - msystem: ${{ matrix.arch.msystem }} + msystem: MSYS release: false # use existing MSYS2 installation update: false # faster builds cache: true - install: | - base-devel - mingw-w64-${{ matrix.arch.msys-env }}-toolchain - mingw-w64-${{ matrix.arch.msys-env }}-clang - mingw-w64-${{ matrix.arch.msys-env }}-clang-libs + install: git base make - - name: Build VM + - name: Build VM (Linux) + if: startsWith(matrix.arch.name, 'linux') shell: bash run: ./scripts/ci/actions_build.sh + - name: Build VM (Windows) + if: startsWith(matrix.arch.name, 'win') + shell: msys2 {0} #bash + run: ./scripts/ci/actions_build.sh + - name: Sign VM (not implemented) if: false run: ./deploy/sign-vm.sh diff --git a/.github/workflows/win-arm.yml b/.github/workflows/win-arm.yml index e48c5a69aa..dc45f9ae71 100644 --- a/.github/workflows/win-arm.yml +++ b/.github/workflows/win-arm.yml @@ -47,20 +47,20 @@ jobs: fail-fast: false matrix: arch: - - { name: win64ARMv8, msystem: clangarm64, msys-env: clang-aarch64 } + - win64ARMv8 flavor: - squeak.cog.spur - squeak.stack.spur - - squeak.sista.spur + # - squeak.sista.spur # Not yet compiling as of VMMaker.oscog-eem.3617 mode: - fast - debug - assert runs-on: windows-11-arm - name: ${{ matrix.flavor }} for ${{ matrix.arch.name }}${{ matrix.mode == 'debug' && ' (DEBUG)' || matrix.mode == 'assert' && ' (ASSERT)' || '' }} + name: ${{ matrix.flavor }} for ${{ matrix.arch }}${{ matrix.mode == 'debug' && ' (DEBUG)' || matrix.mode == 'assert' && ' (ASSERT)' || '' }} env: - ARCH: ${{ matrix.arch.name }} + ARCH: ${{ matrix.arch }} FLAVOR: ${{ matrix.flavor }} MODE: ${{ matrix.mode }} steps: @@ -83,27 +83,21 @@ jobs: # - name: Setup tmate debugging session # uses: mxschmitt/action-tmate@v3 - - name: Prepare MSYS2/${{ matrix.arch.msys-env }} build environment + - name: Prepare MSYS2 environment uses: msys2/setup-msys2@v2 id: msys2 with: - msystem: ${{ matrix.arch.msystem }} + msystem: MSYS release: true # no MSYS2 installed in ARM64 runners update: false # faster? cache: true - install: | - git - base-devel - mingw-w64-${{ matrix.arch.msys-env }}-toolchain + install: git base make - name: Build VM shell: msys2 {0} #bash run: ./scripts/ci/actions_build.sh - # run: C:\msys64\usr\bin\bash -lc "cd $(pwd); exec ./scripts/ci/actions_build.sh" env: - MSYS_SYS: ${{ matrix.arch.msystem }} - MSYS_ENV: ${{ matrix.arch.msys-env }} - MSYS_PATH: ${{ steps.msys2.outputs.msys2-location }} + MSYS2_BIN: ${{ steps.msys2.outputs.msys2-location }}/usr/bin/ - name: Sign VM (not implemented) if: false diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index d1c8660b4f..40829d7711 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -47,8 +47,8 @@ jobs: fail-fast: false matrix: arch: - - { name: win64x64, msystem: mingw64, msys-env: x86_64 } - - { name: win32x86, msystem: mingw32, msys-env: i686 } + - win64x64 + - win32x86 flavor: - squeak.cog.spur - squeak.stack.spur @@ -59,9 +59,9 @@ jobs: - assert runs-on: windows-2025 - name: ${{ matrix.flavor }} for ${{ matrix.arch.name }}${{ matrix.mode == 'debug' && ' (DEBUG)' || matrix.mode == 'assert' && ' (ASSERT)' || '' }} + name: ${{ matrix.flavor }} for ${{ matrix.arch }}${{ matrix.mode == 'debug' && ' (DEBUG)' || matrix.mode == 'assert' && ' (ASSERT)' || '' }} env: - ARCH: ${{ matrix.arch.name }} + ARCH: ${{ matrix.arch }} FLAVOR: ${{ matrix.flavor }} MODE: ${{ matrix.mode }} steps: @@ -79,32 +79,24 @@ jobs: uses: actions/cache@v4 with: path: .thirdparty-cache - key: thirdparty-cache-${{ matrix.arch.name }}-${{ matrix.flavor }} + key: thirdparty-cache-${{ matrix.arch }}-${{ matrix.flavor }} + # Set your personal SSH key via GitHub to login securely into tmate shell # - name: Setup tmate debugging session - # uses: mxschmitt/action-tmate@v3 + # uses: mxschmitt/action-tmate@v3 - - name: Prepare MSYS2/${{ matrix.arch.msys-env }} build environment + - name: Prepare MSYS2 environment uses: msys2/setup-msys2@v2 with: - msystem: ${{ matrix.arch.msystem }} + msystem: MSYS release: false # use existing MSYS2 installation update: false # faster? cache: true - install: | - git - base-devel - mingw-w64-${{ matrix.arch.msys-env }}-toolchain - mingw-w64-${{ matrix.arch.msys-env }}-clang - mingw-w64-${{ matrix.arch.msys-env }}-clang-libs + install: git base make - name: Build VM shell: msys2 {0} #bash run: ./scripts/ci/actions_build.sh - # run: C:\msys64\usr\bin\bash -lc "cd $(pwd); exec ./scripts/ci/actions_build.sh" - env: - MSYS_SYS: ${{ matrix.arch.msystem }} - MSYS_ENV: ${{ matrix.arch.msys-env }} - name: Sign VM (not implemented) if: false diff --git a/building/win32x86/HowToBuild b/building/win32x86/HowToBuild index 49ce1b3594..a367c14367 100644 --- a/building/win32x86/HowToBuild +++ b/building/win32x86/HowToBuild @@ -8,7 +8,6 @@ Contents: - Building out of the box - Building a Specific Plugin Dll - Building the VM Simulator Support Libraries - - Building an MSI installer (Newspeak) - Optimization level and gcc version (please read!) - Debugging with gdb - Debugging with Visual Studio @@ -17,14 +16,14 @@ Contents: Overview -------- The "Cog" VM comes in a bewildering variety of forms. The first distinction -is between Squeak/Croquet VMs that run Squeak, Pharo, Cuis, Croquet images -and their ilk, and between Newspeak VMs that run Newspeak. +is between Squeak/Croquet VMs that run Squeak, Cuis, Croquet images +and their ilk. Another distinction is between Stack, Cog and Sista VMs. Stack VMs are those with context-to-stack mapping that optimise message sending by keeping method activations on a stack instead of in contexts. These are pure interpreters but significantly faster than the standard context-based Interpreter VM. Cog VMs -add a JIT to the mix, compiling methods used more than once to maxchine code on +add a JIT to the mix, compiling methods used more than once to maschine code on the fly. Sista VMs, as yet unrealised and in development, add support for adaptive optimization that does speculative inlining at the bytecode-to-bytecode level. These are targeted for release in 2015. @@ -54,8 +53,8 @@ debuggability with minimum performance. This directory tree provides build directories for some of this matrix. For example, squeak.cog.v3 contains a build directory for Smalltalk Cog VMs using -the old object representation, newspeak.stack.spur contains a build directory -for Newspeak Stack VMs using the Spur object representation. Build as desired. +the old object representation, squeak.stack.spur contains a build directory +for Smalltalk Stack VMs using the Spur object representation. Build as desired. Checking out sources to build out-of-the-box @@ -68,26 +67,32 @@ Check-out the repository from github: Building out of the box ----------------------- -The standard build configurations are the MinGW tools under Cygwin. -The build system also supports Visual Studio Community (tested with 2017), but -requires Cygwin tools, especially GNU Make, to run. - - -Cygwin 1. Install the tools: -- Install - either cygwin 64bits version from www.cygwin.com. - either mingw 64bits version and msys from www.mingw.com. -If installing Cygwin make sure you install the MinGW support, which is in the -list of packages called "mingw64-i686-gcc-core,mingw64-i686-gcc-g++,mingw64-i686-headers,mingw64-i686-runtime". - -Alternatively, an installation of mingw32 and msys may work, but has not been tested. - -Cygwin 2. Build -Then cd to the build directory of your choice, e.g. - building/win32x86/squeak.cog.spur/ -Then execute - ./mvm - +The standard build configurations are for LLVM/Clang and an MSYS2 shell. You can +either build against the WinSDK directly, which is the recommended way, or +against mingw-w64. + +If you do not know about any of these technologies, here are the resources +to get started: + - LLVM/Clang: https://clang.llvm.org/ + - MSYS2: https://www.msys2.org/ + - Mingw-w64: https://www.mingw-w64.org/ + - Windows SDK: https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ + +Option A - WinSDK + 1. Install MSYS2 via "scripts/installMSYS2.cmd base" + 2. Install "Visual Studio Community Edition" (incl. Windows 10 SDK) + - https://visualstudio.microsoft.com/de/vs/community/ + - Note that recent versions come with own Clang besides MSVCC + - Note that "C++ ATL Support" is required for the CameraPlugin + 3. [optional] Install another LLVM/Clang that targets *-pc-windows-msvc + - https://github.com/llvm/llvm-project/releases + 4. Open MSYS2 shell with default MSYS environment + - Typically "c:/msys64/msys2.exe" or "c:/msys64/msys2_shell.cmd -msys2" + 5. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm" + - Use another LLVM/Clang via "./mvm -- LLVM_BIN=c:/llvm/bin/ " + - Use LLVM/Clang from $PATH via "./mvm -- LLVM_BIN='' " + This builds debug, assert and production versions of the VM in builddbg/vm, buildast/vm and build/vm. If the configuration includes multi-threaded builds it will also create VMs in buildmtdbg/vm, buildmtast/vm and buildmt/vm. The @@ -98,35 +103,31 @@ to access standard i/o. In order to only build the production vm, you can launch the command: ./mvm -f -For building with clang instead of gcc, it is possible to pass options to make via mvm after --: - ./mvm -f -- CC=i686-w64-mingw32-clang - -If building from mingw32, it may be necessary to omit the tool prefix: - ./mvm -f -- TOOLPREFIX='' - - -MSVC 1. Install the tools: -- follow step Cygwin 1. Install the tools -- Make sure that the tools directory (e.g., C:\cygwin\bin) is in your PATH environment variable -- Install Visual Studio Community from https://visualstudio.microsoft.com/downloads/ -- Install a Windows Kit from https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ - -MSVC 2. Build -Open a x86 Native Tools Command Prompt from Visual Studio. -Then cd to the build directory of your choice, e.g. - building/win32x86\squeak.cog.spur\ -Then execute - ..\common\SETPATH.BAT -to add the cygwin tools to your path (edit SETPATH if they are not installed in -c:\cygwin64) -Then execute - ..\common\MAKEDEBUG.BAT - ..\common\MAKEASSERT.BAT - ..\common\MAKEFAST.BAT -to make each of the three VMs. - - -Both Builds + +Option B - mingw-w64 + 1. Install MSYS2 via "scripts/installMSYS2.cmd i686" + 2. Open MSYS2 shell with MINGW32 environment + - Typically "c:/msys64/mingw32.exe" or "c:/msys64/msys2_shell.cmd -mingw32" + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm -- TOOLPREFIX='' " + +Note that any other version of Clang must be installed only through +MSYS2 and target *-w64-windows-gnu to produce the correct .o files. + + +Option C - WinSDK via x86 Native Tools Command Prompt + 1. Do steps 1 to 3 from option A. + - Needs "MSVC v143 - VS 2022 C++ x64/86 Buildtool" for "Native Tools Command Prompt" + 2. Open an x86 Native Tools Command Prompt + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "..\common\SETPATH_MSYS2.BAT " + 4. Then execute the other batch files to build the VM + ..\common\MAKEDEBUG.BAT + ..\common\MAKEASSERT.BAT + ..\common\MAKEFAST.BAT + + + Each build directory contains two files plugins.int plugins.ext @@ -135,8 +136,6 @@ directory (which defaults to ../../src/plugins), and which are to be linked into the VM (plugins.int) or compiled as external dlls to be dynamically linked at run-time (plugins.ext). Tailor these files as you wish. -The Newspeak builds include an installer. See Building an MSI installer below. - Finally, at the building/win32x86 level the makeall script will run all the mvm scripts it can find. @@ -154,13 +153,13 @@ Building the VM Simulator Support Libraries If you want to get the Cog VM simulator working you'll need to build one or more of the processor simulator plugins, each of which has support libraries that must be built: - Processor Plugin Support Library - x86 BochsIA32Plugin building/win32x86/bochsx86 - x86_64/x64 BochsX64Plugin building/win32x86/bochsx64 - ARMv5 GdbARMPlugin building/win32x86/gdbarm32 - ARMv8 GdbARM64Plugin building/win32x86/gdbarm32 + Processor Plugin Support Library + x86 BochsIA32Plugin building/win32x86/bochsx86 + x86_64/x64 BochsX64Plugin building/win32x86/bochsx64 + ARMv5 GdbARMPlugin building/win32x86/gdbarm32 + ARMv8 GdbARMv8Plugin building/win32x86/gdbarm64 cd to the relevant directories; run conf.COG and then the build script, e.g. - $ cd building/linux32x86/bochsx86 + $ cd building/win32x86/bochsx64 $ ./conf.COG $ ./makeem @@ -168,24 +167,16 @@ Then when Squeak VMs are built they will include the plugin(s) for which support libraries have been provided. -Building an MSI installer (Newspeak) ------------------------------------- -The Newspeak builds include an installer subdirectory. The installer build -creates an MSI installer that provides a platform-conformat install experience -for the VM. First build the VM then cd to the installer and make, e.g.: - $ cd newspeak.cog.v3 - $ ./mvm - $ cd installer - $ make - - Optimization level and gcc version ---------------------------------- -There used to be issues with gcc version > 4.2.1. Any of the following flags may break the build at -O2: --ftree-pre --fpartial-inlining --fcaller-saves -However, with removal of some Undefined Behavior in source code, this list might well be out of date. +There used to be issues with gcc version > 4.2.1. Any of the following flags +may break the build at -O2: + -ftree-pre + -fpartial-inlining + -fcaller-saves + +However, with removal of some Undefined Behavior in source code, this list might +well be out of date. See http://smallissimo.blogspot.fr/2013/02/compiling-squeak-cog-virtual-machine-on.html @@ -200,7 +191,7 @@ unstripped VM to provide symbols, e.g. (gdb) file SqueakUnstripped.exe (gdb) run trunk.image -Note that on Cygwin, while cross-compilation works well, cross debugging does +Note that on MSYS2, while cross-compilation works well, cross debugging does not work at all. One has to debug 32-bit executables on a 32-bit installation with a 32-bit gdb, and 64-bit executables on a 64-bit installation with a 64-bit gdb. diff --git a/building/win32x86/common/Makefile b/building/win32x86/common/Makefile index 3c5781bc0d..7962383b72 100644 --- a/building/win32x86/common/Makefile +++ b/building/win32x86/common/Makefile @@ -1,8 +1,26 @@ ############################################################################# -# Common Makefile for Win32 VM using gcc, cygwin and gnu make +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Visit: https://www.msys2.org/ +# Visit: https://www.mingw-w64.org/ +# +# Make sure to install Clang via MSYS2 pacman to get a compiler that targets +# *-w64-windows-gnu . Other pre-built Clang bundles for Windows will target +# *-pc-windows-msvc . See Makefile.WinSDK for the MSVC toolchain. +# +# RECOMMENDED: Start MSYS2/MINGW64 environment, run "mvm" script. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# # Do make init to allow make -n to function. ############################################################################# +# Use SDKPREFIX configure custom build environments (e.g., .WinSDK). There +# are customization hooks for .rules, .rules.*, .tools, .tools.*, and .plugin +SDKPREFIX?= + ############################################################################# # Parameters: # VM the name of the exe to build, defaults to Squeak (=> Squeak.exe) @@ -54,7 +72,7 @@ else BUILD:=builddbg endif endif -$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory + PLUGINSRCDIR:= ../../../src export PLUGINSRCDIR OBJDIR:= $(BUILD)/vm @@ -71,14 +89,25 @@ WIN32UTILDIR:=$(PLATDIR)/win32/util CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) ifeq ($(THREADING),multi) -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terpmt.c $(VMSRCDIR)/cogit.c) else -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terp.c $(VMSRCDIR)/cogit.c) endif VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR) +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile$(SDKPREFIX).tools +include ../common/Makefile$(SDKPREFIX).tools.print +include ../common/Makefile$(SDKPREFIX).tools.flags +include ../common/Makefile$(SDKPREFIX).tools.defs + +############################################################################# +$(shell $(MKDIR) deps >/dev/null) # deps is the dependencies directory + ############################################################################# # The internal (.lib) and external (.dll) plugins # @@ -89,15 +118,22 @@ LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS))) DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS))) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBM_LIB?=libm.a +export LIBM_LIB +LIBS:=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) export BIT_IDENTICAL_FLOATING_POINT endif +.PHONY: libs dlls + +libs: $(LIBS) +dlls: $(DLLS) + ############################################################################# # The third-party libraries # ifneq ($(THIRDPARTYLIBS),) -include ../common/Makefile.lib.extra +include ../common/Makefile$(SDKPREFIX).lib.extra THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR) endif @@ -110,19 +146,9 @@ VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ)) ############################################################################# # SqueakVM definitions # -ifeq ($(CONFIGURATION),product) -VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe -CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe -STRIPEXE:= $(OBJDIR)/$(VM).exe -STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe -else VMEXE:= $(OBJDIR)/$(VM).exe CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe -STRIPEXE:= -STRIPCONSOLEEXE:= -endif VMDEF:= $(VM).def -VMEXP:= $(OBJDIR)/$(VM).exp VMMAP:= $(OBJDIR)/$(VM).map CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map VMLIB:= $(VM).lib @@ -130,16 +156,11 @@ VMRES:= $(VM).res VMDEFIN:=$(VM).def.in BTOBJ:= $(OBJDIR)/btext.o ETOBJ:= $(OBJDIR)/etext.o -JMPASM:=_setjmp-x86.asm -JMPOBJ:=$(OBJDIR)/_setjmp-x86.o +JMPASM:=_setjmp-$(ARCH).asm +JMPOBJ:=$(OBJDIR)/_setjmp-$(ARCH).o .PRECIOUS: mkNamedPrims.exe -############################################################################# -# Toolchain -# -include ../common/Makefile.tools - INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) .SUFFIXES: @@ -148,9 +169,13 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) ############################################################################# # Common build rules # +include ../common/Makefile$(SDKPREFIX).rules +include ../common/Makefile$(SDKPREFIX).rules.vm default: product # ensure two-pass initialization, see below -defaultBuild: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST) +defaultBuild: print-tools print-settings init vm vm-extra $(APPPOST) + +vm: libs $(VMEXE) $(CONSOLEVMEXE) dlls svnver: echo $(RC) $(RCFLAGS) @@ -179,25 +204,28 @@ init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg clean: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps cleanmt: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps cleanast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps cleanmtast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps cleandbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps cleanmtdbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps nukelibs: - rm $(LIBS) + $(RM) $(LIBS) + +nukedlls: + $(RM) $(DLLS) .PHONY : print-settings @@ -208,6 +236,7 @@ print-settings: $(info VPATH=$(VPATH)) $(info INCLUDES=$(INCLUDES)) $(info CFLAGS=$(CFLAGS)) + $(info DEFS=$(DEFS)) $(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS)) $(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS)) $(info OBJDIR=$(OBJDIR)) @@ -222,121 +251,64 @@ print-objects: $(info VMOBJ=$(VMOBJ)) $(info -----------------------------------------------------) -.PHONY : print-tools - -print-tools: - $(info ---------------- Build tools ------------------------) - $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) - $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) - $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) - $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) - $(info AR $(shell which $(ARX)) $(shell $(ARX) --version 2> /dev/null | head -n 1)) - $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) - $(info DLLTOOL $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) - $(info DLLWRAP $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) - $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) - $(info -----------------------------------------------------) - ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore))) -mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c - $(CC) -o $@ -mconsole -m32 $< - $(BTOBJ): $(WIN32MISCDIR)/btext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(ETOBJ): $(WIN32MISCDIR)/etext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(JMPOBJ): $(WIN32MISCDIR)/$(JMPASM) - $(AS) -o $@ $< - -vm: $(VMEXE) - -$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(LDFLAGS) -o $(VMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) - -$(CONSOLEVMEXE): $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) - -ifneq ($STRIPEXE,) -$(STRIPEXE): $(VMEXE) - $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) - -$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) - $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) -endif + $(CC) -c $< -o $@ $(OBJDIR): - @-mkdir $(BUILD) - mkdir $(OBJDIR) + @-$(MKDIR) $(BUILD) + $(MKDIR) $(OBJDIR) ifneq ($(INTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) endif ifneq ($(EXTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) endif -############################################################################# -# The exports for named primitives from Squeak (required by VM) -# -$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) - $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) - ############################################################################# # Building plugins # .PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll - +.PHONY: always # Check for Makefile in win32 plugins directory otherwise use default Makefile -plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.plugin ../common/Makefile.plugin))) +plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile$(SDKPREFIX).plugin ../common/Makefile$(SDKPREFIX).plugin))) # Internal plugin. Build as lib then link in lib -$(OBJDIR)/%.lib: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/vm/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.lib: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/vm/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) INTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ COGDEFS="$(COGDEFS) -DSQUEAK_BUILTIN_PLUGIN=$(*F)" $(OBJDIR)/$(*F).lib # External plugin. Build as dll and copy to vm dir ($(OBJDIR)). -$(OBJDIR)/%.dll: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.dll: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) EXTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ JMPOBJ=$(JMPOBJ) VMLIB=$(OBJDIR)/$(VMLIB) \ COGDEFS="$(COGDEFS) -DSQUEAK_EXTERNAL_PLUGIN=$(*F)" $(OBJDIR)/$(*F).dll +# Build fdlibm with GNU ar and GNU ranlib. Override $(LIBM_LIB) and add +# custom rule to choose, e.g., different librarian method. $(BUILD)/fdlibm/libm.a: - @-mkdir -p $(@D) + @-$(MKDIR) $(@D) $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ - TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote - - -############################################################################# -# Basic rules -# -include ../common/Makefile.rules - -$(VMRES): $(VM).rc - $(RC) $(RCFLAGS) -i $(VM).rc -o $@ - $(CP) $(VM).exe.manifest $(OBJDIR) - $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote libm.a -resource.o: $(VMRES) - $(RC) $(RCFLAGS) -i $< -o $@ ############################################################################# # Extra specific dependencies diff --git a/building/win32x86/common/Makefile.WinSDK b/building/win32x86/common/Makefile.WinSDK new file mode 100644 index 0000000000..254f2ae8f6 --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK @@ -0,0 +1,33 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# -> https://github.com/llvm/llvm-project/releases +# -> https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ +# -> https://visualstudio.microsoft.com/de/vs/community/ +# -> https://www.msys2.org/ +# +# Make sure to either use a Clang from MS Visual Studio or a pre-built +# clang that targets *-pc-windows-msvc. The Clang from MSYS2 pacman will +# target *-w64-windows-gnu . See Makefile for the MSYS2 toolchain. +# +# RECOMMENDED: Start plain MSYS2 shell, run "mvm" script. +# Alternative: Start Native Tools Command Prompt, run SETPATH then MAKE*.BAT. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Do make init to allow make -n to function. +############################################################################# + +SDKPREFIX:=.WinSDK +LIBM_LIB:=libm.lib + +include ../common/Makefile + +$(BUILD)/fdlibm/$(LIBM_LIB): + @-$(MKDIR) $(@D) + $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ + LIBRARIAN='$(LIBRARIAN)' \ + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote $(LIBM_LIB) diff --git a/building/win32x86/common/Makefile.WinSDK.lib.extra b/building/win32x86/common/Makefile.WinSDK.lib.extra new file mode 100644 index 0000000000..0367ef5b80 --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.lib.extra @@ -0,0 +1,12 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# THIRDPARTYLIBS The libraries to build (you define them in ./third-party/LIB/Makefile.lib) +# THIRDPARTYDIR Where to build libraries +# THIRDPARTYOUTDIR Where to first install libraries (output place) +# THIRDPARTYCACHEDIR Where to download thirdparty libraries +# +############################################################################# + +# Under construction. See Makefile.lib.extra for a template. diff --git a/building/win32x86/common/Makefile.WinSDK.plugin b/building/win32x86/common/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..c3de67bb3f --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.plugin @@ -0,0 +1,141 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Generic Makefile for plugins +############################################################################# +# +# The following variables can be overridden in the platform Makefile, e.g. +# platforms/win32/plugins/BochsIA32Plugin/Makefile. Look at +# platforms/win32/plugins/*/Makefile for examples. +# +# EXCLUDESRC defines patterns of source files to not compile, e.g. %/dump.c +# +# The following variables can be defined to extend the compilation flags. +# +# XCFLAGS adds additional compilation flags after all other C preprocessor define flags +# XINC adds additional include flags after all other INCLUDE flags +# +# The following are the three key locations (set via invocation): +# BUILDDIR: Where is the root of the build tree? +# PLATDIR: Where is the root of the platforms tree? +# SRCDIR: Where is the root of the src tree? (i.e. ../../../winbuild/src) + +############################################################################# +# Standard directory locations: +# CROSSDIR: The location of the cross platform sources +# WIN32DIR: The location of the win32 sources +# MAKERDIR: The location of the VMMaker generated sources +# BUILDDIR: The location where the plugin is built +# +CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME) +WIN32DIR:= $(PLATDIR)/win32/plugins/$(LIBNAME) +MAKERDIR:= $(PLUGINSRCDIR)/plugins/$(LIBNAME) +BUILDDIR:= $(BUILD)/$(LIBNAME) + +# Support directory locations +CROSSVMDIR:= $(PLATDIR)/Cross/vm +WIN32VMDIR:= $(PLATDIR)/win32/vm +WIN32MISCDIR:=$(PLATDIR)/win32/misc +MAKERVMDIR:= $(SRCDIR)/vm + +############################################################################# +# Standard include sources +# +INCLUDES:= -I. \ + -I$(VMSRCDIR) -I$(WIN32VMDIR) -I$(CROSSVMDIR) \ + -I$(MAKERDIR) -I$(WIN32DIR) -I$(CROSSDIR) + +############################################################################# +# If no source files were given, use standard set +# +CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) +WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) +MAKERSRC:= $(wildcard $(MAKERDIR)/*.c) +LIBSRC?= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) +ifneq ($(EXCLUDESRC),) +LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) +endif + +############################################################################# +# Plugin settings +# +OBJDIR:= $(BUILD)/$(LIBNAME) +VMDIR:= $(BUILD)/vm +PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib +PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll +LIBOBJ?= $(LIBSRC:.c=.o) +LIBOBJ:= $(LIBOBJ:.cpp=.o) +LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) +ifdef BIT_IDENTICAL_FLOATING_POINT +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) +endif + +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.WinSDK.tools +include ../common/Makefile.WinSDK.tools.flags +include ../common/Makefile.WinSDK.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.WinSDK.rules + +VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) + +all: $(PLUGINLIB) $(PLUGINDLL) + +.PHONY : print-settings + +print-settings: + $(info ---------------- Makefile settings ------------------) + $(info PATH='$(PATH)') + $(info VPATH='$(VPATH)') + $(info INCLUDES='$(INCLUDES)') + $(info DEFS='$(DEFS)') + $(info CFLAGS='$(CFLAGS)') + $(info SRCDIR='$(SRCDIR)') + $(info CROSSDIR='$(CROSSDIR)') + $(info WIN32DIR='$(WIN32DIR)') + $(info WIN32MISCDIR='$(WIN32MISCDIR)') + $(info MAKERDIR='$(MAKERDIR)') + $(info CROSSSRC='$(CROSSSRC)') + $(info WIN32SRC='$(WIN32SRC)') + $(info MAKERSRC='$(MAKERSRC)') + $(info EXCLUDESRC='$(EXCLUDESRC)') + $(info LIBSRC='$(LIBSRC)') + $(info LIBOBJ='$(LIBOBJ)') + $(info OBJDIR='$(OBJDIR)') + $(info VMDIR='$(VMDIR)') + $(info VMLIB='$(VMLIB)') + $(info PLUGINSRCDIR='$(PLUGINSRCDIR)') + $(info PLUGINLIB='$(PLUGINLIB)') + $(info PLUGINDLL='$(PLUGINDLL)') + $(info PLUGINDLL_LIBS='$(PLUGINDLL_LIBS)') + $(info XINC='$(XINC)') + $(info XDEFS='$(XDEFS)') + $(info -----------------------------------------------------) + +$(OBJDIR): + $(MKDIR) $(subst /,\\,$(OBJDIR)) + +$(VMDIR): + $(MKDIR) $(subst /,\\,$(VMDIR)) + +$(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(LIBSRC) + -$(RM) $(PLUGINLIB) + $(LIBRARIAN) $(LIBOBJ) $(EXTRALIBS) -out:$(subst /,\\,$(PLUGINLIB)) + +PLUGINDLL_LIBS:=WinMM.lib ole32.lib msdmo.lib user32.lib kernel32.lib /NODEFAULTLIB:libc /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt + +$(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(JMPOBJ) $(LIBSRC) + $(LD) $(LDFLAGS) -DLL $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(PLUGINDLL_LIBS) $(EXTRALIBS) \ + -NOIMPLIB \ + -LIBPATH:$(BUILD)/vm \ + -OUT:$(subst /,\\,$(PLUGINDLL)) diff --git a/building/win32x86/common/Makefile.WinSDK.rules b/building/win32x86/common/Makefile.WinSDK.rules new file mode 100644 index 0000000000..191e0c153b --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.rules @@ -0,0 +1,16 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +include ../common/Makefile.rules + +# Microsoft (R) Windows (R) Resource Compiler; see Makefile.WinSDK +# %.res: %.rc +# $(RC) $(RCFLAGS) -Fo $@ $< diff --git a/building/win32x86/common/Makefile.WinSDK.rules.vm b/building/win32x86/common/Makefile.WinSDK.rules.vm new file mode 100644 index 0000000000..55034381ae --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.rules.vm @@ -0,0 +1,38 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -c $< -o mkNamedPrims.obj + $(LD) -out:$@ mkNamedPrims.obj -subsystem:console -defaultlib:libcmt + +.PHONY: vm-extra +vm-extra: + $(info No extra things to do for the VM.) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -OUT:$(VMEXE) -MAP:$(VMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +$(CONSOLEVMEXE): $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o$(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -OUT:$(CONSOLEVMEXE) -MAP:$(CONSOLEVMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +# Microsoft (R) Windows (R) Resource Compiler +%.res: %.rc + $(RC) $(RCFLAGS) -Fo $@ $< + +# Microsoft (R) Windows Resource To Object Converter +resource.o: $(VMRES) + $(CVTRES) -MACHINE:$(ARCH) -OUT:resource.o $(VMRES) + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win32x86/common/Makefile.WinSDK.tools b/building/win32x86/common/Makefile.WinSDK.tools new file mode 100644 index 0000000000..1f226bf619 --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.tools @@ -0,0 +1,98 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# Supported architecures: x86, x64, arm64 +ARCH:=x86 +# Export ARCH to be used in plugins such as IA32ABI (i.e. FFI callbacks) +export ARCH + +############################################################################# +# Set paths to toolchain. Note that $(LLVM_BIN) and $(MSYS2_BIN) may be +# empty, relying on $(PATH) to find those tools. +# + +include ../common/Makefile.WinSDK.tools.paths + +ifeq ($(VCToolsBinDir),) + $(error Failed to locate Visual Studio build tools!) +endif + +ifeq ($(WindowsSDKToolsBinDir),) + $(error Failed to locate Windows SDK build tools!) +endif + +ifeq ($(LLVM_BIN),) + $(info Using clang from PATH...) +endif + +ifeq ($(MSYS2_BIN),) + $(info Using GNU tools from PATH...) +endif + +############################################################################# +# C compiler settings +# + +CC:=$(LLVM_BIN)clang +CXX:=$(LLVM_BIN)clang++ + +TZ:=$(shell $(MSYS2_BIN)date +%Z) + +############################################################################# +# Linker settings +# +LD:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LDCXX:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LIBRARIAN:=$(VCToolsBinDir)/LIB -nologo + +BASELDFLAGS:= -DYNAMICBASE -LARGEADDRESSAWARE -NXCOMPAT -DEBUG:FULL +LDFLAGS:= -subsystem:windows $(BASELDFLAGS) $(EXTRALDFLAGS) +CONSOLELDFLAGS:= -subsystem:console $(BASELDFLAGS) $(EXTRALDFLAGS) +DL:=-DEFAULTLIB: +NDL:=-NODEFAULTLIB: + +ifdef BIT_IDENTICAL_FLOATING_POINT +EXTRANDLS:=-NODEFAULTLIB:libm +endif +STDLIBS:=$(STDLIBS) $(NDL)libc $(NDL)libcmt $(EXTRANDLS) $(DL)msvcrt \ + dinput8.lib dsound.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \ + version.lib wininet.lib user32.lib gdi32.lib psapi.lib \ + advapi32.lib kernel32.lib secur32.lib shell32.lib shfolder.lib + +############################################################################# +# Tools to use (usually all from GNU coreutils). If $(MSYS2_BIN) +# prefix is empty, rely on $(PATH) to find tools. +# +CP:= $(MSYS2_BIN)cp +RM:= $(MSYS2_BIN)rm +MV:= $(MSYS2_BIN)mv +MKDIR:=$(MSYS2_BIN)mkdir -p + +############################################################################# +# RC settings, Microsoft Resource Compiler +# CVTRES settings, Microsoft Resource To Object Converter +# +# Note: RC compiles the .rc files into linkable .o files +# +RC:=$(WindowsSDKToolsBinDir)/rc -nologo +CVTRES:=$(VCToolsBinDir)/cvtres -nologo +SED:=$(MSYS2_BIN)sed +GREP:=$(MSYS2_BIN)grep +BASH:=$(MSYS2_BIN)bash +SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h + +ifneq ($(shell $(GREP) 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) +$(shell $(BASH) -c "cd ../../../scripts; ./updateSCCSVersions") +endif +SVNMAJOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: \([0-9][0-9][0-9][0-9]\).*/\\1/p" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNMINOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNREV := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNBUILD := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]*\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') + +RCFLAGS:= -i $(PLATDIR)/win32/misc -D_WIN32 -DFILEVERSIONVALUES=$(SVNMAJOR),$(SVNMINOR),$(SVNREV),$(SVNBUILD) -DFILEVERSIONSTRING="\"$(SVNMAJOR).$(SVNMINOR).$(SVNREV).$(SVNBUILD)\"" diff --git a/building/win32x86/common/Makefile.WinSDK.tools.defs b/building/win32x86/common/Makefile.WinSDK.tools.defs new file mode 100644 index 0000000000..dddc7431dc --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.tools.defs @@ -0,0 +1,32 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +include ../common/Makefile.tools.defs + +############################################################################# + +# Make all setjmp/longjmp varieties to our _setjmp/_longjmp in _setjmp-x86.asm +JMPDEFS:=-Dsetjmp=_setjmp -Dlongjmp=_longjmp -D_siglongjmp=_longjmp +DEFS:= $(JMPDEFS) $(DEFS) + +# ??? +FUNDEFS:=-Dalloca=_alloca -Dhuge=my_huge +DEFS:= $(FUNDEFS) $(DEFS) + + + + + + + +# Do _not_ define NDEBUG. The entire point of the msvc build is to debug with +# MSVC and defining NDEBUG installs a default catch-everything exception handler +# that effectively disables debugging. +# XDEFS= -DSQUEAK_BUILTIN_PLUGIN diff --git a/building/win32x86/common/Makefile.WinSDK.tools.flags b/building/win32x86/common/Makefile.WinSDK.tools.flags new file mode 100644 index 0000000000..6aca6be989 --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.tools.flags @@ -0,0 +1,18 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +# Skip mingw-w64 specific configuration flags that should not be required +# when using a clang that targets msvc format. +NOBUILTIN= +CALLING_CONVENTION= +BITFIELD_LAYOUT= +DECLSPEC= + +include ../common/Makefile.tools.flags diff --git a/building/win32x86/common/Makefile.WinSDK.tools.paths b/building/win32x86/common/Makefile.WinSDK.tools.paths new file mode 100644 index 0000000000..48b6eebe5f --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.tools.paths @@ -0,0 +1,123 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany + +# Check or lookup paths to the compiler, other build tools (e.g., GNU make or +# MS Link), and the Windows SDK. +############################################################################# + +WindowsSdkMajorVersion:=10 +HostARCH:=HostX64 + +ifeq ($(MSYS2_BIN),) + MSYS2_BIN:=c:/msys64/usr/bin/ +else + override MSYS2_BIN:=$(subst \,/,$(MSYS2_BIN)) +endif + +############################################################################# +# Set paths to the Windows SDK (and tools) and Visual Studio (and tools) +# +ifeq ($(VCINSTALLDIR),) + # ../[2017 2022]/[Community Enterprise]/VC + VCINSTALLDIR:=C:/Program\ Files/Microsoft\ Visual\ Studio/*/*/VC + VCINSTALLDIR:=$(wildcard $(VCINSTALLDIR)) +else + override VCINSTALLDIR:=$(subst \,/,$(VCINSTALLDIR)) +endif + +ifeq ($(VCToolsInstallDir),) + # ../MSVC/[14.29.30133 14.44.35207] + VCToolsInstallDir:=$(VCINSTALLDIR)/Tools/MSVC/* + VCToolsInstallDir:=$(shell echo "$(VCToolsInstallDir)" | sed 's/ /\\ /g') + VCToolsInstallDir:=$(wildcard $(VCToolsInstallDir)) + # To make sort and lastword work, mask space-ridden VCINSTALLDIR + VCToolsInstallDir:=$(subst $(VCINSTALLDIR),%MAKETMP123%,$(VCToolsInstallDir)) + VCToolsInstallDir:=$(sort $(VCToolsInstallDir)) + VCToolsInstallDir:=$(lastword $(VCToolsInstallDir)) + VCToolsInstallDir:=$(subst %MAKETMP123%,$(VCINSTALLDIR),$(VCToolsInstallDir)) +else + override VCToolsInstallDir:=$(subst \,/,$(VCToolsInstallDir)) +endif + + +############################################################################# +# Set paths to LLVM, for compilers (and maybe other build tools). +# Note that Visual Studio ships its own version of LLVM/Clang these days. +# Note that Clang for x86 (32-bit) is in "bin", not "x86/bin" +# + +# LLVM_BIN:=c:/llvm/bin/ + +VCLlvmInstallDir:=$(VCINSTALLDIR)/Tools/Llvm +LLVM_BIN:=$(VCLlvmInstallDir)/bin/ + +# Must escape whitespace and parentheses for scripts +LLVM_BIN:=$(shell echo "$(LLVM_BIN)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to MSVC linker and library tools, LINK and LIB. +# + +VCToolsBinDir:=$(VCToolsInstallDir)/bin/$(HostARCH)/$(ARCH) +VCToolsBinDir:=$(shell echo "$(VCToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to Windows SDK and tools (e.g. RC and CVTRES). +# +ifeq ($(WindowsSdkDir),) + WindowsSdkDir:=C:/Program Files (x86)/Windows Kits/$(WindowsSdkMajorVersion)/ +else + override WindowsSdkDir:=$(subst \,/,$(WindowsSdkDir)) +endif +ifeq ($(WindowsSDKVersion),) + WindowsSDKVersion:=$(WindowsSdkDir)/include/$(WindowsSdkMajorVersion)* + WindowsSDKVersion:=$(shell echo "$(WindowsSDKVersion)" | sed 's/ /\\ /g') + WindowsSDKVersion:=$(wildcard $(WindowsSDKVersion)) + WindowsSDKVersion:=$(subst $(WindowsSdkDir)/include/,,$(WindowsSDKVersion)) + # Use only newest SDK version + WindowsSDKVersion:=$(sort $(WindowsSDKVersion)) + WindowsSDKVersion:=$(lastword $(WindowsSDKVersion)) +endif +override WindowsSDKVersion:=$(subst \,,$(WindowsSDKVersion)) + +WindowsSDKToolsBinDir:=$(WindowsSdkDir)/bin/$(WindowsSDKVersion)/$(ARCH) +WindowsSDKToolsBinDir:=$(shell echo "$(WindowsSDKToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to INCLUDE headers from Visual Studio (e.g., COM stuff) and +# Windows SDK (e.g., standard C library). +# +ifeq ($(INCLUDE),) +INCLUDE:=$(VCToolsInstallDir)/ATLMFC/include;$(VCToolsInstallDir)/include;$(VCINSTALLDIR)/Auxiliary/VS/include;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/shared;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/ucrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/um;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/winrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/cppwinrt +INCLUDE:=$(subst //,/,$(INCLUDE)) +INCLUDE:=$(subst /,\,$(INCLUDE)) +#$(info INCLUDE is $(INCLUDE)) +endif +MSVCINCLUDES:=-I"$(subst \,/,$(subst ;," -I",$(INCLUDE)))" +#$(info MSVCINCLUDES is $(MSVCINCLUDES)) + +# Put -I. last because boost includes bizarreness such as +# include which will include a local file called list if -I. comes +# early in the include path. Fragile. +INCLUDES:= $(filter-out -I., $(INCLUDES)) $(MSVCINCLUDES) $(XINC) -I. + + +############################################################################# +# Set paths to system libraries from Visual Studio (e.g. COM stuff) and +# Windows SDK (e.g., standard C lib). +# +ifeq ($(LIB),) +LIB:=$(VCToolsInstallDir)/ATLMFC/lib/$(ARCH);$(VCToolsInstallDir)/lib/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/ucrt/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/um/$(ARCH) +LIB:=$(subst //,/,$(LIB)) +LIB:=$(subst /,\,$(LIB)) +export LIB +endif +# $(info LIB is $(LIB)) diff --git a/building/win32x86/common/Makefile.WinSDK.tools.print b/building/win32x86/common/Makefile.WinSDK.tools.print new file mode 100644 index 0000000000..e1d184606a --- /dev/null +++ b/building/win32x86/common/Makefile.WinSDK.tools.print @@ -0,0 +1,30 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info VCToolsBinDir $(VCToolsBinDir)) + $(info WindowsSDKToolsBinDir $(WindowsSDKToolsBinDir)) + $(info WindowsSdkDir $(WindowsSdkDir)) + $(info WindowsSDKVersion $(WindowsSDKVersion)) + $(info MSYS2_BIN $(MSYS2_BIN)) + $(info LLVM_BIN $(LLVM_BIN)) + $(info CC $(shell which $(CC))) + $(info .. $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info CXX $(shell which $(CXX))) + $(info .. $(shell $(CXX) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD) 2> /dev/null)) + $(info LDXX $(shell which $(LD) 2> /dev/null)) + $(info LIBRARIAN $(shell which $(LIBRARIAN) 2> /dev/null)) + $(info RC $(shell which $(RC) 2> /dev/null)) + $(info CVTRES $(shell which $(CVTRES) 2> /dev/null)) + $(info -----------------------------------------------------) diff --git a/building/win32x86/common/Makefile.lib.extra b/building/win32x86/common/Makefile.lib.extra index a2cd8c7bd2..26b426cd5c 100644 --- a/building/win32x86/common/Makefile.lib.extra +++ b/building/win32x86/common/Makefile.lib.extra @@ -10,7 +10,7 @@ THIRDPARTYDIR?=$(BUILD)/third-party THIRDPARTYLIBDIR?=$(THIRDPARTYOUTDIR)/bin THIRDPARTYINCLUDEDIR?=$(THIRDPARTYOUTDIR)/include THIRDPARTYCACHEDIR?=../../../.thirdparty-cache -THIRDPARTYOUTDIR?=$(abspath $(THIRDPARTYCACHEDIR)/windows/i386) +THIRDPARTYOUTDIR?=$(abspath $(THIRDPARTYCACHEDIR)/windows/i686) export THIRDPARTYOUTDIR THIRDPARTYINSTALLDIR?=$(BUILD)/vm THIRDPARTY_CFLAGS?=-m32 -static-libgcc -static-libstdc++ @@ -18,8 +18,7 @@ THIRDPARTY_LDFLAGS?=-m32 -static-libgcc -static-libstdc++ WGET?=wget -q --no-check-certificate #I need this toolchain to compile external libraries with appropriate gcc -THIRDPARTY_TOOLCHAIN_PREFIX:=i686-w64-mingw32- -THIRDPARTY_TOOLCHAIN:=CC=$(THIRDPARTY_TOOLCHAIN_PREFIX)gcc AR=$(THIRDPARTY_TOOLCHAIN_PREFIX)ar LD=$(THIRDPARTY_TOOLCHAIN_PREFIX)clang NM=$(THIRDPARTY_TOOLCHAIN_PREFIX)nm RC=$(THIRDPARTY_TOOLCHAIN_PREFIX)windres DLLTOOL=$(THIRDPARTY_TOOLCHAIN_PREFIX)dlltool DLLWRAP=$(THIRDPARTY_TOOLCHAIN_PREFIX)dllwrap +THIRDPARTY_TOOLCHAIN:=CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-mingw32-clang NM=i686-w64-mingw32-nm RC=i686-w64-mingw32-windres DLLTOOL=i686-w64-mingw32-dlltool DLLWRAP=i686-w64-mingw32-dllwrap $(THIRDPARTYDIR): diff --git a/building/win32x86/common/Makefile.plugin b/building/win32x86/common/Makefile.plugin index 1b9cbb0736..add97f8562 100644 --- a/building/win32x86/common/Makefile.plugin +++ b/building/win32x86/common/Makefile.plugin @@ -1,5 +1,11 @@ ############################################################################# -# Generic Makefile for plugins on Win32 +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Generic Makefile for plugins on Win64 ############################################################################# # # The following variables can be overridden in the platform Makefile, e.g. @@ -47,37 +53,6 @@ ifneq ($(EXCLUDESRC),) LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) endif -############################################################################# -# C compiler settings (gcc 4.x) -# -include ../common/Makefile.tools - -# overrides of default toolchain settings - -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O1 -march=pentium4 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:=-DNDEBUG -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -march=pentium4 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -else -OFLAGS:= -march=pentium4 -DEBUGVM=1 -NDEBUG:= -endif - -XDEFS:= -DEFS:= $(WINVER) -DWIN32=1 -DNO_ISNAN \ - -DNO_SERVICE \ - $(NDEBUG) -DLSB_FIRST -DVM_NAME=\"$(VM)\" -DX86 $(XDEFS) - - -CFLAGS:= -msse2 -ggdb2 -m32 \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) $(COGDEFS) - - ############################################################################# # DLL settings # @@ -86,9 +61,6 @@ CFLAGS:= -msse2 -ggdb2 -m32 \ # OPTSTRIP:= echo not doing strip - -.SUFFIXES: .c .cpp .o .s .rc .res .dep - ############################################################################# # Plugin settings # @@ -99,9 +71,20 @@ PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll LIBOBJ ?= $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LIBSRC))) LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBOBJ+=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) endif +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.tools +include ../common/Makefile.tools.flags +include ../common/Makefile.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.rules VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) @@ -124,6 +107,7 @@ print-settings: $(info WIN32SRC=$(WIN32SRC)) $(info MAKERSRC=$(MAKERSRC)) $(info LIBSRC=$(LIBSRC)) + $(info EXCLUDESRC=$(EXCLUDESRC)) $(info LIBOBJ=$(LIBOBJ)) $(info OBJDIR=$(OBJDIR)) $(info VMDIR=$(VMDIR)) @@ -132,10 +116,10 @@ print-settings: $(info -----------------------------------------------------) $(OBJDIR): - mkdir $(OBJDIR) + $(MKDIR) $(OBJDIR) $(VMDIR): - mkdir $(VMDIR) + $(MKDIR) $(VMDIR) # If any prerequisites are declared all must exist to continue ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES))) @@ -150,13 +134,12 @@ $(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ) --output-exp $(OBJDIR)/$(LIBNAME).exp \ --output-lib $(OBJDIR)/$(LIBNAME).lib \ $(DLLTOOLEXTRAS) \ - $(LIBOBJ) + $(LIBOBJ) $(JMPOBJ) ifneq ($(LINK_WITH_GCC),) $(CC) -shared \ -m32 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ - --entry _DllMain@12 \ $(GCCLINKEXTRAS) \ $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS) else ifneq ($(LINK_WITH_GPP),) @@ -164,24 +147,18 @@ else ifneq ($(LINK_WITH_GPP),) -m32 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ - --entry _DllMain@12 \ $(GPPLINKEXTRAS) \ $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS) else - $(DLLWRAP) -mwindows \ + $(DLLWRAP) -mwindows -m32 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ - --entry _DllMain@12 \ $(DLLWRAPEXTRAS) \ $(OBJDIR)/$(LIBNAME).exp \ $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS) endif $(OPTSTRIP) --strip-all $(VMDIR)/$(LIBNAME).dll -$(RM) $(OBJDIR)/$(LIBNAME).lib -############################################################################# -# Rules for automated builds -# -include ../common/Makefile.rules else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES)) # If any prerequisites are missing simply create a .ignore file diff --git a/building/win32x86/common/Makefile.rules b/building/win32x86/common/Makefile.rules index 30d820af2f..5079d6e59d 100644 --- a/building/win32x86/common/Makefile.rules +++ b/building/win32x86/common/Makefile.rules @@ -1,32 +1,51 @@ ############################################################################# -# Compilation rules for Microsoft Windows +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. # +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +.SUFFIXES: .c .cpp .o .s .rc .res .dep + +############################################################################# # See http://make.mad-scientist.net/papers/advanced-auto-dependency-generation # for an explanation of the dependency management scheme. - +# +$(info OBJDIR is $(OBJDIR)) ifeq ($(findstring /vm,$(OBJDIR)),/vm) BD:=$(BUILD)/vm else -BD:=$(BUILD)/$(LIBNAME)/vm +BD:=$(BUILD)/$(LIBNAME) endif -ALLFLAGS = $(CFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.c - $(CC) -x c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +# Not interested in recording system header dependencies. *must* use " = " +DEPFLAGS = -MMD -MT '$(BD)/$(*F).o' -MF deps/$(*F).d +############################################################################# -$(OBJDIR)/%.o: %.m - $(CC) -x objective-c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +ALLCFLAGS = $(DEPFLAGS) $(CFLAGS) $(INCLUDES) $(DEFS) +ALLCXXFLAGS = $(DEPFLAGS) $(CXXFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.cpp - $(CXX) -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +############################################################################# +# Rules for automated builds using LLVM/Clang +# -%res: %.rc - $(RC) $(RCFLAGS) -i $< -o $@ +$(OBJDIR)/%.o: %.c + $(CC) -o $@ $(ALLCFLAGS) -c $< + +$(OBJDIR)/%.o: %.cpp + $(CC) -o $@ $(ALLCXXFLAGS) -c $< +# GNU windres (GNU Binutils); see Makefile +# %.res: %.rc +# $(RC) $(RCFLAGS) -i $< -o $@ deps/%.d: ; .PRECIOUS: deps/%.d --include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC)))) +-include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC) $(LIBSRC)))) diff --git a/building/win32x86/common/Makefile.rules.vm b/building/win32x86/common/Makefile.rules.vm new file mode 100644 index 0000000000..ec7382816a --- /dev/null +++ b/building/win32x86/common/Makefile.rules.vm @@ -0,0 +1,70 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for building the VM binary itself +############################################################################# + +ifeq ($(CONFIGURATION),product) +VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe +STRIPEXE:= $(OBJDIR)/$(VM).exe +STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe +else +VMEXE:= $(OBJDIR)/$(VM).exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe +STRIPEXE:= +STRIPCONSOLEEXE:= +endif + +############################################################################# +# The exports for named primitives from Squeak (required by VM) +# +VMEXP:= $(OBJDIR)/$(VM).exp +$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) + $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) + +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -o $@ -mconsole -m32 $< + +.PHONY: vm-extra +vm-extra: $(STRIPEXE) $(STRIPCONSOLEEXE) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -o $(VMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) + +$(CONSOLEVMEXE): $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCLFAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) + +ifneq ($STRIPEXE,) +$(STRIPEXE): $(VMEXE) + $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) + +$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) + $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) +endif + +############################################################################# + +# GNU windres (GNU Binutils) +%.res: %.rc + $(RC) $(RCFLAGS) -i $< -o $@ + +# GNU windres (GNU Binutils) +resource.o: $(VMRES) + $(RC) $(RCFLAGS) -i $< -o $@ + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win32x86/common/Makefile.tools b/building/win32x86/common/Makefile.tools index 11d9b37d39..89f53caad7 100644 --- a/building/win32x86/common/Makefile.tools +++ b/building/win32x86/common/Makefile.tools @@ -1,6 +1,10 @@ ############################################################################# -# Compilation rules for 32-bit Cygwin/mingw compiler on Microsoft Windows +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. # +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# ARCH:=x86 export ARCH @@ -9,73 +13,18 @@ TOOLPREFIX:=i686-w64-mingw32- export TOOLPREFIX ############################################################################# -# C compiler settings (Use clang for non-default .manifest file) +# C compiler settings (Use clang for having a working FFI) # -ifeq ($(COMPILER_TO_USE),) -COMPILER_TO_USE:=clang -endif - -ifeq ($(COMPILER_TO_USE),clang) -AS:= $(TOOLPREFIX)clang -c CC:= $(TOOLPREFIX)clang CXX:= $(TOOLPREFIX)clang++ -else -AS:= $(TOOLPREFIX)as -CC:= $(TOOLPREFIX)gcc -CXX:= $(TOOLPREFIX)g++ -endif - -WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-value -Wno-unused-function - -# VM config flags. -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O2 -march=pentium4 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -march=pentium4 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -else -OFLAGS:= -march=pentium4 -DEBUGVM=1 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -endif - -ifeq ($(IS_PREPARING),false) - ifeq ($(THREADING),multi) - COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) - else - COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) - endif - - ifeq ($(COMPILER_TO_USE),clang) - COGDEFS:=$(COGDEFS) -fno-stack-protector - endif -endif # IS_PREPARING - -# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h) -WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 - -# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h -NOBUILTIN:= -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf -CFLAGS:= -msse2 -ggdb2 -m32 \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) TZ:=$(shell date +%Z) -DEFS:= $(COGDEFS) $(WINVER) -DWIN32=1 -DNO_ISNAN \ - -DNO_SERVICE -D'TZ="$(TZ)"' \ - $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) ############################################################################# # Linker settings # -# Note: I had to use 'gcc' instead of 'ld' to prevent unresolved symbols -# The switch '-mwindows' gives us a GUI app instead of a console app. -# Newer cygwins want --export-all-symbols in place of --export-dynamic. -# -LD:= $(CC) -LDCXX := $(TOOLPREFIX)clang++ # For linking c++ bundles +LD:=$(CC) +LDCXX:=$(CXX) # For linking c++ bundles EXPORT:=--export-all-symbols BASELDFLAGS:=-m32 -mthreads -Wl,--large-address-aware,--dynamicbase,--nxcompat,$(EXPORT) @@ -87,15 +36,18 @@ STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \ ############################################################################# # Tools to use +# - Note that "dllwrap" is replaced by "clang -shared" +# - Note that "ar" produces thin archives (-T) to allow mising .o and .a # -AR:= $(TOOLPREFIX)ar rc -ARX:= $(TOOLPREFIX)ar # must not change $(AR) bc. implicit usage +AR:= $(TOOLPREFIX)ar crUuT CP:= cp RM:= rm SED:=sed +MV:=mv +MKDIR:=mkdir -p NM:= $(TOOLPREFIX)nm DLLTOOL:= $(TOOLPREFIX)dlltool -DLLWRAP:= $(TOOLPREFIX)gcc -shared +DLLWRAP:= $(CC) -shared STRIP:= $(TOOLPREFIX)strip OBJCOPY:= $(TOOLPREFIX)objcopy @@ -104,7 +56,7 @@ OBJCOPY:= $(TOOLPREFIX)objcopy # # Note: RC compiles the .rc files into linkable .o files # -RC:= $(TOOLPREFIX)windres +RC:=$(TOOLPREFIX)windres SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h ifneq ($(shell grep 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) diff --git a/building/win32x86/common/Makefile.tools.defs b/building/win32x86/common/Makefile.tools.defs new file mode 100644 index 0000000000..f632c5451e --- /dev/null +++ b/building/win32x86/common/Makefile.tools.defs @@ -0,0 +1,66 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +############################################################################# + +# See sdkddkver.h from Windows SDK or w32api.h from mingw-w64 +# Windows XP ... 0x0501 +# Windows 7 ... 0x0601 +# Windows 8 ... 0x0602 +# Windows 10 ... 0x0A00 +WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 + +# Every clang for Windows (i.e. *-pc-windows-msvc or *-w64-windows-gnu) already +# defines WIN32, _WIN32 etc. So, this might just be historical overhead. +WINBIT:=-DWIN32=1 -D_WIN32=1 + +#!#! UNICODE applies to API calls, _UNICODE to string representation, so one +#!#! must define both. +WINUNI:=-DUNICODE=1 -D_UNICODE=1 + +############################################################################# +# DEFS +# +ifeq ($(CONFIGURATION),product) +DEBUGVM= 0 +NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts +else ifeq ($(CONFIGURATION),assert) +DEBUGVM= 0 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +else +DEBUGVM= 1 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +endif + +ifeq ($(IS_PREPARING),false) + ifeq ($(THREADING),multi) + COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) + else + COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) + endif + ifdef BIT_IDENTICAL_FLOATING_POINT + COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1 + endif +endif # IS_PREPARING + +# Several versions of clang (all versions from 14 through 18 as of this writing) +# generate incorrect code for spur segment storage +# (return:restoringObjectsIn:savedFirstFields:and:savedHashes:) +# unless USE_INLINE_MEMORY_ACCESSORS is set. +MEMACCESS?=-DUSE_INLINE_MEMORY_ACCESSORS=1 + +# Multi-threaded environment. Might in case use multi-threading specific +# versions of API calls. Also used to avoid built-in functions. +MT_ENV?=-D_MT + +# Use fdlibm for floating-point, which is cross-platform, or +# platform-specific floating point. See COGDEFS. +BIT_IDENTICAL_FLOATING_POINT=1 + +DEFS:=-D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) $(WINBIT) \ + $(WINUNI) $(MT_ENV) -D'TZ="$(TZ)"' -DNO_ISNAN -DNO_SERVICE \ + $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) diff --git a/building/win32x86/common/Makefile.tools.flags b/building/win32x86/common/Makefile.tools.flags new file mode 100644 index 0000000000..491c86d57b --- /dev/null +++ b/building/win32x86/common/Makefile.tools.flags @@ -0,0 +1,78 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (incl. OFLAGS and DEFS) for LLVM/Clang +############################################################################# + +# Enable all but several warnings +WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label \ + -Wno-unused-value -Wno-unused-function -Wno-missing-variable-declarations \ + -Wno-unused-macros -Wno-sign-compare -Wno-sign-conversion -Wno-pedantic \ + -Wno-reserved-id-macro -Wno-undef + +############################################################################# +# OFLAGS (VM and Plugins) +# + +# Turn off BUFFER_SECURITY for functional setjmp/longjmp +BUFFER_SECURITY:=-fno-stack-protector -D_CRT_SECURE_NO_WARNINGS + +# For exception handing we require a frame pointer (e.g. for unwind). +# Clang supports both +# -fno-omit-frame-pointer +# -fno-omit-leaf-frame-pointer +# We assume that when when not omitting the frame pointer, Clang will still +# omit the leaf frame pointers, which is fine. +FRAME_POINTER_FLAGS:=-fno-omit-frame-pointer -DcFramePointerInUse=1 + +ifeq ($(CONFIGURATION),product) + # For fast/production builds, use -O2 optimization + OFLAGS= -O2 -finline-hint-functions -funroll-loops $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else ifeq ($(CONFIGURATION),assert) + # For assert builds, use -Os optimization, which is similar to -O2 + OFLAGS= -Os -fno-builtin $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else + # For debug builds, minimize optimization, even has leaf-frame-pointers + OFLAGS= -O0 $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +endif + +# FYI +# -Ob enable inline expansion -Oy omit frame pointer, Oi enable intrinsics + + +############################################################################# +# CFLAGS +# +NOBUILTIN?=-fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf + +# Include extra debugging information. +DEBUG_LEVEL?=-g3 + +# Enable exceptions for debugging purposes. +EXCEPTION_FLAGS?=-fexceptions +CXX_EXCEPTION_FLAGS?=-fexceptions -fcxx-exceptions + +# No __STDCALL calling convention by default. Stick to __CDECL. +CALLING_CONVENTION?=-mno-rtd + +# Keep default structure layout compatible with Microsoft standards. +BITFIELD_LAYOUT?=-mms-bitfields + +# Allow __declspec keyword. +# See https://learn.microsoft.com/cpp/cpp/declspec +DECLSPEC?=-fdeclspec + +CFLAGS= $(DECLSPEC) -msse2 $(DEBUG_LEVEL) -m32 -march=pentium4 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + +CXXFLAGS= $(DECLSPEC) -msse2 $(DEBUG_LEVEL) -m32 -march=pentium4 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(CXX_EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + diff --git a/building/win32x86/common/Makefile.tools.print b/building/win32x86/common/Makefile.tools.print new file mode 100644 index 0000000000..29c9b26961 --- /dev/null +++ b/building/win32x86/common/Makefile.tools.print @@ -0,0 +1,24 @@ +############################################################################# +# Common Makefile for Win32 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) + $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) + $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) + $(info AR $(shell command -v $(AR)) $(shell $(AR) --version 2> /dev/null | head -n 1)) + $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) + $(info DLLTOOL $(shell command -v $(DLLTOOL)) $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) + $(info DLLWRAP $(shell command -v $(DLLWRAP)) $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) + $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) + $(info -----------------------------------------------------) diff --git a/building/win32x86/common/SETPATH_MSYS2.BAT b/building/win32x86/common/SETPATH_MSYS2.BAT new file mode 100644 index 0000000000..4c51b469d4 --- /dev/null +++ b/building/win32x86/common/SETPATH_MSYS2.BAT @@ -0,0 +1,3 @@ +REM We recommend to run MAKE from a normal MSYS2 environment but it also works +REM from within a Native Tools Command Prompt (Visual Studio Community). +set PATH=%PATH%;c:\msys64\bin diff --git a/building/win32x86/squeak.cog.spur.lowcode/Makefile b/building/win32x86/squeak.cog.spur.lowcode/Makefile index 20d2fc6664..fe1b23883c 100644 --- a/building/win32x86/squeak.cog.spur.lowcode/Makefile +++ b/building/win32x86/squeak.cog.spur.lowcode/Makefile @@ -1,18 +1,24 @@ -############################################################################# -# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur32.cog.lowcode COGDEFS:= -DLowcodeVM=1 -COMPILER_TO_USE:=clang - -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) + +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win32x86/squeak.cog.spur/Makefile b/building/win32x86/squeak.cog.spur/Makefile index fe6f8a7b6f..15b5d82aab 100644 --- a/building/win32x86/squeak.cog.spur/Makefile +++ b/building/win32x86/squeak.cog.spur/Makefile @@ -1,15 +1,22 @@ -############################################################################# -# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur32.cog -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win32x86/squeak.cog.spur/plugins.ext b/building/win32x86/squeak.cog.spur/plugins.ext index ba9ebcb10a..9261fd42b4 100644 --- a/building/win32x86/squeak.cog.spur/plugins.ext +++ b/building/win32x86/squeak.cog.spur/plugins.ext @@ -2,8 +2,6 @@ EXTERNAL_PLUGINS = \ B3DAcceleratorPlugin \ CameraPlugin \ -BochsIA32Plugin \ -BochsX64Plugin \ FileAttributesPlugin \ Squeak3D \ SqueakFFIPrims \ @@ -14,3 +12,5 @@ DESPlugin \ MD5Plugin \ SHA2Plugin \ VectorEnginePlugin +# BochsIA32Plugin \ +# BochsX64Plugin \ No newline at end of file diff --git a/building/win32x86/squeak.cog.v3/Makefile b/building/win32x86/squeak.cog.v3/Makefile index 722228e6bb..b986db55f9 100644 --- a/building/win32x86/squeak.cog.v3/Makefile +++ b/building/win32x86/squeak.cog.v3/Makefile @@ -1,15 +1,27 @@ -############################################################################# -# Makefile for Win32 Cog Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/v3.cog -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# No inlining for v3 because VM sources are missing a pointer cast, which is +# an error in recent Clang. (as of VMMaker.oscog-eem.3613) +MEMACCESS:= +export MEMACCESS + +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win32x86/squeak.sista.spur/Makefile b/building/win32x86/squeak.sista.spur/Makefile index 1c13f5205a..357e6aefbe 100644 --- a/building/win32x86/squeak.sista.spur/Makefile +++ b/building/win32x86/squeak.sista.spur/Makefile @@ -1,17 +1,22 @@ -############################################################################# -# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur32.sista -COMPILER_TO_USE:=clang - -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win32x86/squeak.stack.spur/Makefile b/building/win32x86/squeak.stack.spur/Makefile index 0994f61057..458f4fc103 100644 --- a/building/win32x86/squeak.stack.spur/Makefile +++ b/building/win32x86/squeak.stack.spur/Makefile @@ -1,15 +1,22 @@ -############################################################################# -# Makefile for Win32 Stack Spur Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur32.stack -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win32x86/squeak.stack.v3/Makefile b/building/win32x86/squeak.stack.v3/Makefile index fbec8529a5..41babe549b 100644 --- a/building/win32x86/squeak.stack.v3/Makefile +++ b/building/win32x86/squeak.stack.v3/Makefile @@ -1,15 +1,27 @@ -############################################################################# -# Makefile for Win32 Stack Squeak VM using gcc-3.4.x and cygwin +#################################################################################### +# Makefile for Win32 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -############################################################################# +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/v3.stack -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# No inlining for v3 because VM sources are missing a pointer cast, which is +# an error in recent Clang. (as of VMMaker.oscog-eem.3613) +MEMACCESS:= +export MEMACCESS + +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW32 or CLANG32), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64ARMv8/HowToBuild b/building/win64ARMv8/HowToBuild index 16fdc7a201..20dbef8d60 100644 --- a/building/win64ARMv8/HowToBuild +++ b/building/win64ARMv8/HowToBuild @@ -8,7 +8,6 @@ Contents: - Building out of the box - Building a Specific Plugin Dll - Building the VM Simulator Support Libraries - - Building an MSI installer (Newspeak) - Optimization level and gcc version (please read!) - Debugging with gdb - Debugging with Visual Studio @@ -17,14 +16,14 @@ Contents: Overview -------- The "Cog" VM comes in a bewildering variety of forms. The first distinction -is between Squeak/Croquet VMs that run Squeak, Pharo, Cuis, Croquet images -and their ilk, and between Newspeak VMs that run Newspeak. +is between Squeak/Croquet VMs that run Squeak, Cuis, Croquet images +and their ilk. Another distinction is between Stack, Cog and Sista VMs. Stack VMs are those with context-to-stack mapping that optimise message sending by keeping method activations on a stack instead of in contexts. These are pure interpreters but significantly faster than the standard context-based Interpreter VM. Cog VMs -add a JIT to the mix, compiling methods used more than once to maxchine code on +add a JIT to the mix, compiling methods used more than once to maschine code on the fly. Sista VMs, as yet unrealised and in development, add support for adaptive optimization that does speculative inlining at the bytecode-to-bytecode level. These are targeted for release in 2015. @@ -53,8 +52,8 @@ whereas debug VMs are compiled with no optimization at all, providing maximum debuggability with minimum performance. This directory tree provides build directories for some of this matrix. For -example, newspeak.stack.spur contains a build directory -for Newspeak Stack VMs using the Spur object representation. Build as desired. +example, squeak.stack.spur contains a build directory +for Smalltalk Stack VMs using the Spur object representation. Build as desired. Checking out sources to build out-of-the-box @@ -67,24 +66,31 @@ Check-out the repository from github: Building out of the box ----------------------- -The standard build configurations are the MinGW tools under Cygwin. Currently -neither Cygwin nor MinGW provide an arm64 toolchain. We leave the instructions -here in expectation that they will. More information might be available via the -MSYS2 project page (https://www.msys2.org/wiki/arm64/). Please skip forward to -"MSVC". The build system also supports Visual Studio Community (tested with 2022), -but requires Cygwin tools, especially GNU Make, to run. - -Cygwin 1. Install the tools: -- Install - either cygwin 64bits version from www.cygwin.com. - either mingw 64bits version and msys from www.mingw.com. -list of packages called "mingw64-arm64-gcc-core,mingw64-arm64-gcc-g++,mingw64-arm64-headers,mingw64-arm64-runtime". - -Cygwin 2. Build -Then cd to the build directory of your choice, e.g. - building/win64x64/squeak.stack.spur/ -Then execute - ./mvm +The standard build configurations are for LLVM/Clang and an MSYS2 shell. You can +either build against the WinSDK directly, which is the recommended way, or +against mingw-w64. + +If you do not know about any of these technologies, here are the resources +to get started: + - LLVM/Clang: https://clang.llvm.org/ + - MSYS2: https://www.msys2.org/ + - Mingw-w64: https://www.mingw-w64.org/ + - Windows SDK: https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ + +Option A - WinSDK + 1. Install MSYS2 via "scripts/installMSYS2.cmd base" + 2. Install "Visual Studio Community Edition" (incl. Windows 10 SDK) + - https://visualstudio.microsoft.com/de/vs/community/ + - Note that recent versions come with own Clang besides MSVCC + - Note that "C++ ATL Support" is required for the CameraPlugin + 3. [optional] Install another LLVM/Clang that targets *-pc-windows-msvc + - https://github.com/llvm/llvm-project/releases + 4. Open MSYS2 shell with default MSYS environment + - Typically "c:/msys64/msys2.exe" or "c:/msys64/msys2_shell.cmd -msys2" + 5. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm" + - Use another LLVM/Clang via "./mvm -- LLVM_BIN=c:/llvm/bin/ " + - Use LLVM/Clang from $PATH via "./mvm -- LLVM_BIN='' " This builds debug, assert and production versions of the VM in builddbg/vm, buildast/vm and build/vm. If the configuration includes multi-threaded builds @@ -96,35 +102,31 @@ to access standard i/o. In order to only build the production vm, you can launch the command: ./mvm -f -For building with clang instead of gcc, it is possible to pass options to make via mvm after --: - ./mvm -f -- CC=arm64-w64-mingw32-clang -If building from mingw64, it may be necessary to omit the tool prefix: - ./mvm -f -- TOOLPREFIX='' +Option B - mingw-w64 + 1. Install MSYS2 via "scripts/installMSYS2.cmd clang-aarch64" + 2. Open MSYS2 shell with CLANGARM64 environment + - Typically "c:/msys64/mingw64.exe" or "c:/msys64/msys2_shell.cmd -mingw64" + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm -- TOOLPREFIX='' " +Note that any other version of Clang must be installed only through +MSYS2 and target *-w64-windows-gnu to produce the correct .o files. + -MSVC 1. Install the tools: -- follow step Cygwin 1. Install the tools -- Make sure that the tools directory (e.g., C:\cygwin\bin) is in your PATH environment variable -- Install Visual Studio Community from https://visualstudio.microsoft.com/downloads/ -- Install a Windows Kit from https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ +Option C - WinSDK via arm64 Native Tools Command Prompt + 1. Do steps 1 to 3 from option A. + 2. Open an arm64 Native Tools Command Prompt + - Needs "MSVC v143 - VS 2022 C++ arm64 Buildtool" for "Native Tools Command Prompt" + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "..\common\SETPATH_MSYS2.BAT " + 4. Then execute the other batch files to build the VM + ..\common\MAKEDEBUG.BAT + ..\common\MAKEASSERT.BAT + ..\common\MAKEFAST.BAT -MSVC 2. Build -Open a x64 Native Tools Command Prompt from Visual Studio. -Then cd to the build directory of your choice, e.g. - building/win64x64\squeak.cog.spur\ -Then execute - ..\common\SETPATH.BAT -to add the cygwin tools to your path (edit SETPATH if they are not installed in -c:\cygwin64) -Then execute - ..\common\MAKEDEBUG.BAT - ..\common\MAKEASSERT.BAT - ..\common\MAKEFAST.BAT -to make each of the three VMs. -Both Builds Each build directory contains two files plugins.int plugins.ext @@ -133,8 +135,6 @@ directory (which defaults to ../../src/plugins), and which are to be linked into the VM (plugins.int) or compiled as external dlls to be dynamically linked at run-time (plugins.ext). Tailor these files as you wish. -The Newspeak builds include an installer. See Building an MSI installer below. - Finally, at the building/win64x64 level the makeall script will run all the mvm scripts it can find. @@ -158,7 +158,7 @@ must be built: ARMv5 GdbARMPlugin building/win64ARMv8/gdbarm32 ARMv8 GdbARMv8Plugin building/win64ARMv8/gdbarm64 cd to the relevant directories; run conf.COG and then the build script, e.g. - $ cd building/linux32x86/bochsx86 + $ cd building/win64ARMv8/bochsx86 $ ./conf.COG $ ./makeem @@ -166,17 +166,6 @@ Then when Squeak VMs are built they will include the plugin(s) for which support libraries have been provided. -Building an MSI installer (Newspeak) ------------------------------------- -The Newspeak builds include an installer subdirectory. The installer build -creates an MSI installer that provides a platform-conformat install experience -for the VM. First build the VM then cd to the installer and make, e.g.: - $ cd newspeak.cog.spur - $ ./mvm - $ cd installer - $ make - - Optimization level and gcc version ---------------------------------- There used to be issues with gcc version > 4.2.1. Any of the following flags may break the build at -O2: @@ -198,7 +187,7 @@ unstripped VM to provide symbols, e.g. (gdb) file SqueakUnstripped.exe (gdb) run trunk.image -Note that on Cygwin, while cross-compilation works well, cross debugging does +Note that on MSYS2, while cross-compilation works well, cross debugging does not work at all. One has to debug 32-bit executables on a 32-bit installation with a 32-bit gdb, and 64-bit executables on a 64-bit installation with a 64-bit gdb. diff --git a/building/win64ARMv8/common/Makefile b/building/win64ARMv8/common/Makefile index 1797244eb4..eca72ffc92 100644 --- a/building/win64ARMv8/common/Makefile +++ b/building/win64ARMv8/common/Makefile @@ -1,8 +1,26 @@ ############################################################################# -# Common Makefile for Win32 VM using gcc, cygwin and gnu make +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Visit: https://www.msys2.org/ +# Visit: https://www.mingw-w64.org/ +# +# Make sure to install Clang via MSYS2 pacman to get a compiler that targets +# *-w64-windows-gnu . Other pre-built Clang bundles for Windows will target +# *-pc-windows-msvc . See Makefile.WinSDK for the MSVC toolchain. +# +# RECOMMENDED: Start MSYS2/MINGW64 environment, run "mvm" script. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# # Do make init to allow make -n to function. ############################################################################# +# Use SDKPREFIX configure custom build environments (e.g., .WinSDK). There +# are customization hooks for .rules, .rules.*, .tools, .tools.*, and .plugin +SDKPREFIX?= + ############################################################################# # Parameters: # VM the name of the exe to build, defaults to Squeak (=> Squeak.exe) @@ -54,7 +72,7 @@ else BUILD:=builddbg endif endif -$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory + PLUGINSRCDIR:= ../../../src export PLUGINSRCDIR OBJDIR:= $(BUILD)/vm @@ -71,14 +89,25 @@ WIN32UTILDIR:=$(PLATDIR)/win32/util CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) ifeq ($(THREADING),multi) -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terpmt.c $(VMSRCDIR)/cogit.c) else -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terp.c $(VMSRCDIR)/cogit.c) endif VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR) +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile$(SDKPREFIX).tools +include ../common/Makefile$(SDKPREFIX).tools.print +include ../common/Makefile$(SDKPREFIX).tools.flags +include ../common/Makefile$(SDKPREFIX).tools.defs + +############################################################################# +$(shell $(MKDIR) deps >/dev/null) # deps is the dependencies directory + ############################################################################# # The internal (.lib) and external (.dll) plugins # @@ -89,15 +118,22 @@ LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS))) DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS))) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBM_LIB?=libm.a +export LIBM_LIB +LIBS:=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) export BIT_IDENTICAL_FLOATING_POINT endif +.PHONY: libs dlls + +libs: $(LIBS) +dlls: $(DLLS) + ############################################################################# # The third-party libraries # ifneq ($(THIRDPARTYLIBS),) -include ../common/Makefile.lib.extra +include ../common/Makefile$(SDKPREFIX).lib.extra THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR) endif @@ -110,19 +146,9 @@ VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ)) ############################################################################# # SqueakVM definitions # -ifeq ($(CONFIGURATION),product) -VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe -CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe -STRIPEXE:= $(OBJDIR)/$(VM).exe -STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe -else VMEXE:= $(OBJDIR)/$(VM).exe CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe -STRIPEXE:= -STRIPCONSOLEEXE:= -endif VMDEF:= $(VM).def -VMEXP:= $(OBJDIR)/$(VM).exp VMMAP:= $(OBJDIR)/$(VM).map CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map VMLIB:= $(VM).lib @@ -130,16 +156,11 @@ VMRES:= $(VM).res VMDEFIN:=$(VM).def.in BTOBJ:= $(OBJDIR)/btext.o ETOBJ:= $(OBJDIR)/etext.o -JMPASM:=_setjmp-arm64.asm -JMPOBJ:=$(OBJDIR)/_setjmp-arm64.o +JMPASM:=_setjmp-$(ARCH).asm +JMPOBJ:=$(OBJDIR)/_setjmp-$(ARCH).o .PRECIOUS: mkNamedPrims.exe -############################################################################# -# Toolchain -# -include ../common/Makefile.tools - INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) .SUFFIXES: @@ -148,9 +169,13 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) ############################################################################# # Common build rules # +include ../common/Makefile$(SDKPREFIX).rules +include ../common/Makefile$(SDKPREFIX).rules.vm default: product # ensure two-pass initialization, see below -defaultBuild: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST) +defaultBuild: print-tools print-settings init vm vm-extra $(APPPOST) + +vm: libs $(VMEXE) $(CONSOLEVMEXE) dlls svnver: echo $(RC) $(RCFLAGS) @@ -179,25 +204,28 @@ init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg clean: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps cleanmt: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps cleanast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps cleanmtast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps cleandbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps cleanmtdbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps nukelibs: - rm $(LIBS) + $(RM) $(LIBS) + +nukedlls: + $(RM) $(DLLS) .PHONY : print-settings @@ -208,6 +236,7 @@ print-settings: $(info VPATH=$(VPATH)) $(info INCLUDES=$(INCLUDES)) $(info CFLAGS=$(CFLAGS)) + $(info DEFS=$(DEFS)) $(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS)) $(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS)) $(info OBJDIR=$(OBJDIR)) @@ -222,121 +251,64 @@ print-objects: $(info VMOBJ=$(VMOBJ)) $(info -----------------------------------------------------) -.PHONY : print-tools - -print-tools: - $(info ---------------- Build tools ------------------------) - $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) - $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) - $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) - $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) - $(info AR $(shell which $(ARX)) $(shell $(ARX) --version 2> /dev/null | head -n 1)) - $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) - $(info DLLTOOL $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) - $(info DLLWRAP $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) - $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) - $(info -----------------------------------------------------) - ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore))) -mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c - $(CC) -o $@ -mconsole -m64 $< - $(BTOBJ): $(WIN32MISCDIR)/btext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(ETOBJ): $(WIN32MISCDIR)/etext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(JMPOBJ): $(WIN32MISCDIR)/$(JMPASM) $(CC) -c $< -o $@ -vm: $(VMEXE) - -$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(LDFLAGS) -o $(VMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) - -$(CONSOLEVMEXE): $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) - -ifneq ($STRIPEXE,) -$(STRIPEXE): $(VMEXE) - $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) - -$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) - $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) -endif - $(OBJDIR): - @-mkdir $(BUILD) - mkdir $(OBJDIR) + @-$(MKDIR) $(BUILD) + $(MKDIR) $(OBJDIR) ifneq ($(INTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) endif ifneq ($(EXTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) endif -############################################################################# -# The exports for named primitives from Squeak (required by VM) -# -$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) - $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) - ############################################################################# # Building plugins # .PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll - +.PHONY: always # Check for Makefile in win32 plugins directory otherwise use default Makefile -plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.plugin ../common/Makefile.plugin))) +plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile$(SDKPREFIX).plugin ../common/Makefile$(SDKPREFIX).plugin))) # Internal plugin. Build as lib then link in lib -$(OBJDIR)/%.lib: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/vm/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.lib: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/vm/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) INTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ COGDEFS="$(COGDEFS) -DSQUEAK_BUILTIN_PLUGIN=$(*F)" $(OBJDIR)/$(*F).lib # External plugin. Build as dll and copy to vm dir ($(OBJDIR)). -$(OBJDIR)/%.dll: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.dll: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) EXTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ JMPOBJ=$(JMPOBJ) VMLIB=$(OBJDIR)/$(VMLIB) \ COGDEFS="$(COGDEFS) -DSQUEAK_EXTERNAL_PLUGIN=$(*F)" $(OBJDIR)/$(*F).dll +# Build fdlibm with GNU ar and GNU ranlib. Override $(LIBM_LIB) and add +# custom rule to choose, e.g., different librarian method. $(BUILD)/fdlibm/libm.a: - @-mkdir -p $(@D) + @-$(MKDIR) $(@D) $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ - TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote - - -############################################################################# -# Basic rules -# -include ../common/Makefile.rules - -$(VMRES): $(VM).rc - $(RC) $(RCFLAGS) -i $(VM).rc -o $@ - $(CP) $(VM).exe.manifest $(OBJDIR) - $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote libm.a -resource.o: $(VMRES) - $(RC) $(RCFLAGS) -i $< -o $@ ############################################################################# # Extra specific dependencies diff --git a/building/win64ARMv8/common/Makefile.WinSDK b/building/win64ARMv8/common/Makefile.WinSDK new file mode 100644 index 0000000000..dfb37fca21 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK @@ -0,0 +1,33 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# -> https://github.com/llvm/llvm-project/releases +# -> https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ +# -> https://visualstudio.microsoft.com/de/vs/community/ +# -> https://www.msys2.org/ +# +# Make sure to either use a Clang from MS Visual Studio or a pre-built +# clang that targets *-pc-windows-msvc. The Clang from MSYS2 pacman will +# target *-w64-windows-gnu . See Makefile for the MSYS2 toolchain. +# +# RECOMMENDED: Start plain MSYS2 shell, run "mvm" script. +# Alternative: Start Native Tools Command Prompt, run SETPATH then MAKE*.BAT. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Do make init to allow make -n to function. +############################################################################# + +SDKPREFIX:=.WinSDK +LIBM_LIB:=libm.lib + +include ../common/Makefile + +$(BUILD)/fdlibm/$(LIBM_LIB): + @-$(MKDIR) $(@D) + $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ + LIBRARIAN='$(LIBRARIAN)' \ + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote $(LIBM_LIB) diff --git a/building/win64ARMv8/common/Makefile.WinSDK.lib.extra b/building/win64ARMv8/common/Makefile.WinSDK.lib.extra new file mode 100644 index 0000000000..3e7da9e555 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.lib.extra @@ -0,0 +1,12 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# THIRDPARTYLIBS The libraries to build (you define them in ./third-party/LIB/Makefile.lib) +# THIRDPARTYDIR Where to build libraries +# THIRDPARTYOUTDIR Where to first install libraries (output place) +# THIRDPARTYCACHEDIR Where to download thirdparty libraries +# +############################################################################# + +# Under construction. See Makefile.lib.extra for a template. diff --git a/building/win64ARMv8/common/Makefile.WinSDK.plugin b/building/win64ARMv8/common/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..b544324980 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.plugin @@ -0,0 +1,141 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Generic Makefile for plugins +############################################################################# +# +# The following variables can be overridden in the platform Makefile, e.g. +# platforms/win32/plugins/BochsIA32Plugin/Makefile. Look at +# platforms/win32/plugins/*/Makefile for examples. +# +# EXCLUDESRC defines patterns of source files to not compile, e.g. %/dump.c +# +# The following variables can be defined to extend the compilation flags. +# +# XCFLAGS adds additional compilation flags after all other C preprocessor define flags +# XINC adds additional include flags after all other INCLUDE flags +# +# The following are the three key locations (set via invocation): +# BUILDDIR: Where is the root of the build tree? +# PLATDIR: Where is the root of the platforms tree? +# SRCDIR: Where is the root of the src tree? (i.e. ../../../winbuild/src) + +############################################################################# +# Standard directory locations: +# CROSSDIR: The location of the cross platform sources +# WIN32DIR: The location of the win32 sources +# MAKERDIR: The location of the VMMaker generated sources +# BUILDDIR: The location where the plugin is built +# +CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME) +WIN32DIR:= $(PLATDIR)/win32/plugins/$(LIBNAME) +MAKERDIR:= $(PLUGINSRCDIR)/plugins/$(LIBNAME) +BUILDDIR:= $(BUILD)/$(LIBNAME) + +# Support directory locations +CROSSVMDIR:= $(PLATDIR)/Cross/vm +WIN32VMDIR:= $(PLATDIR)/win32/vm +WIN32MISCDIR:=$(PLATDIR)/win32/misc +MAKERVMDIR:= $(SRCDIR)/vm + +############################################################################# +# Standard include sources +# +INCLUDES:= -I. \ + -I$(VMSRCDIR) -I$(WIN32VMDIR) -I$(CROSSVMDIR) \ + -I$(MAKERDIR) -I$(WIN32DIR) -I$(CROSSDIR) + +############################################################################# +# If no source files were given, use standard set +# +CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) +WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) +MAKERSRC:= $(wildcard $(MAKERDIR)/*.c) +LIBSRC?= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) +ifneq ($(EXCLUDESRC),) +LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) +endif + +############################################################################# +# Plugin settings +# +OBJDIR:= $(BUILD)/$(LIBNAME) +VMDIR:= $(BUILD)/vm +PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib +PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll +LIBOBJ?= $(LIBSRC:.c=.o) +LIBOBJ:= $(LIBOBJ:.cpp=.o) +LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) +ifdef BIT_IDENTICAL_FLOATING_POINT +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) +endif + +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.WinSDK.tools +include ../common/Makefile.WinSDK.tools.flags +include ../common/Makefile.WinSDK.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.WinSDK.rules + +VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) + +all: $(PLUGINLIB) $(PLUGINDLL) + +.PHONY : print-settings + +print-settings: + $(info ---------------- Makefile settings ------------------) + $(info PATH='$(PATH)') + $(info VPATH='$(VPATH)') + $(info INCLUDES='$(INCLUDES)') + $(info DEFS='$(DEFS)') + $(info CFLAGS='$(CFLAGS)') + $(info SRCDIR='$(SRCDIR)') + $(info CROSSDIR='$(CROSSDIR)') + $(info WIN32DIR='$(WIN32DIR)') + $(info WIN32MISCDIR='$(WIN32MISCDIR)') + $(info MAKERDIR='$(MAKERDIR)') + $(info CROSSSRC='$(CROSSSRC)') + $(info WIN32SRC='$(WIN32SRC)') + $(info MAKERSRC='$(MAKERSRC)') + $(info EXCLUDESRC='$(EXCLUDESRC)') + $(info LIBSRC='$(LIBSRC)') + $(info LIBOBJ='$(LIBOBJ)') + $(info OBJDIR='$(OBJDIR)') + $(info VMDIR='$(VMDIR)') + $(info VMLIB='$(VMLIB)') + $(info PLUGINSRCDIR='$(PLUGINSRCDIR)') + $(info PLUGINLIB='$(PLUGINLIB)') + $(info PLUGINDLL='$(PLUGINDLL)') + $(info PLUGINDLL_LIBS='$(PLUGINDLL_LIBS)') + $(info XINC='$(XINC)') + $(info XDEFS='$(XDEFS)') + $(info -----------------------------------------------------) + +$(OBJDIR): + $(MKDIR) $(subst /,\\,$(OBJDIR)) + +$(VMDIR): + $(MKDIR) $(subst /,\\,$(VMDIR)) + +$(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(LIBSRC) + -$(RM) $(PLUGINLIB) + $(LIBRARIAN) $(LIBOBJ) $(EXTRALIBS) -out:$(subst /,\\,$(PLUGINLIB)) + +PLUGINDLL_LIBS:=WinMM.lib ole32.lib msdmo.lib user32.lib kernel32.lib /NODEFAULTLIB:libc /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt + +$(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(JMPOBJ) $(LIBSRC) + $(LD) $(LDFLAGS) -DLL $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(PLUGINDLL_LIBS) $(EXTRALIBS) \ + -NOIMPLIB \ + -LIBPATH:$(BUILD)/vm \ + -OUT:$(subst /,\\,$(PLUGINDLL)) diff --git a/building/win64ARMv8/common/Makefile.WinSDK.rules b/building/win64ARMv8/common/Makefile.WinSDK.rules new file mode 100644 index 0000000000..8ebdb34927 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.rules @@ -0,0 +1,16 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +include ../common/Makefile.rules + +# Microsoft (R) Windows (R) Resource Compiler; see Makefile.WinSDK +# %.res: %.rc +# $(RC) $(RCFLAGS) -Fo $@ $< diff --git a/building/win64ARMv8/common/Makefile.WinSDK.rules.vm b/building/win64ARMv8/common/Makefile.WinSDK.rules.vm new file mode 100644 index 0000000000..91f86a05b7 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.rules.vm @@ -0,0 +1,38 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -c $< -o mkNamedPrims.obj + $(LD) -out:$@ mkNamedPrims.obj -subsystem:console -defaultlib:libcmt + +.PHONY: vm-extra +vm-extra: + $(info No extra things to do for the VM.) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -OUT:$(VMEXE) -MAP:$(VMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +$(CONSOLEVMEXE): $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o$(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -OUT:$(CONSOLEVMEXE) -MAP:$(CONSOLEVMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +# Microsoft (R) Windows (R) Resource Compiler +%.res: %.rc + $(RC) $(RCFLAGS) -Fo $@ $< + +# Microsoft (R) Windows Resource To Object Converter +resource.o: $(VMRES) + $(CVTRES) -MACHINE:$(ARCH) -OUT:resource.o $(VMRES) + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win64ARMv8/common/Makefile.WinSDK.tools b/building/win64ARMv8/common/Makefile.WinSDK.tools new file mode 100644 index 0000000000..c7507153b1 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.tools @@ -0,0 +1,108 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# Supported architecures: x86, x64, arm64 +ARCH:=arm64 +# Export ARCH to be used in plugins such as IA32ABI (i.e. FFI callbacks) +export ARCH + +############################################################################# +# Set paths to toolchain. Note that $(LLVM_BIN) and $(MSYS2_BIN) may be +# empty, relying on $(PATH) to find those tools. +# + +include ../common/Makefile.WinSDK.tools.paths + +ifeq ($(VCToolsBinDir),) + $(error Failed to locate Visual Studio build tools!) +endif + +ifeq ($(WindowsSDKToolsBinDir),) + $(error Failed to locate Windows SDK build tools!) +endif + +ifeq ($(LLVM_BIN),) + $(info Using clang from PATH...) +endif + +ifeq ($(MSYS2_BIN),) + $(info Using GNU tools from PATH...) +endif + +############################################################################# +# C compiler settings +# + +CC:=$(LLVM_BIN)clang +CXX:=$(LLVM_BIN)clang++ + +TZ:=$(shell $(MSYS2_BIN)date +%Z) + +# Microsoft Macro Assembler; not needed, use LLVM/Clang; see Makefile.WinSDK +# AS:=$(VCToolsBinDir)/ml64 + +############################################################################# +# Linker settings +# +LD:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LDCXX:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LIBRARIAN:=$(VCToolsBinDir)/LIB -nologo + +# The JIT will attempt to alloca up to 1.5Mb by default on x86-64. So set +# the default stack size to 2Mb to avoid crashes in the JIT's alloca. +ifeq ($(DEFAULT_STACK_SIZE),) +DEFAULT_STACK_SIZE:=2097152 +endif +STACK_LD_FLAG=-STACK:$(DEFAULT_STACK_SIZE),$(DEFAULT_STACK_SIZE) + +BASELDFLAGS:= $(STACK_LD_FLAG) -DYNAMICBASE -LARGEADDRESSAWARE -NXCOMPAT -DEBUG:FULL +LDFLAGS:= -subsystem:windows $(BASELDFLAGS) $(EXTRALDFLAGS) +CONSOLELDFLAGS:= -subsystem:console $(BASELDFLAGS) $(EXTRALDFLAGS) +DL:=-DEFAULTLIB: +NDL:=-NODEFAULTLIB: + +ifdef BIT_IDENTICAL_FLOATING_POINT +EXTRANDLS:=-NODEFAULTLIB:libm +endif +STDLIBS:=$(STDLIBS) $(NDL)libc $(NDL)libcmt $(EXTRANDLS) $(DL)msvcrt \ + dinput8.lib dsound.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \ + version.lib wininet.lib user32.lib gdi32.lib psapi.lib \ + advapi32.lib kernel32.lib secur32.lib shell32.lib shfolder.lib + +############################################################################# +# Tools to use (usually all from GNU coreutils). If $(MSYS2_BIN) +# prefix is empty, rely on $(PATH) to find tools. +# +CP:= $(MSYS2_BIN)cp +RM:= $(MSYS2_BIN)rm +MV:= $(MSYS2_BIN)mv +MKDIR:=$(MSYS2_BIN)mkdir -p + +############################################################################# +# RC settings, Microsoft Resource Compiler +# CVTRES settings, Microsoft Resource To Object Converter +# +# Note: RC compiles the .rc files into linkable .o files +# +RC:=$(WindowsSDKToolsBinDir)/rc -nologo +CVTRES:=$(VCToolsBinDir)/cvtres -nologo +SED:=$(MSYS2_BIN)sed +GREP:=$(MSYS2_BIN)grep +BASH:=$(MSYS2_BIN)bash +SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h + +ifneq ($(shell $(GREP) 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) +$(shell $(BASH) -c "cd ../../../scripts; ./updateSCCSVersions") +endif +SVNMAJOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: \([0-9][0-9][0-9][0-9]\).*/\\1/p" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNMINOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNREV := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNBUILD := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]*\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') + +RCFLAGS:= -i $(PLATDIR)/win32/misc -D_WIN32 -DFILEVERSIONVALUES=$(SVNMAJOR),$(SVNMINOR),$(SVNREV),$(SVNBUILD) -DFILEVERSIONSTRING="\"$(SVNMAJOR).$(SVNMINOR).$(SVNREV).$(SVNBUILD)\"" diff --git a/building/win64ARMv8/common/Makefile.WinSDK.tools.defs b/building/win64ARMv8/common/Makefile.WinSDK.tools.defs new file mode 100644 index 0000000000..21323403ce --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.tools.defs @@ -0,0 +1,37 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +include ../common/Makefile.tools.defs + +############################################################################# + +# Enable the LLP64 data model, where only pointers expand to 64-bits +# https://learn.microsoft.com/en-us/windows/win32/winprog64/abstract-data-models +POINTER_MODEL:=-DLLP64=1 +DEFS:=$(POINTER_MODEL) $(DEFS) + +# Make all setjmp/longjmp varieties to our _setjmp/_longjmp in _setjmp-x64.asm +JMPDEFS:=-Dsetjmp=_setjmp -Dlongjmp=_longjmp -D_siglongjmp=_longjmp +DEFS:= $(JMPDEFS) $(DEFS) + +# ??? +FUNDEFS:=-Dalloca=_alloca -Dhuge=my_huge +DEFS:= $(FUNDEFS) $(DEFS) + + + + + + + +# Do _not_ define NDEBUG. The entire point of the msvc build is to debug with +# MSVC and defining NDEBUG installs a default catch-everything exception handler +# that effectively disables debugging. +# XDEFS= -DSQUEAK_BUILTIN_PLUGIN diff --git a/building/win64ARMv8/common/Makefile.WinSDK.tools.flags b/building/win64ARMv8/common/Makefile.WinSDK.tools.flags new file mode 100644 index 0000000000..cf5e72f28d --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.tools.flags @@ -0,0 +1,18 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +# Skip mingw-w64 specific configuration flags that should not be required +# when using a clang that targets msvc format. +NOBUILTIN= +CALLING_CONVENTION= +BITFIELD_LAYOUT= +DECLSPEC= + +include ../common/Makefile.tools.flags diff --git a/building/win64ARMv8/common/Makefile.WinSDK.tools.paths b/building/win64ARMv8/common/Makefile.WinSDK.tools.paths new file mode 100644 index 0000000000..1783013eb8 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.tools.paths @@ -0,0 +1,122 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Check or lookup paths to the compiler, other build tools (e.g., GNU make or +# MS Link), and the Windows SDK. +############################################################################# + +WindowsSdkMajorVersion:=10 +HostARCH:=HostARM64 + +ifeq ($(MSYS2_BIN),) + MSYS2_BIN:=c:/msys64/usr/bin/ +else + override MSYS2_BIN:=$(subst \,/,$(MSYS2_BIN)) +endif + +############################################################################# +# Set paths to the Windows SDK (and tools) and Visual Studio (and tools) +# +ifeq ($(VCINSTALLDIR),) + # ../[2017 2022]/[Community Enterprise]/VC + VCINSTALLDIR:=C:/Program\ Files/Microsoft\ Visual\ Studio/*/*/VC + VCINSTALLDIR:=$(wildcard $(VCINSTALLDIR)) +else + override VCINSTALLDIR:=$(subst \,/,$(VCINSTALLDIR)) +endif + +ifeq ($(VCToolsInstallDir),) + # ../MSVC/[14.29.30133 14.44.35207] + VCToolsInstallDir:=$(VCINSTALLDIR)/Tools/MSVC/* + VCToolsInstallDir:=$(shell echo "$(VCToolsInstallDir)" | sed 's/ /\\ /g') + VCToolsInstallDir:=$(wildcard $(VCToolsInstallDir)) + # To make sort and lastword work, mask space-ridden VCINSTALLDIR + VCToolsInstallDir:=$(subst $(VCINSTALLDIR),%MAKETMP123%,$(VCToolsInstallDir)) + VCToolsInstallDir:=$(sort $(VCToolsInstallDir)) + VCToolsInstallDir:=$(lastword $(VCToolsInstallDir)) + VCToolsInstallDir:=$(subst %MAKETMP123%,$(VCINSTALLDIR),$(VCToolsInstallDir)) +else + override VCToolsInstallDir:=$(subst \,/,$(VCToolsInstallDir)) +endif + + +############################################################################# +# Set paths to LLVM, for compilers (and maybe other build tools). +# Note that Visual Studio ships its own version of LLVM/Clang these days. +# + +# LLVM_BIN:=c:/llvm/bin/ + +VCLlvmInstallDir:=$(VCINSTALLDIR)/Tools/Llvm +LLVM_BIN:=$(VCLlvmInstallDir)/$(ARCH)/bin/ + +# Must escape whitespace and parentheses for scripts +LLVM_BIN:=$(shell echo "$(LLVM_BIN)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to MSVC linker and library tools, LINK and LIB. +# + +VCToolsBinDir:=$(VCToolsInstallDir)/bin/$(HostARCH)/$(ARCH) +VCToolsBinDir:=$(shell echo "$(VCToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to Windows SDK and tools (e.g. RC and CVTRES). +# +ifeq ($(WindowsSdkDir),) + WindowsSdkDir:=C:/Program Files (x86)/Windows Kits/$(WindowsSdkMajorVersion)/ +else + override WindowsSdkDir:=$(subst \,/,$(WindowsSdkDir)) +endif +ifeq ($(WindowsSDKVersion),) + WindowsSDKVersion:=$(WindowsSdkDir)/include/$(WindowsSdkMajorVersion)* + WindowsSDKVersion:=$(shell echo "$(WindowsSDKVersion)" | sed 's/ /\\ /g') + WindowsSDKVersion:=$(wildcard $(WindowsSDKVersion)) + WindowsSDKVersion:=$(subst $(WindowsSdkDir)/include/,,$(WindowsSDKVersion)) + # Use only newest SDK version + WindowsSDKVersion:=$(sort $(WindowsSDKVersion)) + WindowsSDKVersion:=$(lastword $(WindowsSDKVersion)) +endif +override WindowsSDKVersion:=$(subst \,,$(WindowsSDKVersion)) + +WindowsSDKToolsBinDir:=$(WindowsSdkDir)/bin/$(WindowsSDKVersion)/$(ARCH) +WindowsSDKToolsBinDir:=$(shell echo "$(WindowsSDKToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to INCLUDE headers from Visual Studio (e.g., COM stuff) and +# Windows SDK (e.g., standard C library). +# +ifeq ($(INCLUDE),) +INCLUDE:=$(VCToolsInstallDir)/ATLMFC/include;$(VCToolsInstallDir)/include;$(VCINSTALLDIR)/Auxiliary/VS/include;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/shared;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/ucrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/um;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/winrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/cppwinrt +INCLUDE:=$(subst //,/,$(INCLUDE)) +INCLUDE:=$(subst /,\,$(INCLUDE)) +#$(info INCLUDE is $(INCLUDE)) +endif +MSVCINCLUDES:=-I"$(subst \,/,$(subst ;," -I",$(INCLUDE)))" +#$(info MSVCINCLUDES is $(MSVCINCLUDES)) + +# Put -I. last because boost includes bizarreness such as +# include which will include a local file called list if -I. comes +# early in the include path. Fragile. +INCLUDES:= $(filter-out -I., $(INCLUDES)) $(MSVCINCLUDES) $(XINC) -I. + + +############################################################################# +# Set paths to system libraries from Visual Studio (e.g. COM stuff) and +# Windows SDK (e.g., standard C lib). +# +ifeq ($(LIB),) +LIB:=$(VCToolsInstallDir)/ATLMFC/lib/$(ARCH);$(VCToolsInstallDir)/lib/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/ucrt/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/um/$(ARCH) +LIB:=$(subst //,/,$(LIB)) +LIB:=$(subst /,\,$(LIB)) +export LIB +endif +# $(info LIB is $(LIB)) diff --git a/building/win64ARMv8/common/Makefile.WinSDK.tools.print b/building/win64ARMv8/common/Makefile.WinSDK.tools.print new file mode 100644 index 0000000000..ce25b3579b --- /dev/null +++ b/building/win64ARMv8/common/Makefile.WinSDK.tools.print @@ -0,0 +1,30 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info VCToolsBinDir $(VCToolsBinDir)) + $(info WindowsSDKToolsBinDir $(WindowsSDKToolsBinDir)) + $(info WindowsSdkDir $(WindowsSdkDir)) + $(info WindowsSDKVersion $(WindowsSDKVersion)) + $(info MSYS2_BIN $(MSYS2_BIN)) + $(info LLVM_BIN $(LLVM_BIN)) + $(info CC $(shell which $(CC))) + $(info .. $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info CXX $(shell which $(CXX))) + $(info .. $(shell $(CXX) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD) 2> /dev/null)) + $(info LDXX $(shell which $(LD) 2> /dev/null)) + $(info LIBRARIAN $(shell which $(LIBRARIAN) 2> /dev/null)) + $(info RC $(shell which $(RC) 2> /dev/null)) + $(info CVTRES $(shell which $(CVTRES) 2> /dev/null)) + $(info -----------------------------------------------------) diff --git a/building/win64ARMv8/common/Makefile.plugin b/building/win64ARMv8/common/Makefile.plugin index e5b8ff185d..8e7b05b9e0 100644 --- a/building/win64ARMv8/common/Makefile.plugin +++ b/building/win64ARMv8/common/Makefile.plugin @@ -1,4 +1,10 @@ ############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# # Generic Makefile for plugins on Win64 ############################################################################# # @@ -47,36 +53,6 @@ ifneq ($(EXCLUDESRC),) LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) endif -############################################################################# -# C compiler settings (gcc 4.x) -# -include ../common/Makefile.tools - -# overrides of default toolchain settings - -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O1 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:=-DNDEBUG -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -else -OFLAGS:= -O0 -fno-omit-frame-pointer -DEBUGVM=1 -NDEBUG:= -endif - -XDEFS:= -DEFS:= $(WINVER) -DWIN64=1 -DNO_ISNAN \ - -DNO_SERVICE \ - $(NDEBUG) -DLSB_FIRST -DVM_NAME=\"$(VM)\" $(XDEFS) - -CFLAGS:= -fdeclspec -msse2 -ggdb2 -march=$(ARCH) \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) $(COGDEFS) - - ############################################################################# # DLL settings # @@ -85,9 +61,6 @@ CFLAGS:= -fdeclspec -msse2 -ggdb2 -march=$(ARCH) \ # OPTSTRIP:= echo not doing strip - -.SUFFIXES: .c .cpp .o .s .rc .res .dep - ############################################################################# # Plugin settings # @@ -98,9 +71,20 @@ PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll LIBOBJ ?= $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LIBSRC))) LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBOBJ+=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) endif +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.tools +include ../common/Makefile.tools.flags +include ../common/Makefile.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.rules VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) @@ -132,10 +116,10 @@ print-settings: $(info -----------------------------------------------------) $(OBJDIR): - mkdir $(OBJDIR) + $(MKDIR) $(OBJDIR) $(VMDIR): - mkdir $(VMDIR) + $(MKDIR) $(VMDIR) # If any prerequisites are declared all must exist to continue ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES))) @@ -153,20 +137,20 @@ $(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(LIBOBJ) $(JMPOBJ) ifneq ($(LINK_WITH_GCC),) $(CC) -shared \ - -march=$(ARCH) \ + -m64 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ $(GCCLINKEXTRAS) \ $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS) else ifneq ($(LINK_WITH_GPP),) $(CXX) -shared \ - -march=$(ARCH) \ + -m64 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ $(GPPLINKEXTRAS) \ $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(EXTRALIBS) else - $(DLLWRAP) -mwindows -march=$(ARCH) \ + $(DLLWRAP) -mwindows -m64 \ -def $(OBJDIR)/$(LIBNAME).def \ -o $(VMDIR)/$(LIBNAME).dll \ $(DLLWRAPEXTRAS) \ @@ -176,11 +160,6 @@ endif $(OPTSTRIP) --strip-all $(VMDIR)/$(LIBNAME).dll -$(RM) $(OBJDIR)/$(LIBNAME).lib -############################################################################# -# Rules for automated builds -# -include ../common/Makefile.rules - else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES)) # If any prerequisites are missing simply create a .ignore file diff --git a/building/win64ARMv8/common/Makefile.rules b/building/win64ARMv8/common/Makefile.rules index 94ca903a3f..b201a79a8d 100644 --- a/building/win64ARMv8/common/Makefile.rules +++ b/building/win64ARMv8/common/Makefile.rules @@ -1,31 +1,51 @@ ############################################################################# -# Compilation rules for Microsoft Windows +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. # +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +.SUFFIXES: .c .cpp .o .s .rc .res .dep + +############################################################################# # See http://make.mad-scientist.net/papers/advanced-auto-dependency-generation # for an explanation of the dependency management scheme. +# +$(info OBJDIR is $(OBJDIR)) ifeq ($(findstring /vm,$(OBJDIR)),/vm) BD:=$(BUILD)/vm else -BD:=$(BUILD)/$(LIBNAME)/vm +BD:=$(BUILD)/$(LIBNAME) endif -ALLFLAGS = $(CFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.c - $(CC) -x c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +# Not interested in recording system header dependencies. *must* use " = " +DEPFLAGS = -MMD -MT '$(BD)/$(*F).o' -MF deps/$(*F).d +############################################################################# -$(OBJDIR)/%.o: %.m - $(CC) -x objective-c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +ALLCFLAGS = $(DEPFLAGS) $(CFLAGS) $(INCLUDES) $(DEFS) +ALLCXXFLAGS = $(DEPFLAGS) $(CXXFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.cpp - $(CXX) -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +############################################################################# +# Rules for automated builds using LLVM/Clang +# -%res: %.rc - $(RC) $(RCFLAGS) -i $< -o $@ +$(OBJDIR)/%.o: %.c + $(CC) -o $@ $(ALLCFLAGS) -c $< + +$(OBJDIR)/%.o: %.cpp + $(CC) -o $@ $(ALLCXXFLAGS) -c $< +# GNU windres (GNU Binutils); see Makefile +# %.res: %.rc +# $(RC) $(RCFLAGS) -i $< -o $@ deps/%.d: ; .PRECIOUS: deps/%.d --include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC)))) +-include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC) $(LIBSRC)))) diff --git a/building/win64ARMv8/common/Makefile.rules.vm b/building/win64ARMv8/common/Makefile.rules.vm new file mode 100644 index 0000000000..7a05dbee84 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.rules.vm @@ -0,0 +1,70 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for building the VM binary itself +############################################################################# + +ifeq ($(CONFIGURATION),product) +VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe +STRIPEXE:= $(OBJDIR)/$(VM).exe +STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe +else +VMEXE:= $(OBJDIR)/$(VM).exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe +STRIPEXE:= +STRIPCONSOLEEXE:= +endif + +############################################################################# +# The exports for named primitives from Squeak (required by VM) +# +VMEXP:= $(OBJDIR)/$(VM).exp +$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) + $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) + +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -o $@ -mconsole -m64 $< + +.PHONY: vm-extra +vm-extra: $(STRIPEXE) $(STRIPCONSOLEEXE) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -o $(VMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) + +$(CONSOLEVMEXE): $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCLFAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) + +ifneq ($STRIPEXE,) +$(STRIPEXE): $(VMEXE) + $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) + +$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) + $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) +endif + +############################################################################# + +# GNU windres (GNU Binutils) +%.res: %.rc + $(RC) $(RCFLAGS) -i $< -o $@ + +# GNU windres (GNU Binutils) +resource.o: $(VMRES) + $(RC) $(RCFLAGS) -i $< -o $@ + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win64ARMv8/common/Makefile.tools b/building/win64ARMv8/common/Makefile.tools index 983148e103..93ad05b51b 100644 --- a/building/win64ARMv8/common/Makefile.tools +++ b/building/win64ARMv8/common/Makefile.tools @@ -1,92 +1,33 @@ ############################################################################# -# Compilation rules for 64-bit Cygwin/mingw compiler on Microsoft Windows -# and arm64 +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# -ARCH:=armv8.1-a +ARCH:=arm64 export ARCH -TOOLPREFIX:=clang-aarch64-w64-mingw32- +TOOLPREFIX:=aarch64-w64-mingw32- export TOOLPREFIX ############################################################################# # C compiler settings (Use clang for having a working FFI) # -ifeq ($(COMPILER_TO_USE),) -COMPILER_TO_USE:=clang -endif - -ifeq ($(COMPILER_TO_USE),clang) CC:= $(TOOLPREFIX)clang CXX:= $(TOOLPREFIX)clang++ -else -CC:= $(TOOLPREFIX)gcc -CXX:= $(TOOLPREFIX)g++ -endif - -WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label -Wno-unused-function - -# VM config flags. -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O2 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -else -OFLAGS:= -O0 -fno-omit-frame-pointer -DEBUGVM=1 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -endif - - -ifeq ($(IS_PREPARING),false) - ifeq ($(THREADING),multi) - COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) - else - COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) - endif - ifdef BIT_IDENTICAL_FLOATING_POINT - COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1 - endif - - ifeq ($(COMPILER_TO_USE),clang) - COGDEFS:=$(COGDEFS) -fno-stack-protector - endif -endif # IS_PREPARING - -# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h) -WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 - -# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h -NOBUILTIN:= -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf -CFLAGS:= -fdeclspec -ggdb2 -march=$(ARCH) \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) - -# Several versions of clang (all versions from 14 through 18 as of this writing) -# generate incorrect code for spur segment storage -# (return:restoringObjectsIn:savedFirstFields:and:savedHashes:) -# unless USE_INLINE_MEMORY_ACCESSORS is set. -MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1 TZ:=$(shell date +%Z) -DEFS:= -D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) \ - -DWIN64=1 -DNO_ISNAN -DNO_SERVICE \ - $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) ############################################################################# # Linker settings # -# Note: I had to use 'gcc' instead of 'ld' to prevent unresolved symbols -# The switch '-mwindows' gives us a GUI app instead of a console app. -# Newer cygwins want --export-all-symbols in place of --export-dynamic. -# -LD:= $(CC) -LDCXX := $(TOOLPREFIX)clang++ # For linking c++ bundles +LD:=$(CC) +LDCXX:=$(CXX) # For linking c++ bundles EXPORT:=--export-all-symbols -BASELDFLAGS:=-march=$(ARCH) -mthreads -Wl,--stack -Xlinker 2097152,2097152 -Wl,$(EXPORT) +BASELDFLAGS:=-m64 -mthreads -Wl,--stack -Xlinker 2097152,2097152 -Wl,$(EXPORT) LDFLAGS:= -mwindows $(BASELDFLAGS) CONSOLELDFLAGS:= -mconsole $(BASELDFLAGS) STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \ @@ -95,15 +36,18 @@ STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \ ############################################################################# # Tools to use +# - Note that "dllwrap" is replaced by "clang -shared" +# - Note that "ar" produces thin archives (-T) to allow mising .o and .a # -AR:= $(TOOLPREFIX)ar rc -ARX:= $(TOOLPREFIX)ar # must not change $(AR) bc. implicit usage +AR:= $(TOOLPREFIX)ar crUuT CP:= cp RM:= rm SED:=sed +MV:=mv +MKDIR:=mkdir -p NM:= $(TOOLPREFIX)nm DLLTOOL:= $(TOOLPREFIX)dlltool -DLLWRAP:= $(TOOLPREFIX)ld -shared +DLLWRAP:= $(CC) -shared STRIP:= $(TOOLPREFIX)strip OBJCOPY:= $(TOOLPREFIX)objcopy @@ -112,7 +56,7 @@ OBJCOPY:= $(TOOLPREFIX)objcopy # # Note: RC compiles the .rc files into linkable .o files # -RC:= $(TOOLPREFIX)windres +RC:=$(TOOLPREFIX)windres SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h ifneq ($(shell grep 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) diff --git a/building/win64ARMv8/common/Makefile.tools.defs b/building/win64ARMv8/common/Makefile.tools.defs new file mode 100644 index 0000000000..a1eb751247 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.tools.defs @@ -0,0 +1,66 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +############################################################################# + +# See sdkddkver.h from Windows SDK or w32api.h from mingw-w64 +# Windows XP ... 0x0501 +# Windows 7 ... 0x0601 +# Windows 8 ... 0x0602 +# Windows 10 ... 0x0A00 +WINVER:=-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 + +# Every clang for Windows (i.e. *-pc-windows-msvc or *-w64-windows-gnu) already +# defines WIN32, WIN64, etc. So, this might just be historical overhead. +WINBIT:=-DWIN32=1 -D_WIN32=1 -DWIN64=1 -D_WIN64=1 + +#!#! UNICODE applies to API calls, _UNICODE to string representation, so one +#!#! must define both. +WINUNI:=-DUNICODE=1 -D_UNICODE=1 + +############################################################################# +# DEFS +# +ifeq ($(CONFIGURATION),product) +DEBUGVM= 0 +NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts +else ifeq ($(CONFIGURATION),assert) +DEBUGVM= 0 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +else +DEBUGVM= 1 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +endif + +ifeq ($(IS_PREPARING),false) + ifeq ($(THREADING),multi) + COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) + else + COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) + endif + ifdef BIT_IDENTICAL_FLOATING_POINT + COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1 + endif +endif # IS_PREPARING + +# Several versions of clang (all versions from 14 through 18 as of this writing) +# generate incorrect code for spur segment storage +# (return:restoringObjectsIn:savedFirstFields:and:savedHashes:) +# unless USE_INLINE_MEMORY_ACCESSORS is set. +MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1 + +# Multi-threaded environment. Might in case use multi-threading specific +# versions of API calls. Also used to avoid built-in functions. +MT_ENV?=-D_MT + +# Use fdlibm for floating-point, which is cross-platform, or +# platform-specific floating point. See COGDEFS. +BIT_IDENTICAL_FLOATING_POINT=1 + +DEFS:=-D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) $(WINBIT) \ + $(WINUNI) $(MT_ENV) -D'TZ="$(TZ)"' -DNO_ISNAN -DNO_SERVICE \ + $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) diff --git a/building/win64ARMv8/common/Makefile.tools.flags b/building/win64ARMv8/common/Makefile.tools.flags new file mode 100644 index 0000000000..be33848d53 --- /dev/null +++ b/building/win64ARMv8/common/Makefile.tools.flags @@ -0,0 +1,78 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (incl. OFLAGS and DEFS) for LLVM/Clang +############################################################################# + +# Enable all but several warnings +WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label \ + -Wno-unused-value -Wno-unused-function -Wno-missing-variable-declarations \ + -Wno-unused-macros -Wno-sign-compare -Wno-sign-conversion -Wno-pedantic \ + -Wno-reserved-id-macro -Wno-undef + +############################################################################# +# OFLAGS (VM and Plugins) +# + +# Turn off BUFFER_SECURITY for functional setjmp/longjmp +BUFFER_SECURITY:=-fno-stack-protector -D_CRT_SECURE_NO_WARNINGS + +# For exception handing we require a frame pointer (e.g. for unwind). +# Clang supports both +# -fno-omit-frame-pointer +# -fno-omit-leaf-frame-pointer +# We assume that when when not omitting the frame pointer, Clang will still +# omit the leaf frame pointers, which is fine. +FRAME_POINTER_FLAGS:=-fno-omit-frame-pointer -DcFramePointerInUse=1 + +ifeq ($(CONFIGURATION),product) + # For fast/production builds, use -O2 optimization + OFLAGS= -O2 -finline-hint-functions -funroll-loops $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else ifeq ($(CONFIGURATION),assert) + # For assert builds, use -Os optimization, which is similar to -O2 + OFLAGS= -Os -fno-builtin $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else + # For debug builds, minimize optimization, even has leaf-frame-pointers + OFLAGS= -O0 $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +endif + +# FYI +# -Ob enable inline expansion -Oy omit frame pointer, Oi enable intrinsics + + +############################################################################# +# CFLAGS +# +NOBUILTIN?=-fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf + +# Include extra debugging information. +DEBUG_LEVEL?=-g3 + +# Enable exceptions for debugging purposes. +EXCEPTION_FLAGS?=-fexceptions +CXX_EXCEPTION_FLAGS?=-fexceptions -fcxx-exceptions + +# No __STDCALL calling convention by default. Stick to __CDECL. +CALLING_CONVENTION?=-mno-rtd + +# Keep default structure layout compatible with Microsoft standards. +BITFIELD_LAYOUT?=-mms-bitfields + +# Allow __declspec keyword. +# See https://learn.microsoft.com/cpp/cpp/declspec +DECLSPEC?=-fdeclspec + +CFLAGS= $(DECLSPEC) $(DEBUG_LEVEL) -m64 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + +CXXFLAGS= $(DECLSPEC) $(DEBUG_LEVEL) -m64 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(CXX_EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + diff --git a/building/win64ARMv8/common/Makefile.tools.print b/building/win64ARMv8/common/Makefile.tools.print new file mode 100644 index 0000000000..a08da17a0a --- /dev/null +++ b/building/win64ARMv8/common/Makefile.tools.print @@ -0,0 +1,24 @@ +############################################################################# +# Common Makefile for Win64ARMv8 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) + $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) + $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) + $(info AR $(shell command -v $(AR)) $(shell $(AR) --version 2> /dev/null | head -n 1)) + $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) + $(info DLLTOOL $(shell command -v $(DLLTOOL)) $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) + $(info DLLWRAP $(shell command -v $(DLLWRAP)) $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) + $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) + $(info -----------------------------------------------------) diff --git a/building/win64ARMv8/common/SETPATH_MSYS2.BAT b/building/win64ARMv8/common/SETPATH_MSYS2.BAT new file mode 100644 index 0000000000..4c51b469d4 --- /dev/null +++ b/building/win64ARMv8/common/SETPATH_MSYS2.BAT @@ -0,0 +1,3 @@ +REM We recommend to run MAKE from a normal MSYS2 environment but it also works +REM from within a Native Tools Command Prompt (Visual Studio Community). +set PATH=%PATH%;c:\msys64\bin diff --git a/building/win64ARMv8/squeak.cog.spur/Makefile b/building/win64ARMv8/squeak.cog.spur/Makefile index fb13599ee4..e752cca839 100644 --- a/building/win64ARMv8/squeak.cog.spur/Makefile +++ b/building/win64ARMv8/squeak.cog.spur/Makefile @@ -1,15 +1,22 @@ -###################################################################################### -# Makefile for Win32 Cog Spur Squeak VM using either gcc and cygwin, or MSVC and LLVM. +#################################################################################### +# Makefile for Win64ARMv8 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -###################################################################################### +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur64.cog -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. CLANGARM64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64ARMv8/squeak.sista.spur/Makefile b/building/win64ARMv8/squeak.sista.spur/Makefile index e401a80032..bbc749d762 100644 --- a/building/win64ARMv8/squeak.sista.spur/Makefile +++ b/building/win64ARMv8/squeak.sista.spur/Makefile @@ -1,17 +1,22 @@ -###################################################################################### -# Makefile for Win32 Sista Spur Squeak VM using either gcc and cygwin, or MSVC and LLVM. +#################################################################################### +# Makefile for Win64ARMv8 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -###################################################################################### +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur64.sista -COMPILER_TO_USE:=clang - -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. CLANGARM64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64ARMv8/squeak.stack.spur/Makefile b/building/win64ARMv8/squeak.stack.spur/Makefile index a447634ac7..da5c77640c 100644 --- a/building/win64ARMv8/squeak.stack.spur/Makefile +++ b/building/win64ARMv8/squeak.stack.spur/Makefile @@ -1,15 +1,22 @@ -###################################################################################### -# Makefile for Win32 Stack Spur Squeak VM using either gcc and cygwin, or MSVC and LLVM. +#################################################################################### +# Makefile for Win64ARMv8 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. -###################################################################################### +#################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur64.stack -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. CLANGARM64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64x64/HowToBuild b/building/win64x64/HowToBuild index aa8d2eba92..4a79e4702a 100644 --- a/building/win64x64/HowToBuild +++ b/building/win64x64/HowToBuild @@ -8,7 +8,6 @@ Contents: - Building out of the box - Building a Specific Plugin Dll - Building the VM Simulator Support Libraries - - Building an MSI installer (Newspeak) - Optimization level and gcc version (please read!) - Debugging with gdb - Debugging with Visual Studio @@ -17,14 +16,14 @@ Contents: Overview -------- The "Cog" VM comes in a bewildering variety of forms. The first distinction -is between Squeak/Croquet VMs that run Squeak, Pharo, Cuis, Croquet images -and their ilk, and between Newspeak VMs that run Newspeak. +is between Squeak/Croquet VMs that run Squeak, Cuis, Croquet images +and their ilk. Another distinction is between Stack, Cog and Sista VMs. Stack VMs are those with context-to-stack mapping that optimise message sending by keeping method activations on a stack instead of in contexts. These are pure interpreters but significantly faster than the standard context-based Interpreter VM. Cog VMs -add a JIT to the mix, compiling methods used more than once to maxchine code on +add a JIT to the mix, compiling methods used more than once to maschine code on the fly. Sista VMs, as yet unrealised and in development, add support for adaptive optimization that does speculative inlining at the bytecode-to-bytecode level. These are targeted for release in 2015. @@ -53,8 +52,8 @@ whereas debug VMs are compiled with no optimization at all, providing maximum debuggability with minimum performance. This directory tree provides build directories for some of this matrix. For -example, newspeak.stack.spur contains a build directory -for Newspeak Stack VMs using the Spur object representation. Build as desired. +example, squeak.stack.spur contains a build directory +for Smalltalk Stack VMs using the Spur object representation. Build as desired. Checking out sources to build out-of-the-box @@ -67,21 +66,31 @@ Check-out the repository from github: Building out of the box ----------------------- -The standard build configurations are the MinGW tools under Cygwin. -The build system also supports Visual Studio Community (tested with 2017), but -requires Cygwin tools, especially GNU Make, to run. - -Cygwin 1. Install the tools: -- Install - either cygwin 64bits version from www.cygwin.com. - either mingw 64bits version and msys from www.mingw.com. -list of packages called "mingw64-x86_64-gcc-core,mingw64-x86_64-gcc-g++,mingw64-x86_64-headers,mingw64-x86_64-runtime". - -Cygwin 2. Build -Then cd to the build directory of your choice, e.g. - building/win64x64/squeak.stack.spur/ -Then execute - ./mvm +The standard build configurations are for LLVM/Clang and an MSYS2 shell. You can +either build against the WinSDK directly, which is the recommended way, or +against mingw-w64. + +If you do not know about any of these technologies, here are the resources +to get started: + - LLVM/Clang: https://clang.llvm.org/ + - MSYS2: https://www.msys2.org/ + - Mingw-w64: https://www.mingw-w64.org/ + - Windows SDK: https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ + +Option A - WinSDK + 1. Install MSYS2 via "scripts/installMSYS2.cmd base" + 2. Install "Visual Studio Community Edition" (incl. Windows 10 SDK) + - https://visualstudio.microsoft.com/de/vs/community/ + - Note that recent versions come with own Clang besides MSVCC + - Note that "C++ ATL Support" is required for the CameraPlugin + 3. [optional] Install another LLVM/Clang that targets *-pc-windows-msvc + - https://github.com/llvm/llvm-project/releases + 4. Open MSYS2 shell with default MSYS environment + - Typically "c:/msys64/msys2.exe" or "c:/msys64/msys2_shell.cmd -msys2" + 5. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm" + - Use another LLVM/Clang via "./mvm -- LLVM_BIN=c:/llvm/bin/ " + - Use LLVM/Clang from $PATH via "./mvm -- LLVM_BIN='' " This builds debug, assert and production versions of the VM in builddbg/vm, buildast/vm and build/vm. If the configuration includes multi-threaded builds @@ -93,35 +102,31 @@ to access standard i/o. In order to only build the production vm, you can launch the command: ./mvm -f -For building with clang instead of gcc, it is possible to pass options to make via mvm after --: - ./mvm -f -- CC=x86_64-w64-mingw32-clang -If building from mingw64, it may be necessary to omit the tool prefix: - ./mvm -f -- TOOLPREFIX='' +Option B - mingw-w64 + 1. Install MSYS2 via "scripts/installMSYS2.cmd x86_64" + 2. Open MSYS2 shell with MINGW64 environment + - Typically "c:/msys64/mingw64.exe" or "c:/msys64/msys2_shell.cmd -mingw64" + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "./mvm -- TOOLPREFIX='' " +Note that any other version of Clang must be installed only through +MSYS2 and target *-w64-windows-gnu to produce the correct .o files. + -MSVC 1. Install the tools: -- follow step Cygwin 1. Install the tools -- Make sure that the tools directory (e.g., C:\cygwin\bin) is in your PATH environment variable -- Install Visual Studio Community from https://visualstudio.microsoft.com/downloads/ -- Install a Windows Kit from https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ +Option C - WinSDK via x64 Native Tools Command Prompt + 1. Do steps 1 to 3 from option A. + 2. Open an x64 Native Tools Command Prompt + - Needs "MSVC v143 - VS 2022 C++ x64/86 Buildtool" for "Native Tools Command Prompt" + 3. Change to the vm flavor of your choice, e.g. squeak.cog.spur, and + execute "..\common\SETPATH_MSYS2.BAT " + 4. Then execute the other batch files to build the VM + ..\common\MAKEDEBUG.BAT + ..\common\MAKEASSERT.BAT + ..\common\MAKEFAST.BAT -MSVC 2. Build -Open a x64 Native Tools Command Prompt from Visual Studio. -Then cd to the build directory of your choice, e.g. - building/win64x64\squeak.cog.spur\ -Then execute - ..\common\SETPATH.BAT -to add the cygwin tools to your path (edit SETPATH if they are not installed in -c:\cygwin64) -Then execute - ..\common\MAKEDEBUG.BAT - ..\common\MAKEASSERT.BAT - ..\common\MAKEFAST.BAT -to make each of the three VMs. -Both Builds Each build directory contains two files plugins.int plugins.ext @@ -130,8 +135,6 @@ directory (which defaults to ../../src/plugins), and which are to be linked into the VM (plugins.int) or compiled as external dlls to be dynamically linked at run-time (plugins.ext). Tailor these files as you wish. -The Newspeak builds include an installer. See Building an MSI installer below. - Finally, at the building/win64x64 level the makeall script will run all the mvm scripts it can find. @@ -149,13 +152,13 @@ Building the VM Simulator Support Libraries If you want to get the Cog VM simulator working you'll need to build one or more of the processor simulator plugins, each of which has support libraries that must be built: - Processor Plugin Support Library - x86 BochsIA32Plugin building/win64x64/bochsx86 - x86_64/x64 BochsX64Plugin building/win64x64/bochsx64 - ARMv5 GdbARMPlugin building/win64x64/gdbarm32 - ARMv8 GdbARMv8Plugin building/win64x64/gdbarm64 + Processor Plugin Support Library + x86 BochsIA32Plugin building/win64x64/bochsx86 + x86_64/x64 BochsX64Plugin building/win64x64/bochsx64 + ARMv5 GdbARMPlugin building/win64x64/gdbarm32 + ARMv8 GdbARMv8Plugin building/win64x64/gdbarm64 cd to the relevant directories; run conf.COG and then the build script, e.g. - $ cd building/linux32x86/bochsx86 + $ cd building/win64x64/bochsx64 $ ./conf.COG $ ./makeem @@ -163,24 +166,16 @@ Then when Squeak VMs are built they will include the plugin(s) for which support libraries have been provided. -Building an MSI installer (Newspeak) ------------------------------------- -The Newspeak builds include an installer subdirectory. The installer build -creates an MSI installer that provides a platform-conformat install experience -for the VM. First build the VM then cd to the installer and make, e.g.: - $ cd newspeak.cog.spur - $ ./mvm - $ cd installer - $ make - - Optimization level and gcc version ---------------------------------- -There used to be issues with gcc version > 4.2.1. Any of the following flags may break the build at -O2: --ftree-pre --fpartial-inlining --fcaller-saves -However, with removal of some Undefined Behavior in source code, this list might well be out of date. +There used to be issues with gcc version > 4.2.1. Any of the following flags +may break the build at -O2: + -ftree-pre + -fpartial-inlining + -fcaller-saves + +However, with removal of some Undefined Behavior in source code, this list might +well be out of date. See http://smallissimo.blogspot.fr/2013/02/compiling-squeak-cog-virtual-machine-on.html @@ -195,7 +190,7 @@ unstripped VM to provide symbols, e.g. (gdb) file SqueakUnstripped.exe (gdb) run trunk.image -Note that on Cygwin, while cross-compilation works well, cross debugging does +Note that on MSYS2, while cross-compilation works well, cross debugging does not work at all. One has to debug 32-bit executables on a 32-bit installation with a 32-bit gdb, and 64-bit executables on a 64-bit installation with a 64-bit gdb. diff --git a/building/win64x64/common/Makefile b/building/win64x64/common/Makefile index ec77a48f0b..d7eca033ff 100644 --- a/building/win64x64/common/Makefile +++ b/building/win64x64/common/Makefile @@ -1,8 +1,26 @@ ############################################################################# -# Common Makefile for Win32 VM using gcc, cygwin and gnu make +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Visit: https://www.msys2.org/ +# Visit: https://www.mingw-w64.org/ +# +# Make sure to install Clang via MSYS2 pacman to get a compiler that targets +# *-w64-windows-gnu . Other pre-built Clang bundles for Windows will target +# *-pc-windows-msvc . See Makefile.WinSDK for the MSVC toolchain. +# +# RECOMMENDED: Start MSYS2/MINGW64 environment, run "mvm" script. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# # Do make init to allow make -n to function. ############################################################################# +# Use SDKPREFIX configure custom build environments (e.g., .WinSDK). There +# are customization hooks for .rules, .rules.*, .tools, .tools.*, and .plugin +SDKPREFIX?= + ############################################################################# # Parameters: # VM the name of the exe to build, defaults to Squeak (=> Squeak.exe) @@ -54,7 +72,7 @@ else BUILD:=builddbg endif endif -$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory + PLUGINSRCDIR:= ../../../src export PLUGINSRCDIR OBJDIR:= $(BUILD)/vm @@ -71,14 +89,25 @@ WIN32UTILDIR:=$(PLATDIR)/win32/util CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) ifeq ($(THREADING),multi) -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terpmt.c $(VMSRCDIR)/cogit.c) else -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c) +MAKERSRC:= $(wildcard $(VMSRCDIR)/[ci]*terp.c $(VMSRCDIR)/cogit.c) endif VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR) +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile$(SDKPREFIX).tools +include ../common/Makefile$(SDKPREFIX).tools.print +include ../common/Makefile$(SDKPREFIX).tools.flags +include ../common/Makefile$(SDKPREFIX).tools.defs + +############################################################################# +$(shell $(MKDIR) deps >/dev/null) # deps is the dependencies directory + ############################################################################# # The internal (.lib) and external (.dll) plugins # @@ -89,15 +118,22 @@ LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS))) DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS))) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBM_LIB?=libm.a +export LIBM_LIB +LIBS:=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) export BIT_IDENTICAL_FLOATING_POINT endif +.PHONY: libs dlls + +libs: $(LIBS) +dlls: $(DLLS) + ############################################################################# # The third-party libraries # ifneq ($(THIRDPARTYLIBS),) -include ../common/Makefile.lib.extra +include ../common/Makefile$(SDKPREFIX).lib.extra THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR) endif @@ -110,19 +146,9 @@ VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ)) ############################################################################# # SqueakVM definitions # -ifeq ($(CONFIGURATION),product) -VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe -CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe -STRIPEXE:= $(OBJDIR)/$(VM).exe -STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe -else VMEXE:= $(OBJDIR)/$(VM).exe CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe -STRIPEXE:= -STRIPCONSOLEEXE:= -endif VMDEF:= $(VM).def -VMEXP:= $(OBJDIR)/$(VM).exp VMMAP:= $(OBJDIR)/$(VM).map CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map VMLIB:= $(VM).lib @@ -130,16 +156,11 @@ VMRES:= $(VM).res VMDEFIN:=$(VM).def.in BTOBJ:= $(OBJDIR)/btext.o ETOBJ:= $(OBJDIR)/etext.o -JMPASM:=_setjmp-x64.asm -JMPOBJ:=$(OBJDIR)/_setjmp-x64.o +JMPASM:=_setjmp-$(ARCH).asm +JMPOBJ:=$(OBJDIR)/_setjmp-$(ARCH).o .PRECIOUS: mkNamedPrims.exe -############################################################################# -# Toolchain -# -include ../common/Makefile.tools - INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) .SUFFIXES: @@ -148,9 +169,13 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) ############################################################################# # Common build rules # +include ../common/Makefile$(SDKPREFIX).rules +include ../common/Makefile$(SDKPREFIX).rules.vm default: product # ensure two-pass initialization, see below -defaultBuild: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST) +defaultBuild: print-tools print-settings init vm vm-extra $(APPPOST) + +vm: libs $(VMEXE) $(CONSOLEVMEXE) dlls svnver: echo $(RC) $(RCFLAGS) @@ -179,25 +204,28 @@ init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg clean: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGF build deps cleanmt: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTF buildmt deps cleanast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGA buildast deps cleanmtast: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTA buildmtast deps cleandbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGD builddbg deps cleanmtdbg: - rm -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps + $(RM) -rf sqNamedPrims.h mkNamedPrims.* LOGTD buildmtdbg deps nukelibs: - rm $(LIBS) + $(RM) $(LIBS) + +nukedlls: + $(RM) $(DLLS) .PHONY : print-settings @@ -208,6 +236,7 @@ print-settings: $(info VPATH=$(VPATH)) $(info INCLUDES=$(INCLUDES)) $(info CFLAGS=$(CFLAGS)) + $(info DEFS=$(DEFS)) $(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS)) $(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS)) $(info OBJDIR=$(OBJDIR)) @@ -222,121 +251,63 @@ print-objects: $(info VMOBJ=$(VMOBJ)) $(info -----------------------------------------------------) -.PHONY : print-tools - -print-tools: - $(info ---------------- Build tools ------------------------) - $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) - $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) - $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) - $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) - $(info AR $(shell which $(ARX)) $(shell $(ARX) --version 2> /dev/null | head -n 1)) - $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) - $(info DLLTOOL $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) - $(info DLLWRAP $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) - $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) - $(info -----------------------------------------------------) - ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore))) -mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c - $(CC) -o $@ -mconsole -m64 $< - $(BTOBJ): $(WIN32MISCDIR)/btext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(ETOBJ): $(WIN32MISCDIR)/etext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + $(CC) -c $< -fomit-frame-pointer -Os -o $@ $(JMPOBJ): $(WIN32MISCDIR)/$(JMPASM) $(CC) -c $< -o $@ -vm: $(VMEXE) - -$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(LDFLAGS) -o $(VMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) - -$(CONSOLEVMEXE): $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) - -ifneq ($STRIPEXE,) -$(STRIPEXE): $(VMEXE) - $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) - -$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) - $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) -endif - $(OBJDIR): - @-mkdir $(BUILD) - mkdir $(OBJDIR) + @-$(MKDIR) $(BUILD) + $(MKDIR) $(OBJDIR) ifneq ($(INTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) endif ifneq ($(EXTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) + $(MKDIR) $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) endif -############################################################################# -# The exports for named primitives from Squeak (required by VM) -# -$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) - $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) - ############################################################################# # Building plugins # .PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll - +.PHONY: always # Check for Makefile in win32 plugins directory otherwise use default Makefile -plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.plugin ../common/Makefile.plugin))) +plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile$(SDKPREFIX).plugin ../common/Makefile$(SDKPREFIX).plugin))) # Internal plugin. Build as lib then link in lib -$(OBJDIR)/%.lib: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/vm/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.lib: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/vm/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) INTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ COGDEFS="$(COGDEFS) -DSQUEAK_BUILTIN_PLUGIN=$(*F)" $(OBJDIR)/$(*F).lib # External plugin. Build as dll and copy to vm dir ($(OBJDIR)). -$(OBJDIR)/%.dll: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ +$(OBJDIR)/%.dll: always + $(info WILDCARD $(*F): $(wildcard $(BUILD)/$(*F)/*.o)) + @-$(MKDIR) $(BUILD)/$(*F) + $(RM) -f $(BUILD)/$(*F).ignore + $(MAKE) $(MFLAGS) $(SUBMFLAGS) -I../common BUILD=$(BUILD) \ -f $(call plugin-makefile,$(*F)) \ LIBNAME=$(*F) EXTERNAL_PLUGIN=1 VMSRCDIR=$(VMSRCDIR) \ JMPOBJ=$(JMPOBJ) VMLIB=$(OBJDIR)/$(VMLIB) \ COGDEFS="$(COGDEFS) -DSQUEAK_EXTERNAL_PLUGIN=$(*F)" $(OBJDIR)/$(*F).dll +# Build fdlibm with GNU ar and GNU ranlib. Override $(LIBM_LIB) and add +# custom rule to choose, e.g., different librarian method. $(BUILD)/fdlibm/libm.a: - @-mkdir -p $(@D) + @-$(MKDIR) $(@D) $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ - TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote - - -############################################################################# -# Basic rules -# -include ../common/Makefile.rules - -$(VMRES): $(VM).rc - $(RC) $(RCFLAGS) -i $(VM).rc -o $@ - $(CP) $(VM).exe.manifest $(OBJDIR) - $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest - -resource.o: $(VMRES) - $(RC) $(RCFLAGS) -i $< -o $@ + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote libm.a ############################################################################# # Extra specific dependencies diff --git a/building/win64x64/common/Makefile.WinSDK b/building/win64x64/common/Makefile.WinSDK new file mode 100644 index 0000000000..f4e7526976 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK @@ -0,0 +1,33 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# -> https://github.com/llvm/llvm-project/releases +# -> https://developer.microsoft.com/de-de/windows/downloads/windows-sdk/ +# -> https://visualstudio.microsoft.com/de/vs/community/ +# -> https://www.msys2.org/ +# +# Make sure to either use a Clang from MS Visual Studio or a pre-built +# clang that targets *-pc-windows-msvc. The Clang from MSYS2 pacman will +# target *-w64-windows-gnu . See Makefile for the MSYS2 toolchain. +# +# RECOMMENDED: Start plain MSYS2 shell, run "mvm" script. +# Alternative: Start Native Tools Command Prompt, run SETPATH then MAKE*.BAT. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Do make init to allow make -n to function. +############################################################################# + +SDKPREFIX:=.WinSDK +LIBM_LIB:=libm.lib + +include ../common/Makefile + +$(BUILD)/fdlibm/$(LIBM_LIB): + @-$(MKDIR) $(@D) + $(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \ + LIBRARIAN='$(LIBRARIAN)' \ + TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote $(LIBM_LIB) diff --git a/building/win64x64/common/Makefile.WinSDK.lib.extra b/building/win64x64/common/Makefile.WinSDK.lib.extra new file mode 100644 index 0000000000..55940179f5 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.lib.extra @@ -0,0 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# THIRDPARTYLIBS The libraries to build (you define them in ./third-party/LIB/Makefile.lib) +# THIRDPARTYDIR Where to build libraries +# THIRDPARTYOUTDIR Where to first install libraries (output place) +# THIRDPARTYCACHEDIR Where to download thirdparty libraries +# +############################################################################# + +# Under construction. See Makefile.lib.extra for a template. diff --git a/building/win64x64/common/Makefile.WinSDK.plugin b/building/win64x64/common/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..23c8f72ca7 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.plugin @@ -0,0 +1,141 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Generic Makefile for plugins +############################################################################# +# +# The following variables can be overridden in the platform Makefile, e.g. +# platforms/win32/plugins/BochsIA32Plugin/Makefile. Look at +# platforms/win32/plugins/*/Makefile for examples. +# +# EXCLUDESRC defines patterns of source files to not compile, e.g. %/dump.c +# +# The following variables can be defined to extend the compilation flags. +# +# XCFLAGS adds additional compilation flags after all other C preprocessor define flags +# XINC adds additional include flags after all other INCLUDE flags +# +# The following are the three key locations (set via invocation): +# BUILDDIR: Where is the root of the build tree? +# PLATDIR: Where is the root of the platforms tree? +# SRCDIR: Where is the root of the src tree? (i.e. ../../../winbuild/src) + +############################################################################# +# Standard directory locations: +# CROSSDIR: The location of the cross platform sources +# WIN32DIR: The location of the win32 sources +# MAKERDIR: The location of the VMMaker generated sources +# BUILDDIR: The location where the plugin is built +# +CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME) +WIN32DIR:= $(PLATDIR)/win32/plugins/$(LIBNAME) +MAKERDIR:= $(PLUGINSRCDIR)/plugins/$(LIBNAME) +BUILDDIR:= $(BUILD)/$(LIBNAME) + +# Support directory locations +CROSSVMDIR:= $(PLATDIR)/Cross/vm +WIN32VMDIR:= $(PLATDIR)/win32/vm +WIN32MISCDIR:=$(PLATDIR)/win32/misc +MAKERVMDIR:= $(SRCDIR)/vm + +############################################################################# +# Standard include sources +# +INCLUDES:= -I. \ + -I$(VMSRCDIR) -I$(WIN32VMDIR) -I$(CROSSVMDIR) \ + -I$(MAKERDIR) -I$(WIN32DIR) -I$(CROSSDIR) + +############################################################################# +# If no source files were given, use standard set +# +CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) +WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) +MAKERSRC:= $(wildcard $(MAKERDIR)/*.c) +LIBSRC?= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) +ifneq ($(EXCLUDESRC),) +LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) +endif + +############################################################################# +# Plugin settings +# +OBJDIR:= $(BUILD)/$(LIBNAME) +VMDIR:= $(BUILD)/vm +PLUGINLIB:= $(VMDIR)/$(LIBNAME).lib +PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll +LIBOBJ?= $(LIBSRC:.c=.o) +LIBOBJ:= $(LIBOBJ:.cpp=.o) +LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) +ifdef BIT_IDENTICAL_FLOATING_POINT +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) +endif + +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.WinSDK.tools +include ../common/Makefile.WinSDK.tools.flags +include ../common/Makefile.WinSDK.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.WinSDK.rules + +VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) + +all: $(PLUGINLIB) $(PLUGINDLL) + +.PHONY : print-settings + +print-settings: + $(info ---------------- Makefile settings ------------------) + $(info PATH='$(PATH)') + $(info VPATH='$(VPATH)') + $(info INCLUDES='$(INCLUDES)') + $(info DEFS='$(DEFS)') + $(info CFLAGS='$(CFLAGS)') + $(info SRCDIR='$(SRCDIR)') + $(info CROSSDIR='$(CROSSDIR)') + $(info WIN32DIR='$(WIN32DIR)') + $(info WIN32MISCDIR='$(WIN32MISCDIR)') + $(info MAKERDIR='$(MAKERDIR)') + $(info CROSSSRC='$(CROSSSRC)') + $(info WIN32SRC='$(WIN32SRC)') + $(info MAKERSRC='$(MAKERSRC)') + $(info EXCLUDESRC='$(EXCLUDESRC)') + $(info LIBSRC='$(LIBSRC)') + $(info LIBOBJ='$(LIBOBJ)') + $(info OBJDIR='$(OBJDIR)') + $(info VMDIR='$(VMDIR)') + $(info VMLIB='$(VMLIB)') + $(info PLUGINSRCDIR='$(PLUGINSRCDIR)') + $(info PLUGINLIB='$(PLUGINLIB)') + $(info PLUGINDLL='$(PLUGINDLL)') + $(info PLUGINDLL_LIBS='$(PLUGINDLL_LIBS)') + $(info XINC='$(XINC)') + $(info XDEFS='$(XDEFS)') + $(info -----------------------------------------------------) + +$(OBJDIR): + $(MKDIR) $(subst /,\\,$(OBJDIR)) + +$(VMDIR): + $(MKDIR) $(subst /,\\,$(VMDIR)) + +$(PLUGINLIB): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(LIBSRC) + -$(RM) $(PLUGINLIB) + $(LIBRARIAN) $(LIBOBJ) $(EXTRALIBS) -out:$(subst /,\\,$(PLUGINLIB)) + +PLUGINDLL_LIBS:=WinMM.lib ole32.lib msdmo.lib user32.lib kernel32.lib /NODEFAULTLIB:libc /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt + +$(PLUGINDLL): $(VMDIR) $(OBJDIR) $(LIBOBJ) $(JMPOBJ) $(LIBSRC) + $(LD) $(LDFLAGS) -DLL $(LIBOBJ) $(JMPOBJ) $(VMLIB) $(PLUGINDLL_LIBS) $(EXTRALIBS) \ + -NOIMPLIB \ + -LIBPATH:$(BUILD)/vm \ + -OUT:$(subst /,\\,$(PLUGINDLL)) diff --git a/building/win64x64/common/Makefile.WinSDK.rules b/building/win64x64/common/Makefile.WinSDK.rules new file mode 100644 index 0000000000..4e567797e8 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.rules @@ -0,0 +1,16 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +include ../common/Makefile.rules + +# Microsoft (R) Windows (R) Resource Compiler; see Makefile.WinSDK +# %.res: %.rc +# $(RC) $(RCFLAGS) -Fo $@ $< diff --git a/building/win64x64/common/Makefile.WinSDK.rules.vm b/building/win64x64/common/Makefile.WinSDK.rules.vm new file mode 100644 index 0000000000..9c284314ed --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.rules.vm @@ -0,0 +1,38 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -c $< -o mkNamedPrims.obj + $(LD) -out:$@ mkNamedPrims.obj -subsystem:console -defaultlib:libcmt + +.PHONY: vm-extra +vm-extra: + $(info No extra things to do for the VM.) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -OUT:$(VMEXE) -MAP:$(VMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +$(CONSOLEVMEXE): $(VMOBJ) libs resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o$(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -OUT:$(CONSOLEVMEXE) -MAP:$(CONSOLEVMMAP) \ + $(BTOBJ) $(VMOBJ) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + +# Microsoft (R) Windows (R) Resource Compiler +%.res: %.rc + $(RC) $(RCFLAGS) -Fo $@ $< + +# Microsoft (R) Windows Resource To Object Converter +resource.o: $(VMRES) + $(CVTRES) -MACHINE:$(ARCH) -OUT:resource.o $(VMRES) + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win64x64/common/Makefile.WinSDK.tools b/building/win64x64/common/Makefile.WinSDK.tools new file mode 100644 index 0000000000..6f4372add1 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.tools @@ -0,0 +1,108 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# Supported architecures: x86, x64, arm64 +ARCH:=x64 +# Export ARCH to be used in plugins such as IA32ABI (i.e. FFI callbacks) +export ARCH + +############################################################################# +# Set paths to toolchain. Note that $(LLVM_BIN) and $(MSYS2_BIN) may be +# empty, relying on $(PATH) to find those tools. +# + +include ../common/Makefile.WinSDK.tools.paths + +ifeq ($(VCToolsBinDir),) + $(error Failed to locate Visual Studio build tools!) +endif + +ifeq ($(WindowsSDKToolsBinDir),) + $(error Failed to locate Windows SDK build tools!) +endif + +ifeq ($(LLVM_BIN),) + $(info Using clang from PATH...) +endif + +ifeq ($(MSYS2_BIN),) + $(info Using GNU tools from PATH...) +endif + +############################################################################# +# C compiler settings +# + +CC:=$(LLVM_BIN)clang +CXX:=$(LLVM_BIN)clang++ + +TZ:=$(shell $(MSYS2_BIN)date +%Z) + +# Microsoft Macro Assembler; not needed, use LLVM/Clang; see Makefile.WinSDK +# AS:=$(VCToolsBinDir)/ml64 + +############################################################################# +# Linker settings +# +LD:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LDCXX:=$(VCToolsBinDir)/LINK -nologo -MACHINE:$(ARCH) -INCREMENTAL:NO +LIBRARIAN:=$(VCToolsBinDir)/LIB -nologo + +# The JIT will attempt to alloca up to 1.5Mb by default on x86-64. So set +# the default stack size to 2Mb to avoid crashes in the JIT's alloca. +ifeq ($(DEFAULT_STACK_SIZE),) +DEFAULT_STACK_SIZE:=2097152 +endif +STACK_LD_FLAG=-STACK:$(DEFAULT_STACK_SIZE),$(DEFAULT_STACK_SIZE) + +BASELDFLAGS:= $(STACK_LD_FLAG) -DYNAMICBASE -LARGEADDRESSAWARE -NXCOMPAT -DEBUG:FULL +LDFLAGS:= -subsystem:windows $(BASELDFLAGS) $(EXTRALDFLAGS) +CONSOLELDFLAGS:= -subsystem:console $(BASELDFLAGS) $(EXTRALDFLAGS) +DL:=-DEFAULTLIB: +NDL:=-NODEFAULTLIB: + +ifdef BIT_IDENTICAL_FLOATING_POINT +EXTRANDLS:=-NODEFAULTLIB:libm +endif +STDLIBS:=$(STDLIBS) $(NDL)libc $(NDL)libcmt $(EXTRANDLS) $(DL)msvcrt \ + dinput8.lib dsound.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \ + version.lib wininet.lib user32.lib gdi32.lib psapi.lib \ + advapi32.lib kernel32.lib secur32.lib shell32.lib shfolder.lib + +############################################################################# +# Tools to use (usually all from GNU coreutils). If $(MSYS2_BIN) +# prefix is empty, rely on $(PATH) to find tools. +# +CP:= $(MSYS2_BIN)cp +RM:= $(MSYS2_BIN)rm +MV:= $(MSYS2_BIN)mv +MKDIR:=$(MSYS2_BIN)mkdir -p + +############################################################################# +# RC settings, Microsoft Resource Compiler +# CVTRES settings, Microsoft Resource To Object Converter +# +# Note: RC compiles the .rc files into linkable .o files +# +RC:=$(WindowsSDKToolsBinDir)/rc -nologo +CVTRES:=$(VCToolsBinDir)/cvtres -nologo +SED:=$(MSYS2_BIN)sed +GREP:=$(MSYS2_BIN)grep +BASH:=$(MSYS2_BIN)bash +SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h + +ifneq ($(shell $(GREP) 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) +$(shell $(BASH) -c "cd ../../../scripts; ./updateSCCSVersions") +endif +SVNMAJOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: \([0-9][0-9][0-9][0-9]\).*/\\1/p" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNMINOR := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNREV := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') +SVNBUILD := $(shell $(SED) -e "s/^static.*GitRawRevisionString.*Rev: [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\([0-9][0-9]*\).*/\\1/p" -e "s/^0*//" -e d $(SCCSVER) | $(SED) -e 's/^0*//') + +RCFLAGS:= -i $(PLATDIR)/win32/misc -D_WIN32 -DFILEVERSIONVALUES=$(SVNMAJOR),$(SVNMINOR),$(SVNREV),$(SVNBUILD) -DFILEVERSIONSTRING="\"$(SVNMAJOR).$(SVNMINOR).$(SVNREV).$(SVNBUILD)\"" diff --git a/building/win64x64/common/Makefile.WinSDK.tools.defs b/building/win64x64/common/Makefile.WinSDK.tools.defs new file mode 100644 index 0000000000..58292b14cc --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.tools.defs @@ -0,0 +1,37 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +include ../common/Makefile.tools.defs + +############################################################################# + +# Enable the LLP64 data model, where only pointers expand to 64-bits +# https://learn.microsoft.com/en-us/windows/win32/winprog64/abstract-data-models +POINTER_MODEL:=-DLLP64=1 +DEFS:=$(POINTER_MODEL) $(DEFS) + +# Make all setjmp/longjmp varieties to our _setjmp/_longjmp in _setjmp-x64.asm +JMPDEFS:=-Dsetjmp=_setjmp -Dlongjmp=_longjmp -D_siglongjmp=_longjmp +DEFS:= $(JMPDEFS) $(DEFS) + +# ??? +FUNDEFS:=-Dalloca=_alloca -Dhuge=my_huge +DEFS:= $(FUNDEFS) $(DEFS) + + + + + + + +# Do _not_ define NDEBUG. The entire point of the msvc build is to debug with +# MSVC and defining NDEBUG installs a default catch-everything exception handler +# that effectively disables debugging. +# XDEFS= -DSQUEAK_BUILTIN_PLUGIN diff --git a/building/win64x64/common/Makefile.WinSDK.tools.flags b/building/win64x64/common/Makefile.WinSDK.tools.flags new file mode 100644 index 0000000000..8bfeeb8f30 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.tools.flags @@ -0,0 +1,18 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (e.g., OFLAGS, CFLAGS) for LLVM/Clang +############################################################################# + +# Skip mingw-w64 specific configuration flags that should not be required +# when using a clang that targets msvc format. +NOBUILTIN= +CALLING_CONVENTION= +BITFIELD_LAYOUT= +DECLSPEC= + +include ../common/Makefile.tools.flags diff --git a/building/win64x64/common/Makefile.WinSDK.tools.paths b/building/win64x64/common/Makefile.WinSDK.tools.paths new file mode 100644 index 0000000000..c3cb8b826a --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.tools.paths @@ -0,0 +1,122 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Check or lookup paths to the compiler, other build tools (e.g., GNU make or +# MS Link), and the Windows SDK. +############################################################################# + +WindowsSdkMajorVersion:=10 +HostARCH:=HostX64 + +ifeq ($(MSYS2_BIN),) + MSYS2_BIN:=c:/msys64/usr/bin/ +else + override MSYS2_BIN:=$(subst \,/,$(MSYS2_BIN)) +endif + +############################################################################# +# Set paths to the Windows SDK (and tools) and Visual Studio (and tools) +# +ifeq ($(VCINSTALLDIR),) + # ../[2017 2022]/[Community Enterprise]/VC + VCINSTALLDIR:=C:/Program\ Files/Microsoft\ Visual\ Studio/*/*/VC + VCINSTALLDIR:=$(wildcard $(VCINSTALLDIR)) +else + override VCINSTALLDIR:=$(subst \,/,$(VCINSTALLDIR)) +endif + +ifeq ($(VCToolsInstallDir),) + # ../MSVC/[14.29.30133 14.44.35207] + VCToolsInstallDir:=$(VCINSTALLDIR)/Tools/MSVC/* + VCToolsInstallDir:=$(shell echo "$(VCToolsInstallDir)" | sed 's/ /\\ /g') + VCToolsInstallDir:=$(wildcard $(VCToolsInstallDir)) + # To make sort and lastword work, mask space-ridden VCINSTALLDIR + VCToolsInstallDir:=$(subst $(VCINSTALLDIR),%MAKETMP123%,$(VCToolsInstallDir)) + VCToolsInstallDir:=$(sort $(VCToolsInstallDir)) + VCToolsInstallDir:=$(lastword $(VCToolsInstallDir)) + VCToolsInstallDir:=$(subst %MAKETMP123%,$(VCINSTALLDIR),$(VCToolsInstallDir)) +else + override VCToolsInstallDir:=$(subst \,/,$(VCToolsInstallDir)) +endif + + +############################################################################# +# Set paths to LLVM, for compilers (and maybe other build tools). +# Note that Visual Studio ships its own version of LLVM/Clang these days. +# + +# LLVM_BIN:=c:/llvm/bin/ + +VCLlvmInstallDir:=$(VCINSTALLDIR)/Tools/Llvm +LLVM_BIN:=$(VCLlvmInstallDir)/$(ARCH)/bin/ + +# Must escape whitespace and parentheses for scripts +LLVM_BIN:=$(shell echo "$(LLVM_BIN)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to MSVC linker and library tools, LINK and LIB. +# + +VCToolsBinDir:=$(VCToolsInstallDir)/bin/$(HostARCH)/$(ARCH) +VCToolsBinDir:=$(shell echo "$(VCToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to Windows SDK and tools (e.g. RC and CVTRES). +# +ifeq ($(WindowsSdkDir),) + WindowsSdkDir:=C:/Program Files (x86)/Windows Kits/$(WindowsSdkMajorVersion)/ +else + override WindowsSdkDir:=$(subst \,/,$(WindowsSdkDir)) +endif +ifeq ($(WindowsSDKVersion),) + WindowsSDKVersion:=$(WindowsSdkDir)/include/$(WindowsSdkMajorVersion)* + WindowsSDKVersion:=$(shell echo "$(WindowsSDKVersion)" | sed 's/ /\\ /g') + WindowsSDKVersion:=$(wildcard $(WindowsSDKVersion)) + WindowsSDKVersion:=$(subst $(WindowsSdkDir)/include/,,$(WindowsSDKVersion)) + # Use only newest SDK version + WindowsSDKVersion:=$(sort $(WindowsSDKVersion)) + WindowsSDKVersion:=$(lastword $(WindowsSDKVersion)) +endif +override WindowsSDKVersion:=$(subst \,,$(WindowsSDKVersion)) + +WindowsSDKToolsBinDir:=$(WindowsSdkDir)/bin/$(WindowsSDKVersion)/$(ARCH) +WindowsSDKToolsBinDir:=$(shell echo "$(WindowsSDKToolsBinDir)" | sed 's/[() ]/\\&/g') + + +############################################################################# +# Set paths to INCLUDE headers from Visual Studio (e.g., COM stuff) and +# Windows SDK (e.g., standard C library). +# +ifeq ($(INCLUDE),) +INCLUDE:=$(VCToolsInstallDir)/ATLMFC/include;$(VCToolsInstallDir)/include;$(VCINSTALLDIR)/Auxiliary/VS/include;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/shared;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/ucrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/um;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/winrt;$(WindowsSdkDir)/include/$(WindowsSDKVersion)/cppwinrt +INCLUDE:=$(subst //,/,$(INCLUDE)) +INCLUDE:=$(subst /,\,$(INCLUDE)) +#$(info INCLUDE is $(INCLUDE)) +endif +MSVCINCLUDES:=-I"$(subst \,/,$(subst ;," -I",$(INCLUDE)))" +#$(info MSVCINCLUDES is $(MSVCINCLUDES)) + +# Put -I. last because boost includes bizarreness such as +# include which will include a local file called list if -I. comes +# early in the include path. Fragile. +INCLUDES:= $(filter-out -I., $(INCLUDES)) $(MSVCINCLUDES) $(XINC) -I. + + +############################################################################# +# Set paths to system libraries from Visual Studio (e.g. COM stuff) and +# Windows SDK (e.g., standard C lib). +# +ifeq ($(LIB),) +LIB:=$(VCToolsInstallDir)/ATLMFC/lib/$(ARCH);$(VCToolsInstallDir)/lib/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/ucrt/$(ARCH);$(WindowsSdkDir)/lib/$(WindowsSDKVersion)/um/$(ARCH) +LIB:=$(subst //,/,$(LIB)) +LIB:=$(subst /,\,$(LIB)) +export LIB +endif +# $(info LIB is $(LIB)) diff --git a/building/win64x64/common/Makefile.WinSDK.tools.print b/building/win64x64/common/Makefile.WinSDK.tools.print new file mode 100644 index 0000000000..bedb983113 --- /dev/null +++ b/building/win64x64/common/Makefile.WinSDK.tools.print @@ -0,0 +1,30 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info VCToolsBinDir $(VCToolsBinDir)) + $(info WindowsSDKToolsBinDir $(WindowsSDKToolsBinDir)) + $(info WindowsSdkDir $(WindowsSdkDir)) + $(info WindowsSDKVersion $(WindowsSDKVersion)) + $(info MSYS2_BIN $(MSYS2_BIN)) + $(info LLVM_BIN $(LLVM_BIN)) + $(info CC $(shell which $(CC))) + $(info .. $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info CXX $(shell which $(CXX))) + $(info .. $(shell $(CXX) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD) 2> /dev/null)) + $(info LDXX $(shell which $(LD) 2> /dev/null)) + $(info LIBRARIAN $(shell which $(LIBRARIAN) 2> /dev/null)) + $(info RC $(shell which $(RC) 2> /dev/null)) + $(info CVTRES $(shell which $(CVTRES) 2> /dev/null)) + $(info -----------------------------------------------------) diff --git a/building/win64x64/common/Makefile.plugin b/building/win64x64/common/Makefile.plugin index 5e154bf01a..4cd36d9627 100644 --- a/building/win64x64/common/Makefile.plugin +++ b/building/win64x64/common/Makefile.plugin @@ -1,4 +1,10 @@ ############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# # Generic Makefile for plugins on Win64 ############################################################################# # @@ -47,36 +53,6 @@ ifneq ($(EXCLUDESRC),) LIBSRC:=$(filter-out $(EXCLUDESRC),$(LIBSRC)) endif -############################################################################# -# C compiler settings (gcc 4.x) -# -include ../common/Makefile.tools - -# overrides of default toolchain settings - -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O1 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:=-DNDEBUG -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -else -OFLAGS:= -O0 -fno-omit-frame-pointer -DEBUGVM=1 -NDEBUG:= -endif - -XDEFS:= -DEFS:= $(WINVER) -DWIN64=1 -DNO_ISNAN \ - -DNO_SERVICE \ - $(NDEBUG) -DLSB_FIRST -DVM_NAME=\"$(VM)\" $(XDEFS) - -CFLAGS:= -fdeclspec -msse2 -ggdb2 -m64 \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) $(COGDEFS) - - ############################################################################# # DLL settings # @@ -85,9 +61,6 @@ CFLAGS:= -fdeclspec -msse2 -ggdb2 -m64 \ # OPTSTRIP:= echo not doing strip - -.SUFFIXES: .c .cpp .o .s .rc .res .dep - ############################################################################# # Plugin settings # @@ -98,9 +71,20 @@ PLUGINDLL:= $(VMDIR)/$(LIBNAME).dll LIBOBJ ?= $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LIBSRC))) LIBOBJ:= $(addprefix $(OBJDIR)/,$(LIBOBJ)) ifdef BIT_IDENTICAL_FLOATING_POINT -LIBOBJ+=$(BUILD)/fdlibm/libm.a $(LIBS) +LIBOBJ+=$(BUILD)/fdlibm/$(LIBM_LIB) $(LIBS) endif +############################################################################# +# Toolchain (incl. paths to tools and flags for tools) +# +include ../common/Makefile.tools +include ../common/Makefile.tools.flags +include ../common/Makefile.tools.defs + +############################################################################# +# Basic rules +# +include ../common/Makefile.rules VPATH:= $(MAKERDIR) $(WIN32DIR) $(CROSSDIR) $(OBJDIR) @@ -132,10 +116,10 @@ print-settings: $(info -----------------------------------------------------) $(OBJDIR): - mkdir $(OBJDIR) + $(MKDIR) $(OBJDIR) $(VMDIR): - mkdir $(VMDIR) + $(MKDIR) $(VMDIR) # If any prerequisites are declared all must exist to continue ifeq ($(realpath $(PREREQUISITES)),$(abspath $(PREREQUISITES))) @@ -176,11 +160,6 @@ endif $(OPTSTRIP) --strip-all $(VMDIR)/$(LIBNAME).dll -$(RM) $(OBJDIR)/$(LIBNAME).lib -############################################################################# -# Rules for automated builds -# -include ../common/Makefile.rules - else # ifeq ($(realpath $(PREREQUISITES)),$(PREREQUISITES)) # If any prerequisites are missing simply create a .ignore file diff --git a/building/win64x64/common/Makefile.rules b/building/win64x64/common/Makefile.rules index 94ca903a3f..b201a79a8d 100644 --- a/building/win64x64/common/Makefile.rules +++ b/building/win64x64/common/Makefile.rules @@ -1,31 +1,51 @@ ############################################################################# -# Compilation rules for Microsoft Windows +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. # +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compilation rules +############################################################################# + +.SUFFIXES: .c .cpp .o .s .rc .res .dep + +############################################################################# # See http://make.mad-scientist.net/papers/advanced-auto-dependency-generation # for an explanation of the dependency management scheme. +# +$(info OBJDIR is $(OBJDIR)) ifeq ($(findstring /vm,$(OBJDIR)),/vm) BD:=$(BUILD)/vm else -BD:=$(BUILD)/$(LIBNAME)/vm +BD:=$(BUILD)/$(LIBNAME) endif -ALLFLAGS = $(CFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.c - $(CC) -x c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +# Not interested in recording system header dependencies. *must* use " = " +DEPFLAGS = -MMD -MT '$(BD)/$(*F).o' -MF deps/$(*F).d +############################################################################# -$(OBJDIR)/%.o: %.m - $(CC) -x objective-c -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +ALLCFLAGS = $(DEPFLAGS) $(CFLAGS) $(INCLUDES) $(DEFS) +ALLCXXFLAGS = $(DEPFLAGS) $(CXXFLAGS) $(INCLUDES) $(DEFS) -$(OBJDIR)/%.o: %.cpp - $(CXX) -MMD -MT $(BD)/$(*F).o -MF deps/$(*F).d $(ALLFLAGS) -c $< -o $@ +############################################################################# +# Rules for automated builds using LLVM/Clang +# -%res: %.rc - $(RC) $(RCFLAGS) -i $< -o $@ +$(OBJDIR)/%.o: %.c + $(CC) -o $@ $(ALLCFLAGS) -c $< + +$(OBJDIR)/%.o: %.cpp + $(CC) -o $@ $(ALLCXXFLAGS) -c $< +# GNU windres (GNU Binutils); see Makefile +# %.res: %.rc +# $(RC) $(RCFLAGS) -i $< -o $@ deps/%.d: ; .PRECIOUS: deps/%.d --include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC)))) +-include $(patsubst %,deps/%.d,$(notdir $(basename $(VMSRC) $(LIBSRC)))) diff --git a/building/win64x64/common/Makefile.rules.vm b/building/win64x64/common/Makefile.rules.vm new file mode 100644 index 0000000000..7a05dbee84 --- /dev/null +++ b/building/win64x64/common/Makefile.rules.vm @@ -0,0 +1,70 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for building the VM binary itself +############################################################################# + +ifeq ($(CONFIGURATION),product) +VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe +STRIPEXE:= $(OBJDIR)/$(VM).exe +STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe +else +VMEXE:= $(OBJDIR)/$(VM).exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe +STRIPEXE:= +STRIPCONSOLEEXE:= +endif + +############################################################################# +# The exports for named primitives from Squeak (required by VM) +# +VMEXP:= $(OBJDIR)/$(VM).exp +$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) + $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) + +############################################################################# + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -o $@ -mconsole -m64 $< + +.PHONY: vm-extra +vm-extra: $(STRIPEXE) $(STRIPCONSOLEEXE) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCFLAGS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -o $(VMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) + +$(CONSOLEVMEXE): $(VMOBJ) libs $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) $(JMPOBJ) + $(CC) -o $(OBJDIR)/version.o $(ALLCLFAGS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(JMPOBJ) resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) + +ifneq ($STRIPEXE,) +$(STRIPEXE): $(VMEXE) + $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) + +$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) + $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) +endif + +############################################################################# + +# GNU windres (GNU Binutils) +%.res: %.rc + $(RC) $(RCFLAGS) -i $< -o $@ + +# GNU windres (GNU Binutils) +resource.o: $(VMRES) + $(RC) $(RCFLAGS) -i $< -o $@ + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest diff --git a/building/win64x64/common/Makefile.tools b/building/win64x64/common/Makefile.tools index 73cf023c88..5d7d62b149 100644 --- a/building/win64x64/common/Makefile.tools +++ b/building/win64x64/common/Makefile.tools @@ -1,6 +1,10 @@ ############################################################################# -# Compilation rules for 64-bit Cygwin/mingw compiler on Microsoft Windows -# and x64/x86_64 +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# ARCH:=x64 export ARCH @@ -11,79 +15,16 @@ export TOOLPREFIX ############################################################################# # C compiler settings (Use clang for having a working FFI) # -ifeq ($(COMPILER_TO_USE),) -COMPILER_TO_USE:=clang -endif - -ifeq ($(COMPILER_TO_USE),clang) CC:= $(TOOLPREFIX)clang CXX:= $(TOOLPREFIX)clang++ -else -CC:= $(TOOLPREFIX)gcc -CXX:= $(TOOLPREFIX)g++ -endif - -WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label -Wno-unused-function - -# VM config flags. -ifeq ($(CONFIGURATION),product) -OFLAGS:= -O2 -momit-leaf-frame-pointer -funroll-loops -NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts -DEBUGVM=0 -else ifeq ($(CONFIGURATION),assert) -OFLAGS:= -O1 -fno-omit-frame-pointer -DEBUGVM=0 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -else -OFLAGS:= -O0 -fno-omit-frame-pointer -DEBUGVM=1 -NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' -endif - - -ifeq ($(IS_PREPARING),false) - ifeq ($(THREADING),multi) - COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) - else - COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) - endif - ifdef BIT_IDENTICAL_FLOATING_POINT - COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1 - endif - - ifeq ($(COMPILER_TO_USE),clang) - COGDEFS:=$(COGDEFS) -fno-stack-protector - endif -endif # IS_PREPARING - -# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h) -WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 - -# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h -NOBUILTIN:= -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf -CFLAGS:= -fdeclspec -msse2 -ggdb2 -m64 \ - -mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS) - -# Several versions of clang (all versions from 14 through 18 as of this writing) -# generate incorrect code for spur segment storage -# (return:restoringObjectsIn:savedFirstFields:and:savedHashes:) -# unless USE_INLINE_MEMORY_ACCESSORS is set. -MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1 TZ:=$(shell date +%Z) -DEFS:= -D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) \ - -DWIN64=1 -DNO_ISNAN -DNO_SERVICE \ - $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) ############################################################################# # Linker settings # -# Note: I had to use 'gcc' instead of 'ld' to prevent unresolved symbols -# The switch '-mwindows' gives us a GUI app instead of a console app. -# Newer cygwins want --export-all-symbols in place of --export-dynamic. -# -LD:= $(CC) -LDCXX := $(TOOLPREFIX)clang++ # For linking c++ bundles +LD:=$(CC) +LDCXX:=$(CXX) # For linking c++ bundles EXPORT:=--export-all-symbols BASELDFLAGS:=-m64 -mthreads -Wl,--stack -Xlinker 2097152,2097152 -Wl,$(EXPORT) @@ -95,15 +36,18 @@ STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \ ############################################################################# # Tools to use +# - Note that "dllwrap" is replaced by "clang -shared" +# - Note that "ar" produces thin archives (-T) to allow mising .o and .a # -AR:= $(TOOLPREFIX)ar rc -ARX:= $(TOOLPREFIX)ar # must not change $(AR) bc. implicit usage +AR:= $(TOOLPREFIX)ar crUuT CP:= cp RM:= rm SED:=sed +MV:=mv +MKDIR:=mkdir -p NM:= $(TOOLPREFIX)nm DLLTOOL:= $(TOOLPREFIX)dlltool -DLLWRAP:= $(TOOLPREFIX)gcc -shared +DLLWRAP:= $(CC) -shared STRIP:= $(TOOLPREFIX)strip OBJCOPY:= $(TOOLPREFIX)objcopy @@ -112,7 +56,7 @@ OBJCOPY:= $(TOOLPREFIX)objcopy # # Note: RC compiles the .rc files into linkable .o files # -RC:= $(TOOLPREFIX)windres +RC:=$(TOOLPREFIX)windres SCCSVER:=$(PLATDIR)/Cross/vm/sqSCCSVersion.h ifneq ($(shell grep 'GitRawRevisionString.*$$Rev$$.' $(SCCSVER)),) diff --git a/building/win64x64/common/Makefile.tools.defs b/building/win64x64/common/Makefile.tools.defs new file mode 100644 index 0000000000..db7027da5c --- /dev/null +++ b/building/win64x64/common/Makefile.tools.defs @@ -0,0 +1,66 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +############################################################################# + +# See sdkddkver.h from Windows SDK or w32api.h from mingw-w64 +# Windows XP ... 0x0501 +# Windows 7 ... 0x0601 +# Windows 8 ... 0x0602 +# Windows 10 ... 0x0A00 +WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 + +# Every clang for Windows (i.e. *-pc-windows-msvc or *-w64-windows-gnu) already +# defines WIN32, WIN64, etc. So, this might just be historical overhead. +WINBIT:=-DWIN32=1 -D_WIN32=1 -DWIN64=1 -D_WIN64=1 + +#!#! UNICODE applies to API calls, _UNICODE to string representation, so one +#!#! must define both. +WINUNI:=-DUNICODE=1 -D_UNICODE=1 + +############################################################################# +# DEFS +# +ifeq ($(CONFIGURATION),product) +DEBUGVM= 0 +NDEBUG:= -DNDEBUG -D'VM_LABEL(foo)=0' # Define NDEBUG for production to exclude asserts +else ifeq ($(CONFIGURATION),assert) +DEBUGVM= 0 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +else +DEBUGVM= 1 +NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0' +endif + +ifeq ($(IS_PREPARING),false) + ifeq ($(THREADING),multi) + COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM) + else + COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM) + endif + ifdef BIT_IDENTICAL_FLOATING_POINT + COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1 + endif +endif # IS_PREPARING + +# Several versions of clang (all versions from 14 through 18 as of this writing) +# generate incorrect code for spur segment storage +# (return:restoringObjectsIn:savedFirstFields:and:savedHashes:) +# unless USE_INLINE_MEMORY_ACCESSORS is set. +MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1 + +# Multi-threaded environment. Might in case use multi-threading specific +# versions of API calls. Also used to avoid built-in functions. +MT_ENV?=-D_MT + +# Use fdlibm for floating-point, which is cross-platform, or +# platform-specific floating point. See COGDEFS. +BIT_IDENTICAL_FLOATING_POINT=1 + +DEFS:=-D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) $(WINBIT) \ + $(WINUNI) $(MT_ENV) -D'TZ="$(TZ)"' -DNO_ISNAN -DNO_SERVICE \ + $(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET) diff --git a/building/win64x64/common/Makefile.tools.flags b/building/win64x64/common/Makefile.tools.flags new file mode 100644 index 0000000000..06caad2bec --- /dev/null +++ b/building/win64x64/common/Makefile.tools.flags @@ -0,0 +1,78 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Compiler flags (incl. OFLAGS and DEFS) for LLVM/Clang +############################################################################# + +# Enable all but several warnings +WARNINGS:= -Wall -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label \ + -Wno-unused-value -Wno-unused-function -Wno-missing-variable-declarations \ + -Wno-unused-macros -Wno-sign-compare -Wno-sign-conversion -Wno-pedantic \ + -Wno-reserved-id-macro -Wno-undef + +############################################################################# +# OFLAGS (VM and Plugins) +# + +# Turn off BUFFER_SECURITY for functional setjmp/longjmp +BUFFER_SECURITY:=-fno-stack-protector -D_CRT_SECURE_NO_WARNINGS + +# For exception handing we require a frame pointer (e.g. for unwind). +# Clang supports both +# -fno-omit-frame-pointer +# -fno-omit-leaf-frame-pointer +# We assume that when when not omitting the frame pointer, Clang will still +# omit the leaf frame pointers, which is fine. +FRAME_POINTER_FLAGS:=-fno-omit-frame-pointer -DcFramePointerInUse=1 + +ifeq ($(CONFIGURATION),product) + # For fast/production builds, use -O2 optimization + OFLAGS= -O2 -finline-hint-functions -funroll-loops $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else ifeq ($(CONFIGURATION),assert) + # For assert builds, use -Os optimization, which is similar to -O2 + OFLAGS= -Os -fno-builtin $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +else + # For debug builds, minimize optimization, even has leaf-frame-pointers + OFLAGS= -O0 $(FRAME_POINTER_FLAGS) $(BUFFER_SECURITY) +endif + +# FYI +# -Ob enable inline expansion -Oy omit frame pointer, Oi enable intrinsics + + +############################################################################# +# CFLAGS +# +NOBUILTIN?=-fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf + +# Include extra debugging information. +DEBUG_LEVEL?=-g3 + +# Enable exceptions for debugging purposes. +EXCEPTION_FLAGS?=-fexceptions +CXX_EXCEPTION_FLAGS?=-fexceptions -fcxx-exceptions + +# No __STDCALL calling convention by default. Stick to __CDECL. +CALLING_CONVENTION?=-mno-rtd + +# Keep default structure layout compatible with Microsoft standards. +BITFIELD_LAYOUT?=-mms-bitfields + +# Allow __declspec keyword. +# See https://learn.microsoft.com/cpp/cpp/declspec +DECLSPEC?=-fdeclspec + +CFLAGS= $(DECLSPEC) -msse2 $(DEBUG_LEVEL) -m64 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + +CXXFLAGS= $(DECLSPEC) -msse2 $(DEBUG_LEVEL) -m64 $(OFLAGS) \ + $(CALLING_CONVENTION) $(BITFIELD_LAYOUT) \ + $(NOBUILTIN) $(CXX_EXCEPTION_FLAGS) \ + $(WARNINGS) $(XCFLAGS) + diff --git a/building/win64x64/common/Makefile.tools.print b/building/win64x64/common/Makefile.tools.print new file mode 100644 index 0000000000..1353544507 --- /dev/null +++ b/building/win64x64/common/Makefile.tools.print @@ -0,0 +1,24 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +# +# Rules for printing tool information, e.g., for debugging +############################################################################# + +.PHONY : print-tools + +print-tools: + $(info ---------------- Build tools ------------------------) + $(info CC $(shell which $(CC)) $(shell $(CC) --version 2> /dev/null | head -n 1)) + $(info LD $(shell which $(LD)) $(shell $(LD) --version 2> /dev/null | head -n 1)) + $(info CP $(shell which $(CP)) $(shell $(CP) --version 2> /dev/null | head -n 1)) + $(info RM $(shell which $(RM)) $(shell $(RM) --version 2> /dev/null | head -n 1)) + $(info AR $(shell command -v $(AR)) $(shell $(AR) --version 2> /dev/null | head -n 1)) + $(info NM $(shell which $(NM)) $(shell $(NM) --version 2> /dev/null | head -n 1)) + $(info DLLTOOL $(shell command -v $(DLLTOOL)) $(shell $(DLLTOOL) --version 2> /dev/null | head -n 1)) + $(info DLLWRAP $(shell command -v $(DLLWRAP)) $(shell $(DLLWRAP) --version 2> /dev/null | head -n 1)) + $(info RC $(shell which $(RC)) $(shell $(RC) --version 2> /dev/null | head -n 1)) + $(info -----------------------------------------------------) diff --git a/building/win64x64/common/SETPATH_MSYS2.BAT b/building/win64x64/common/SETPATH_MSYS2.BAT new file mode 100644 index 0000000000..4c51b469d4 --- /dev/null +++ b/building/win64x64/common/SETPATH_MSYS2.BAT @@ -0,0 +1,3 @@ +REM We recommend to run MAKE from a normal MSYS2 environment but it also works +REM from within a Native Tools Command Prompt (Visual Studio Community). +set PATH=%PATH%;c:\msys64\bin diff --git a/building/win64x64/squeak.cog.spur/Makefile b/building/win64x64/squeak.cog.spur/Makefile index 03976a1ba0..23869120cb 100644 --- a/building/win64x64/squeak.cog.spur/Makefile +++ b/building/win64x64/squeak.cog.spur/Makefile @@ -1,15 +1,22 @@ #################################################################################### -# Makefile for Win32 Cog Spur Squeak VM using either gcc and cygwin or MSVC and LLVM +# Makefile for Win64 Cog Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. #################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur64.cog -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW64 or CLANG64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64x64/squeak.cog.spur/plugins.ext b/building/win64x64/squeak.cog.spur/plugins.ext index f3989042b4..4e508e4021 100644 --- a/building/win64x64/squeak.cog.spur/plugins.ext +++ b/building/win64x64/squeak.cog.spur/plugins.ext @@ -12,3 +12,7 @@ DESPlugin \ MD5Plugin \ SHA2Plugin \ VectorEnginePlugin +#BochsX64Plugin \ +#BochsIA32Plugin \ +#GdbARMPlugin \ +#GdbARMv8Plugin \ No newline at end of file diff --git a/building/win64x64/squeak.sista.spur/Makefile b/building/win64x64/squeak.sista.spur/Makefile index ff59e3c19c..c92c85a643 100644 --- a/building/win64x64/squeak.sista.spur/Makefile +++ b/building/win64x64/squeak.sista.spur/Makefile @@ -1,17 +1,22 @@ ############################################################################# -# Makefile for Win32 Sista Spur Squeak VM using either gcc and cygwin or MSVC and LLVM +# Makefile for Win64 Sista Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. ############################################################################# VM:=Squeak VMSRCDIR:=../../../src/spur64.sista -COMPILER_TO_USE:=clang - -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW64 or CLANG64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/building/win64x64/squeak.stack.spur/Makefile b/building/win64x64/squeak.stack.spur/Makefile index b5bb9d5c90..cc3312d9c7 100644 --- a/building/win64x64/squeak.stack.spur/Makefile +++ b/building/win64x64/squeak.stack.spur/Makefile @@ -1,15 +1,22 @@ #################################################################################### -# Makefile for Win32 Stack Spur Squeak VM using either gcc and cygwin or MSVC and LLVM +# Makefile for Win32 Stack Spur Squeak VM using LLVM/Clang # Do make init to allow make -n to function. #################################################################################### VM:=Squeak VMSRCDIR:=../../../src/spur64.stack -# This variable is set by VS Native Tools Command Prompts, not for cygwin wins -VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +# This variable is set by VS Native Tools Command Prompts ifeq ($(VSCMD_ARG_HOST_ARCH),) -include ../common/Makefile + ifeq ($(MSYSTEM),MSYS) + # In a generic MSYS2 environment, compile against WinSDK + include ../common/Makefile.WinSDK + else + # In other envs (e.g. MINGW64 or CLANG64), compile against MinGW + include ../common/Makefile + endif else -include ../common/Makefile.msvc + # Legacy. All *.msvc.* makefiles should be removed at some point. + include ../common/Makefile.msvc +# include ../common/Makefile.WinSDK endif diff --git a/deploy/pack-vm.sh b/deploy/pack-vm.sh index de5a26388b..fe94e67dc0 100755 --- a/deploy/pack-vm.sh +++ b/deploy/pack-vm.sh @@ -40,7 +40,7 @@ pack_macOS() { pack_Windows() { readonly ASSET_EXTENSION="zip" cd "${APP_NAME}" - rm -f *.def *.exp *.lib *.map *.o *.res *Unstripped* *.ignore # remove temporary build files + rm -f *.def *.exp *.lib *.pdb *.map *.o *.res *Unstripped* *.ignore # remove temporary build files 7z a -tzip -r "${PRODUCTS_PATH}/${ASSET_NAME}.${ASSET_EXTENSION}" "./" } diff --git a/platforms/Cross/plugins/IA32ABI/ia32abicc.c b/platforms/Cross/plugins/IA32ABI/ia32abicc.c index 3a5497a380..b136c9255b 100644 --- a/platforms/Cross/plugins/IA32ABI/ia32abicc.c +++ b/platforms/Cross/plugins/IA32ABI/ia32abicc.c @@ -53,7 +53,7 @@ struct VirtualMachine* interpreterProxy; #ifdef _MSC_VER # define alloca _alloca #endif -#if __GNUC__ +#if __GNUC__ || __clang__ # define setsp(sp) __asm__ volatile ("movl %0,%%esp" : : "m"(sp)) # define getsp() ({ void *sp; __asm__ volatile ("movl %%esp,%0" : "=r"(sp) : ); sp;}) #endif @@ -165,9 +165,9 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp) { void *sp = getsp(); int offset = (unsigned long)sp & (STACK_ALIGN_BYTES - 1); if (offset) { -# if _MSC_VER +# if _MSC_VER && !__clang__ _asm sub esp, dword ptr offset; -# elif __GNUC__ +# elif __GNUC__ || __clang__ __asm__ ("sub %0,%%esp" : : "m"(offset)); # else # error need to subtract offset from esp @@ -205,9 +205,9 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp) case retword64: { long vhigh = vmcc.rvs.valleint64.high; -#if _MSC_VER +#if _MSC_VER && !__clang__ _asm mov edx, dword ptr vhigh; -#elif __GNUC__ || __SUNPRO_C +#elif __GNUC__ || __SUNPRO_C || __clang__ __asm__ ("mov %0,%%edx" : : "m"(vhigh)); #else # error need to load edx with vmcc.rvs.valleint64.high on this compiler @@ -217,9 +217,9 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp) case retdouble: { double valflt64 = vmcc.rvs.valflt64; -#if _MSC_VER +#if _MSC_VER && !__clang__ _asm fld qword ptr valflt64; -#elif __GNUC__ || __SUNPRO_C +#elif __GNUC__ || __SUNPRO_C || __clang__ __asm__ ("fldl %0" : : "m"(valflt64)); #else # error need to load %f0 with vmcc.rvs.valflt64 on this compiler diff --git a/platforms/Cross/plugins/IA32ABI/ppc32abicc.c b/platforms/Cross/plugins/IA32ABI/ppc32abicc.c index a1b68374f0..d9dca0b1d1 100644 --- a/platforms/Cross/plugins/IA32ABI/ppc32abicc.c +++ b/platforms/Cross/plugins/IA32ABI/ppc32abicc.c @@ -219,7 +219,7 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp) case retint64: { long vhigh = rs->rvs.valint64.high; -#if _MSC_VER +#if _MSC_VER && !__clang__ _asm mov edx, dword ptr vhigh; #elif __GNUC__ #warning ASSEMBLER @@ -232,7 +232,7 @@ thunkEntry(void *thunkp, sqIntptr_t *stackp) case retdouble: { double valflt64 = rs->rvs.valflt64; -#if _MSC_VER +#if _MSC_VER && !__clang__ _asm fld qword ptr valflt64; #elif __GNUC__ #warning ASSEMBLER diff --git a/platforms/Cross/plugins/IA32ABI/x64sysvabicc.c b/platforms/Cross/plugins/IA32ABI/x64sysvabicc.c index 1e73d73baf..e6b0c08529 100644 --- a/platforms/Cross/plugins/IA32ABI/x64sysvabicc.c +++ b/platforms/Cross/plugins/IA32ABI/x64sysvabicc.c @@ -205,7 +205,7 @@ thunkEntry(long a0, long a1, long a2, long a3, long a4, long a5, case retdouble: { double valflt64 = vmcc.rvs.valflt64; -#if _MSC_VER +#if _MSC_VER && !__clang__ _asm mov qword ptr valflt64, xmm0; #elif __GNUC__ || __SUNPRO_C __asm__("movq %0, %%xmm0" : : "m"(valflt64)); diff --git a/platforms/Cross/plugins/IA32ABI/x64win64abicc.c b/platforms/Cross/plugins/IA32ABI/x64win64abicc.c index 53a20daca2..a8bbac5384 100644 --- a/platforms/Cross/plugins/IA32ABI/x64win64abicc.c +++ b/platforms/Cross/plugins/IA32ABI/x64win64abicc.c @@ -40,7 +40,7 @@ struct VirtualMachine* interpreterProxy; #ifdef _MSC_VER # define alloca _alloca #endif -#if __GNUC__ +#if __GNUC__ || __clang__ # define setsp(sp) __asm__ volatile ("movq %0,%%rsp" : : "m"(sp)) # define getsp() ({ void *sp; __asm__ volatile ("movq %%rsp,%0" : "=r"(sp) : ); sp;}) #endif diff --git a/platforms/Cross/third-party/fdlibm/Makefile.remote b/platforms/Cross/third-party/fdlibm/Makefile.remote index b389b6aa2e..0eb6356a2d 100644 --- a/platforms/Cross/third-party/fdlibm/Makefile.remote +++ b/platforms/Cross/third-party/fdlibm/Makefile.remote @@ -4,3 +4,7 @@ TP:=../../platforms/Cross/third-party FDLIBM:=fdlibm VPATH=$(TP)/$(FDLIBM):. include $(TP)/$(FDLIBM)/Makefile + +# Extra rule for Windows builds using Microsoft VS build tools (i.e., "LIB") +libm.lib : $(obj) + $(LIBRARIAN) $(obj) -out:libm.lib diff --git a/platforms/Cross/vm/sqAtomicOps.h b/platforms/Cross/vm/sqAtomicOps.h index 7388053c64..2fba38e588 100644 --- a/platforms/Cross/vm/sqAtomicOps.h +++ b/platforms/Cross/vm/sqAtomicOps.h @@ -106,7 +106,7 @@ AtomicGet(uint64_t *target) # define set64(variable,value) AtomicSet(&(variable),value) /* Currently we provide definitions for x86 and GCC only. But see below. */ -# elif (defined(__GNUC__) || defined(__SUNPRO_C)) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(_X86_)) +# elif (defined(__GNUC__) || defined(__SUNPRO_C) || defined(__clang__)) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(_X86_)) /* atomic read & write of 64-bit values using SSE2 movq to/from sse register. * 64-bit reads & writes are only guaranteed to be atomic if aligned on a 64-bit @@ -169,7 +169,7 @@ AtomicGet(uint64_t *target) : "memory", "eax", "ebx", "ecx", "edx", "cc") # endif /* __SSE2__ */ -# elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_) || defined(i386)) +# elif (defined(_MSC_VER) && !defined(__clang__)) && (defined(_M_IX86) || defined(_X86_) || defined(i386)) # pragma message(" TODO: verify thoroughly") /* see http://web.archive.org/web/20120411073941/http://www.niallryan.com/node/137 */ @@ -203,13 +203,13 @@ AtomicGet(__int64 *target) # else /* TARGET_OS_IS_IPHONE elif x86 variants etc */ -#if defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__)) +# if defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__)) /* tpr - this is code intended for the Raspberry Pi Raspbian OS * We'll experimentally trust in our MMU to keep 64bit accesses atomic */ # define get64(variable) variable # define set64(variable,value) (variable = value) -#else +# else /* Dear implementor, you have choices. For example consider defining get64 & * set64 thusly @@ -218,12 +218,12 @@ AtomicGet(__int64 *target) * and get the JIT to generate read64 & write64 above atomic 64-bit read/write. */ # error atomic access of 64-bit variables not yet defined for this platform -#endif -# endif +# endif +# endif /* TARGET_OS_IS_IPHONE */ #else /* neither IS_64_BIT_ARCH nor IS_32_BIT_ARCH */ # error Could not infer if architecture is 32 or 64 bits. Please modify sqAtomicOps.h inference rules. -#endif +#endif /* IS_64_BIT_ARCH */ #if defined(__GNUC__) # define GCC_HAS_BUILTIN_SYNC \ diff --git a/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..8d62a12f11 --- /dev/null +++ b/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,12 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +EXTRALIBS:=opengl32.lib ddraw.lib dxguid.lib gdi32.lib user32.lib + +include ../common/Makefile.WinSDK.plugin diff --git a/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.plugin b/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.plugin index 15d301fce8..894c970b83 100644 --- a/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.plugin +++ b/platforms/win32/plugins/B3DAcceleratorPlugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + EXTRALIBS:=-lopengl32 -lddraw -ldxguid -lgdi32 -lOle32 include ../common/Makefile.plugin diff --git a/platforms/win32/plugins/BitBltPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/BitBltPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..4776764a2d --- /dev/null +++ b/platforms/win32/plugins/BitBltPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,19 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# Override to avoid files in platforms/Cross/plugins/BitBltPlugin. +# Fails if one redefines VPATH and then includes ../common/Makefile.WinSDK.plugin. Grrr... + +WIN32DIR:= $(PLATDIR)/win32/plugins/$(LIBNAME) +MAKERDIR:= $(PLUGINSRCDIR)/plugins/$(LIBNAME) +OBJDIR:= $(BASEDIR)/$(BUILD)/$(LIBNAME) + +%: + $(MAKE) -f ../common/Makefile.WinSDK.plugin VPATH="$(MAKERDIR) $(WIN32DIR) $(OBJDIR)" \ + CROSSSRC="" $@ diff --git a/platforms/win32/plugins/BitBltPlugin/Makefile.plugin b/platforms/win32/plugins/BitBltPlugin/Makefile.plugin index a525ce83b1..d2079cf396 100644 --- a/platforms/win32/plugins/BitBltPlugin/Makefile.plugin +++ b/platforms/win32/plugins/BitBltPlugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + # Override to avoid files in platforms/Cross/plugins/BitBltPlugin. # Fails if one redefines VPATH and then includes ../common/Makefile.plugin. Grrr... diff --git a/platforms/win32/plugins/BochsIA32Plugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/BochsIA32Plugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..879e2ac4ac --- /dev/null +++ b/platforms/win32/plugins/BochsIA32Plugin/Makefile.WinSDK.plugin @@ -0,0 +1,26 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +BOX:=../bochsx86 +PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a + +DLLTOOLEXTRA := $(BOX)/cpu/libcpu.a \ + $(BOX)/fpu/libfpu.a \ + $(BOX)/disasm/libdisasm.a +DLLWRAPEXTRA := $(DLLTOOLEXTRA) + +# LINK_WITH_GPP := yes --- Unsupported. See Makefile.WinSDK.plugin +EXTRALIBS:= /LIBPATH:$(BOX)/cpu /LIBPATH:$(BOX)/fpu /LIBPATH:$(BOX)/disasm \ + libcpu.a libfpu.a libdisasm.a + +include ../common/Makefile.WinSDK.plugin + +INCLUDES+=-I$(BOX) \ + -I../../../processors/IA32/bochs \ + -I../../../processors/IA32/bochs/instrument/stubs diff --git a/platforms/win32/plugins/BochsIA32Plugin/Makefile.plugin b/platforms/win32/plugins/BochsIA32Plugin/Makefile.plugin index e6d6a79b0e..2175db3749 100644 --- a/platforms/win32/plugins/BochsIA32Plugin/Makefile.plugin +++ b/platforms/win32/plugins/BochsIA32Plugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + BOX:=../bochsx86 PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a diff --git a/platforms/win32/plugins/BochsX64Plugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/BochsX64Plugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..79622b259c --- /dev/null +++ b/platforms/win32/plugins/BochsX64Plugin/Makefile.WinSDK.plugin @@ -0,0 +1,26 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +BOX:=../bochsx64 +PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a + +DLLTOOLEXTRA := $(BOX)/cpu/libcpu.a \ + $(BOX)/fpu/libfpu.a \ + $(BOX)/disasm/libdisasm.a +DLLWRAPEXTRA := $(DLLTOOLEXTRA) + +# LINK_WITH_GPP := yes --- Unsupported. See Makefile.WinSDK.plugin +EXTRALIBS:= /LIBPATH:$(BOX)/cpu /LIBPATH:$(BOX)/fpu /LIBPATH:$(BOX)/disasm \ + libcpu.a libfpu.a libdisasm.a + +include ../common/Makefile.WinSDK.plugin + +INCLUDES+=-I$(BOX) \ + -I../../../processors/IA32/bochs \ + -I../../../processors/IA32/bochs/instrument/stubs diff --git a/platforms/win32/plugins/BochsX64Plugin/Makefile.plugin b/platforms/win32/plugins/BochsX64Plugin/Makefile.plugin index ff788baee5..9e45d2d5d3 100644 --- a/platforms/win32/plugins/BochsX64Plugin/Makefile.plugin +++ b/platforms/win32/plugins/BochsX64Plugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + BOX:=../bochsx64 PREREQUISITES:=$(BOX)/cpu/libcpu.a $(BOX)/disasm/libdisasm.a $(BOX)/fpu/libfpu.a diff --git a/platforms/win32/plugins/CameraPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/CameraPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..345788ffad --- /dev/null +++ b/platforms/win32/plugins/CameraPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,18 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# CameraPlugin build assumes it's external. +# Further it must be built using the MSVC++ toolchain because of lack of COM +# support in the mingw toolchain. + +EXTRALIBS:=strmbase.lib strmiids.lib + +include ../common/Makefile.WinSDK.plugin + +INCLUDES:=-I$(WIN32MISCDIR) $(INCLUDES) diff --git a/platforms/win32/plugins/CameraPlugin/Makefile.plugin b/platforms/win32/plugins/CameraPlugin/Makefile.plugin index fbf221f268..e03e774ff1 100644 --- a/platforms/win32/plugins/CameraPlugin/Makefile.plugin +++ b/platforms/win32/plugins/CameraPlugin/Makefile.plugin @@ -1,11 +1,20 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + # CameraPlugin build assumes it's external. # Further it must be built using the MSVC++ toolchain because of lack of COM # support in the mingw toolchain. Hence this Makefile.plugin exists only to -# exclude CameraPlugin on the cygwin/mingw build (sadly). +# exclude CameraPlugin on the mingw-w64 build (sadly). EXTRALIBS:=strmbase.lib strmiids.lib -PREREQUISITES:=$(WIN32MISCDIR)/atlbase.h # no atlbase.h for cygwin +PREREQUISITES:=$(WIN32MISCDIR)/atlbase.h # no atlbase.h for mingw-w64 include ../common/Makefile.plugin diff --git a/platforms/win32/plugins/ClipboardExtendedPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/ClipboardExtendedPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..7a54cac5a7 --- /dev/null +++ b/platforms/win32/plugins/ClipboardExtendedPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,12 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +EXTRALIBS:=gdi32.lib + +include ../common/Makefile.WinSDK.plugin diff --git a/platforms/win32/plugins/FT2Plugin/Makefile.plugin b/platforms/win32/plugins/FT2Plugin/Makefile.plugin index 16085de828..b4af560beb 100644 --- a/platforms/win32/plugins/FT2Plugin/Makefile.plugin +++ b/platforms/win32/plugins/FT2Plugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + include ../common/Makefile.plugin ifeq ($(THIRDPARTYOUTDIR),) diff --git a/platforms/win32/plugins/FileAttributesPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/FileAttributesPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..947475c610 --- /dev/null +++ b/platforms/win32/plugins/FileAttributesPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,18 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# +# FileAttributesPlugin uses sqWin32File.h, provided by FilePlugin +# +# Add $(WIN32PLUGINSDIR)/FilePlugin to the include path so sqWin32File.h +# will be found +# +include ../common/Makefile.WinSDK.plugin + +INCLUDES += -I$(PLATDIR)/win32/plugins/FilePlugin -I$(SdkDir)/ucrt diff --git a/platforms/win32/plugins/FileAttributesPlugin/Makefile.plugin b/platforms/win32/plugins/FileAttributesPlugin/Makefile.plugin index c328e310b6..4743460fae 100644 --- a/platforms/win32/plugins/FileAttributesPlugin/Makefile.plugin +++ b/platforms/win32/plugins/FileAttributesPlugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + # # FileAttributesPlugin uses sqWin32File.h, provided by FilePlugin # diff --git a/platforms/win32/plugins/FloatMathPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/FloatMathPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..155197144b --- /dev/null +++ b/platforms/win32/plugins/FloatMathPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,13 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +include ../common/Makefile.WinSDK.plugin + +# There is need to disable optimization when using recent clang. +# OFLAGS= -O0 diff --git a/platforms/win32/plugins/FloatMathPlugin/Makefile.plugin b/platforms/win32/plugins/FloatMathPlugin/Makefile.plugin index 07b635755b..d4fc5cbea7 100644 --- a/platforms/win32/plugins/FloatMathPlugin/Makefile.plugin +++ b/platforms/win32/plugins/FloatMathPlugin/Makefile.plugin @@ -1,11 +1,23 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + include ../common/Makefile.plugin # Special OFLAGS for some files -k_tan.o: k_tan.c - $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o +# k_tan.o: k_tan.c +# $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o + +# acos.o: acos.c +# $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o -acos.o: acos.c - $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o +# tanh.o: tanh.c +# $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o -tanh.o: tanh.c - $(MAKE) -f ../common/Makefile.plugin OFLAGS="-O0" $*.o +# There is need to disable optimization when using recent clang. +# OFLAGS= -O0 diff --git a/platforms/win32/plugins/FloatMathPlugin/Makefile.win32 b/platforms/win32/plugins/FloatMathPlugin/Makefile.win32 deleted file mode 100644 index a8d86ae9e1..0000000000 --- a/platforms/win32/plugins/FloatMathPlugin/Makefile.win32 +++ /dev/null @@ -1,11 +0,0 @@ -include ../../Makefile.mingw32 - -# Special OFLAGS for some files -k_tan.o: k_tan.c - $(MAKE) -f ../../Makefile.mingw32 OFLAGS="-O0" $*.o - -acos.o: acos.c - $(MAKE) -f ../../Makefile.mingw32 OFLAGS="-O0" $*.o - -tanh.o: tanh.c - $(MAKE) -f ../../Makefile.mingw32 OFLAGS="-O0" $*.o diff --git a/platforms/win32/plugins/GdbARMv8Plugin/Makefile.plugin b/platforms/win32/plugins/GdbARMv8Plugin/Makefile.plugin index cedac097a0..c301f58f9d 100644 --- a/platforms/win32/plugins/GdbARMv8Plugin/Makefile.plugin +++ b/platforms/win32/plugins/GdbARMv8Plugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + BOX:=../gdbarm64 GDB=../../../processors/ARM/gdb-8.3.1 diff --git a/platforms/win32/plugins/IA32ABI/Makefile.WinSDK.plugin b/platforms/win32/plugins/IA32ABI/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..cf40c710a9 --- /dev/null +++ b/platforms/win32/plugins/IA32ABI/Makefile.WinSDK.plugin @@ -0,0 +1,16 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +ifeq ($(ARCH),x64) +LIBSRC:=xabicc.c IA32ABI.c x64win64stub.c +else +LIBSRC:=xabicc.c IA32ABI.c +endif + +include ../common/Makefile.WinSDK.plugin diff --git a/platforms/win32/plugins/IA32ABI/Makefile.plugin b/platforms/win32/plugins/IA32ABI/Makefile.plugin index 835592b780..4cbe33b34e 100644 --- a/platforms/win32/plugins/IA32ABI/Makefile.plugin +++ b/platforms/win32/plugins/IA32ABI/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + ifeq ($(ARCH),x64) LIBOBJ:= xabicc.o IA32ABI.o x64win64stub.o else diff --git a/platforms/win32/plugins/Mpeg3Plugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/Mpeg3Plugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..fab617af65 --- /dev/null +++ b/platforms/win32/plugins/Mpeg3Plugin/Makefile.WinSDK.plugin @@ -0,0 +1,41 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +include ../common/Makefile.WinSDK.plugin + +# additional CFLAGS +CFLAGS += -DNOPTHREADS + +# additional directories and files +MP3DIR= $(CROSSDIR)/libmpeg +MP3SRC:= $(notdir $(wildcard $(MP3DIR)/*.c)) +MP3SRC:= $(filter-out dump.c dump2.c mpeg3toc.c mpeg3cat.c testaudio.c udump.c test.c, $(MP3SRC)) +MP3OBJ= $(MP3SRC:.c=.o) + +AUDDIR= $(MP3DIR)/audio +AUDSRC:= $(notdir $(wildcard $(AUDDIR)/*.c)) +AUDOBJ= $(AUDSRC:.c=.o) + +VIDDIR= $(MP3DIR)/video +VIDSRC:= $(notdir $(wildcard $(VIDDIR)/*.c)) +VIDSRC:= $(filter-out worksheet.c, $(VIDSRC)) +VIDOBJ= $(VIDSRC:.c=.o) + +# add the libmpeg files +LIBSRC += $(MP3SRC) $(AUDSRC) $(VIDSRC) +LIBSRC= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC) $(MP3SRC) $(AUDSRC) $(VIDSRC)) +MP3LIBOBJ := $(addprefix $(OBJDIR)/, $(MP3OBJ) $(AUDOBJ) $(VIDOBJ)) +LIBOBJ+=$(MP3LIBOBJ) + +# Restate the dependency. Don't ask me why, but it appears necessary :/ +$(PLUGINLIB): $(LIBOBJ) + +# add the directories +VPATH += $(MP3DIR) $(VIDDIR) $(AUDDIR) +INCLUDES += -I$(MP3DIR) -I$(VIDDIR) -I$(AUDDIR) diff --git a/platforms/win32/plugins/Mpeg3Plugin/Makefile.plugin b/platforms/win32/plugins/Mpeg3Plugin/Makefile.plugin index 183c3a3f81..254edd07f4 100644 --- a/platforms/win32/plugins/Mpeg3Plugin/Makefile.plugin +++ b/platforms/win32/plugins/Mpeg3Plugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + include ../common/Makefile.plugin # additional CFLAGS diff --git a/platforms/win32/plugins/Mpeg3Plugin/Makefile.win32 b/platforms/win32/plugins/Mpeg3Plugin/Makefile.win32 deleted file mode 100644 index 7c1ca76cd0..0000000000 --- a/platforms/win32/plugins/Mpeg3Plugin/Makefile.win32 +++ /dev/null @@ -1,58 +0,0 @@ -CFLAGS = -O2 -funroll-loops -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DX86 -CC = gcc - -RM = rm -DLLTOOL = dlltool -DLLWRAP = dllwrap - -CFLAGS += -DNOPTHREADS -CFLAGS += $(INCS) -CFLAGS += $(XDEFS) - -MP3DIR= libmpeg -MP3SRC= $(notdir $(wildcard $(MP3DIR)/*.c)) -MP3SRC:= $(filter-out dump.c dump2.c mpeg3toc.c mpeg3cat.c testaudio.c udump.c test.c, $(MP3SRC)) -MP3OBJ:= $(MP3SRC:.c=.o) - -AUDDIR= $(MP3DIR)/audio -AUDSRC= $(notdir $(wildcard $(AUDDIR)/*.c)) -AUDOBJ:= $(AUDSRC:.c=.o) - -VIDDIR= $(MP3DIR)/video -VIDSRC= $(notdir $(wildcard $(VIDDIR)/*.c)) -VIDSRC:= $(filter-out worksheet.c, $(VIDSRC)) -VIDOBJ:= $(VIDSRC:.c=.o) - -PLGDIR= . -PLGSRC= $(notdir $(wildcard $(PLGDIR)/*.c)) -PLGOBJ:= $(PLGSRC:.c=.o) - -VPATH= $(PLGDIR) $(MP3DIR) $(VIDDIR) $(AUDDIR) -INCS= -I$(MP3DIR) -I$(VIDDIR) -I$(AUDDIR) -I../../vm - -LIB = Mpeg3Plugin -LIBOBJ= $(PLGOBJ) $(MP3OBJ) $(AUDOBJ) $(VIDOBJ) -OBJDIR= . - -makelib: $(LIBOBJ) - -$(RM) $(LIB).lib - ar rc $(LIB).lib $(LIBOBJ) - $(RM) $(LIBOBJ) - -makedll: $(LIBOBJ) - $(DLLTOOL) \ - --output-def $(OBJDIR)/$(LIB).def \ - --output-exp $(OBJDIR)/$(LIB).exp \ - --output-lib $(OBJDIR)/$(LIB).lib \ - $(LIBOBJ) - $(DLLWRAP) -mwindows \ - -def $(OBJDIR)/$(LIB).def \ - -o $(OBJDIR)/$(LIB).dll \ - $(LIBS) \ - $(OBJDIR)/$(LIB).exp \ - $(LIBOBJ) - strip --strip-all $(OBJDIR)/$(LIB).dll - -$(RM) $(LIBOBJ) $(LIB).lib $(LIB).exp $(LIB).def - -.c.o: - $(CC) -c $(CFLAGS) $< diff --git a/platforms/win32/plugins/SerialPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/SerialPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..bffcb45c54 --- /dev/null +++ b/platforms/win32/plugins/SerialPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,12 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +EXCLUDESRC:=sqNullSerialPort.c + +include ../common/Makefile.WinSDK.plugin diff --git a/platforms/win32/plugins/SerialPlugin/Makefile.plugin b/platforms/win32/plugins/SerialPlugin/Makefile.plugin index 6fdb491ef2..f8a42d8a49 100644 --- a/platforms/win32/plugins/SerialPlugin/Makefile.plugin +++ b/platforms/win32/plugins/SerialPlugin/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + LIBOBJ:= SerialPlugin.o sqWin32SerialPort.o include ../common/Makefile.plugin diff --git a/platforms/win32/plugins/SqueakFFIPrims/Makefile.WinSDK.plugin b/platforms/win32/plugins/SqueakFFIPrims/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..4bb6692987 --- /dev/null +++ b/platforms/win32/plugins/SqueakFFIPrims/Makefile.WinSDK.plugin @@ -0,0 +1,16 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +# Platform ABI is selected in SqueakFFIPrims.c +LIBSRC:=SqueakFFIPrims.c sqFFIPlugin.c sqFFITestFuncs.c sqManualSurface.c + +include ../common/Makefile.WinSDK.plugin + +# On Cog we use the ThreadedFFIPlugin and need no platform-dependent code. +VPATH:= $(MAKERDIR) $(CROSSDIR) $(OBJDIR) diff --git a/platforms/win32/plugins/SqueakFFIPrims/Makefile.plugin b/platforms/win32/plugins/SqueakFFIPrims/Makefile.plugin index 1484113087..d880dc5d15 100644 --- a/platforms/win32/plugins/SqueakFFIPrims/Makefile.plugin +++ b/platforms/win32/plugins/SqueakFFIPrims/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + # On Cog we use the ThreadedFFIPlugin and need no platform-dependent code ifdef COGDEFS CROSSDIR:= $(PLATDIR)/Cross/plugins/$(LIBNAME) diff --git a/platforms/win32/plugins/SqueakSSL/Makefile.WinSDK.plugin b/platforms/win32/plugins/SqueakSSL/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..4e3464eff0 --- /dev/null +++ b/platforms/win32/plugins/SqueakSSL/Makefile.WinSDK.plugin @@ -0,0 +1,13 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# +# Makefile for SqueakSSL plugin. + +EXTRALIBS:=crypt32.lib secur32.lib + +include ../common/Makefile.WinSDK.plugin diff --git a/platforms/win32/plugins/SqueakSSL/Makefile.plugin b/platforms/win32/plugins/SqueakSSL/Makefile.plugin index df23825489..ad3eb83b52 100644 --- a/platforms/win32/plugins/SqueakSSL/Makefile.plugin +++ b/platforms/win32/plugins/SqueakSSL/Makefile.plugin @@ -1,3 +1,12 @@ +############################################################################# +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + # Makefile for SqueakSSL plugin. This should work given the right versions of # things. Alas my current MINGW installation, 3.17, doesn't have an up-to-date # /usr/lib/w32api/libcrypt32.a; it defines 14 funcs needed by sqWin32SSL.c but diff --git a/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.WinSDK.plugin b/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.WinSDK.plugin new file mode 100644 index 0000000000..9f321f7f4b --- /dev/null +++ b/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.WinSDK.plugin @@ -0,0 +1,13 @@ +############################################################################# +# Plugin Makefile for Win64 VM using LLVM/Clang compiler, MSVC build tools, +# GNU make/sed/grep, and the Windows 10 SDK. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + +include ../common/Makefile.WinSDK.plugin + +INCLUDES += -I$(PLATDIR)/Cross/plugins/FilePlugin \ + -I$(PLATDIR)/Cross/plugins/SocketPlugin diff --git a/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.plugin b/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.plugin index bd1f0bef28..9791757d6d 100644 --- a/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.plugin +++ b/platforms/win32/plugins/Win32OSProcessPlugin/Makefile.plugin @@ -1,3 +1,12 @@ +########################################################################################################################################################## +# Common Makefile for Win64 VM using LLVM/Clang compiler, MSYS2 toolchain, +# and mingw-w64 for building a native Windows application. +# +# Copyright (c) Andreas Raab, Eliot Miranda, Marcel Taeumel, et al. +# Copyright (c) 2020 3D Immersive Collaboration Consulting, LLC +# Copyright (c) 2025 Hasso Plattner Institute, University of Potsdam, Germany +############################################################################# + include ../common/Makefile.plugin INCLUDES += -I$(PLATDIR)/Cross/plugins/FilePlugin \ -I$(PLATDIR)/Cross/plugins/SocketPlugin diff --git a/platforms/win32/vm/sqWin32Backtrace.c b/platforms/win32/vm/sqWin32Backtrace.c index c63f7334ba..c54356cff2 100644 --- a/platforms/win32/vm/sqWin32Backtrace.c +++ b/platforms/win32/vm/sqWin32Backtrace.c @@ -70,19 +70,26 @@ backtrace(void **retpcs, int nrpcs) __fp = (void **)((usqInt)_AddressOfReturnAddress() - sizeof(void *)); #elif defined(_M_IX86) || defined(_M_I386) || defined(_X86_) || defined(i386) || defined(__i386__) -# if defined(__GNUC__) +# if defined(__GNUC__) || defined(__clang__) asm volatile ("movl %%ebp, %0" : "=r"(__fp) : ); # else # error "don't know how to derive ebp with this compiler" # endif #elif defined(__amd64__) || defined(__amd64) || defined(x86_64) || defined(__x86_64__) || defined(__x86_64) || defined(x64) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) -# if defined(__GNUC__) +# if defined(__GNUC__) || defined(__clang__) asm volatile ("movq %%rbp, %0" : "=r"(__fp) : ); # else # error "don't know how to derive rbp with this compiler" # endif +#elif defined(__arm64__) || defined(__aarch64__) || defined(ARM64) || defined(_M_ARM64) || defined(_M_ARM64) +# if defined(__GNUC__) || defined(__clang__) +# error "ARMv8 support for MinGW-w64 not yet implemented. Use WinSDK toolchain." +# else +# error "don't know how to derive rbp with this compiler" +# endif + #else # error "unknown architecture, cannot pick frame pointer" #endif diff --git a/scripts/ci/actions_build.sh b/scripts/ci/actions_build.sh index 19be628197..49f5d866f3 100755 --- a/scripts/ci/actions_build.sh +++ b/scripts/ci/actions_build.sh @@ -21,11 +21,6 @@ set -e # - APP_NAME (e.g., "vm" or "sqcogspur64linuxht" or "Squeak.app") - -if [[ "${RUNNER_OS}" == "Windows" ]]; then - source ./scripts/ci/actions_prepare_msys.sh -fi - echo "$(cat platforms/Cross/vm/sqSCCSVersion.h | .git_filters/RevDateURL.smudge)" > platforms/Cross/vm/sqSCCSVersion.h echo "$(cat platforms/Cross/plugins/sqPluginsSCCSVersion.h | .git_filters/RevDateURL.smudge)" > platforms/Cross/plugins/sqPluginsSCCSVersion.h @@ -133,11 +128,11 @@ build_Windows() { echo "::group::Building ${BUILD_PATH}..." skip_BochsPlugins if [[ "${MODE}" == "debug" ]]; then - bash -e ./mvm -d || exit 1 + bash -e ./mvm -d -- TOOLPREFIX='' || exit 1 elif [[ "${MODE}" == "assert" ]]; then - bash -e ./mvm -a || exit 1 + bash -e ./mvm -a -- TOOLPREFIX='' || exit 1 else - bash -e ./mvm -f || exit 1 + bash -e ./mvm -f -- TOOLPREFIX='' || exit 1 fi echo "::endgroup::" diff --git a/scripts/ci/actions_prepare_msys.sh b/scripts/ci/actions_prepare_msys.sh deleted file mode 100755 index ef0093c974..0000000000 --- a/scripts/ci/actions_prepare_msys.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Prepare MSYS environment so that all build tools have the $(TOOLPREFIX) as -# expected in Makefile.tools: -# - win64x64\common\Makefile.tools -# - win32x86\common\Makefile.tools -# Also, extend $PATH since MSYS is installed but not conveniently accessible -# Extend $PATH since MSYS is installed but not conveniently accessible -# in a GitHub-Actions Windows environment. - -[[ -z "${MSYS_SYS}" ]] && exit 2 -[[ -z "${MSYS_ENV}" ]] && exit 2 - -if [ -z "${MSYS_PATH}" ]; then MSYS_PATH="/c/msys64"; fi - -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/clang ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-clang -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/clang++ ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-clang++ -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/ar ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-ar -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/dlltool ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-dlltool -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/as ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-as -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/windres ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-windres -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/nm ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-nm -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/ld ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-ld -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/strip ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-strip -ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/objcopy ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-objcopy - -# We now use "gcc -shared" od "ld -shared" instead of "dllwrap". See Makefile.tools. -#ln -f -s ${MSYS_PATH}/${MSYS_SYS}/bin/dllwrap ${MSYS_PATH}/${MSYS_SYS}/bin/${MSYS_ENV}-w64-mingw32-dllwrap - -# Add MinGW tools for build scripts -PATH=$PATH:${MSYS_PATH}/${MSYS_SYS}/bin - -# Add other GNU tools (e.g., wget) for third-party build scripts -PATH=$PATH:${MSYS_PATH}/usr/bin diff --git a/scripts/installMSYS2-packages.sh b/scripts/installMSYS2-packages.sh new file mode 100755 index 0000000000..aba9657911 --- /dev/null +++ b/scripts/installMSYS2-packages.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +# ---------------------------------------------------------------------------- +# Download, install, and update MSYS2 packages (e.g. compilers, linkers) +# ---------------------------------------------------------------------------- + +# Common GNU dev tools (e.g., git, sed, grep) +PACKAGES="git base" + +if [[ "${MSYSTEM}" == "MSYS" ]]; then + # We require make, because we do not use NMAKE from the MSVC toolchain. + PACKAGES="${PACKAGES} make" +else + # The toolchain groups include compiler, linker, DLL wrappers, etc. + PACKAGES="${PACKAGES} ${MINGW_PACKAGE_PREFIX}-toolchain" + + # Apparently, the toolchains only install mingw32-make. So, either + # create a symlink or install the make package. + PACKAGES="${PACKAGES} make" + + if [[ "${MSYSTEM}" == "MINGW32" ]] || [[ "${MSYSTEM}" == "MINGW64" ]]; then + # The architecture is GCC-based. Install Clang. + PACKAGES="${PACKAGES} \ + ${MINGW_PACKAGE_PREFIX}-clang \ + ${MINGW_PACKAGE_PREFIX}-clang-libs \ + ${MINGW_PACKAGE_PREFIX}-clang-tools-extra \ + ${MINGW_PACKAGE_PREFIX}-clang-analyzer" + elif [[ "${MSYSTEM}" == "CLANG64" ]] || [[ "${MSYSTEM}" == "CLANGARM64" ]]; then + # LLVM/Clang is already installed via *-toolchain group + PACKAGES="${PACKAGES}" + else + echo "Unsupported MSYS2 environment ${MSYSTEM}." + exit 99 + fi +fi + +# Upgrade the system, then install the packages. See above. +pacman -Suqy --noconfirm +pacman -Sq --noconfirm ${PACKAGES} diff --git a/scripts/installMSYS2.cmd b/scripts/installMSYS2.cmd new file mode 100644 index 0000000000..3026005cb9 --- /dev/null +++ b/scripts/installMSYS2.cmd @@ -0,0 +1,79 @@ +@echo off + +SET MSYS_ARCH=%1 +IF "%MSYS_ARCH%"=="" (SET MSYS_ARCH=x86_64) + +IF "%MSYS_ARCH%"=="/?" ( + +echo This script installs and updates an MSYS2 build environment. Requires +echo Windows 10 or later. +echo +echo installMSYS2.bat [MSYS_ARCH] [MSYS_PATH] +echo +echo --------------------------------------------------------------------------- +echo Choose target architecture MSYS_ARCH: +echo - base ... MSYS2 GNU dev tools only, see installWinSDK.bat +echo - i686 ... mingw-w64, native 32-bit Windows, Intel/AMD +echo - x86_64 ... mingw-w64, native 64-bit Windows, Intel/AMD +echo - clang-x86_64 ... mingw-w64, native 64-bit Windows, Intel/AMD +echo - clang-aarch64 ... mingw-w64, native 64-bit Windows, ARMv8 +echo +echo Also see documentation here: +echo - https://www.msys2.org/docs/what-is-msys2/ +echo - https://www.mingw-w64.org +echo - https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ +echo - https://packages.msys2.org/base/base-devel +echo - https://packages.msys2.org/groups/mingw-w64-clang-x86_64-toolchain +echo - https://packages.msys2.org/groups/mingw-w64-clang-aarch64-toolchain +echo --------------------------------------------------------------------------- + +) + +REM Check that the value is a valid architecture +IF NOT "%MSYS_ARCH%"=="base" ( +IF NOT "%MSYS_ARCH%"=="i686" ( +IF NOT "%MSYS_ARCH%"=="x86_64" ( +IF NOT "%MSYS_ARCH%"=="clang-x86_64" ( +IF NOT "%MSYS_ARCH%"=="clang-aarch64" ( + echo ERROR: Unkown architecture: %MSYS_ARCH% && exit /b ))))) + +IF "%MSYS_ARCH%"=="base" (SET MSYS_ENV=msys) +IF "%MSYS_ARCH%"=="i686" (SET MSYS_ENV=mingw32) +IF "%MSYS_ARCH%"=="x86_64" (SET MSYS_ENV=mingw64) +IF "%MSYS_ARCH%"=="clang-x86_64" (SET MSYS_ENV=clang64) +IF "%MSYS_ARCH%"=="clang-aarch64" (SET MSYS_ENV=clangarm64) + +echo MSYS2 environment ... %MSYS_ENV% +echo MSYS2 architecture ... %MSYS_ARCH% + +REM ---------------------------------------------------------------------------- +REM Download, install, and update MSYS2 environment (i.e., no compilers) +REM ---------------------------------------------------------------------------- + +REM By default, MSYS2 will be installed into C:\msys64 but the first parameter +REM can change this to a different location. However, the custom path will +REM always end with "msys64". +SET MSYS_PATH=%2 +IF "%MSYS_PATH%"=="" (SET MSYS_PATH=C:) + +REM Download the latest installer and install MSYS2. Overwrite any existing +REM archive. +SET MSYS_SETUP_URL=https://github.com/msys2/msys2-installer/releases/download/^ +nightly-x86_64/msys2-base-x86_64-latest.sfx.exe +SET MSYS_SETUP_FILE=msys2-base-x86_64.exe + +REM Make sure that we can download tools if necessary through wget. +winget install wget^ + --silent^ + --accept-package-agreements^ + --accept-source-agreements + +wget -q -O %MSYS_SETUP_FILE% %MSYS_SETUP_URL% +%MSYS_SETUP_FILE% -y -o%MSYS_PATH%\ + +REM Make MSYS2 installation available in this script environment. +SET PATH=%PATH%;%MSYS_PATH%\msys64 +echo MSYS2 path ... %MSYS_PATH%\msys64 + +echo Installing packages ... +msys2_shell.cmd -%MSYS_ENV% -defterm -no-start -here -c "./installMSYS2-packages.sh"