Skip to content

Commit

Permalink
For Windows (non-MSVC) builds, fix makefiles to support all combinati…
Browse files Browse the repository at this point in the history
…ons of CONFIGURATION/THREADING. As known from macOS builds, the "-T" option can now be used in mvm scripts to enable multi-threading.

Note that THREADING=multi only works for squeak.cog.spur flavors. Finally, for 32-bit builds, also disable the stack protector when we are using the clang compiler, which we already do for 64-bits.
  • Loading branch information
marceltaeumel committed Apr 15, 2024
1 parent 8e9abfb commit 256f332
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 94 deletions.
2 changes: 1 addition & 1 deletion building/win32x86/common/MAKEASSERT.BAT
@@ -1 +1 @@
make CONFIGURATION=assert THREADING=single default 2>&1 | tee LOGA
make assert 2>&1 | tee LOGA
2 changes: 1 addition & 1 deletion building/win32x86/common/MAKEDEBUG.BAT
@@ -1 +1 @@
make CONFIGURATION=debug THREADING=single default 2>&1 | tee LOGD
make debug 2>&1 | tee LOGD
2 changes: 1 addition & 1 deletion building/win32x86/common/MAKEFAST.BAT
@@ -1 +1 @@
make CONFIGURATION=product THREADING=single default 2>&1 | tee LOGF
make product 2>&1 | tee LOGF
32 changes: 21 additions & 11 deletions building/win32x86/common/Makefile
Expand Up @@ -17,10 +17,19 @@ all: default

VM?=Squeak
VM_NAME?=$(VM)
CONFIGURATION=product
THREADING=single
export VM VM_NAME CONFIGURATION COGDEFS

# This Makefile has a two-pass initialization scheme for COGDEFS, which
# sets VM-specific compilation flags such as for multi-threaded and
# debug builds. We encode this by checking whether CONFIGURATION was
# provided from the outer invocation. We want to avoid expanding COGDEFS
# with the wrong default values in the first, preparatory pass.
ifeq ($(CONFIGURATION),)
IS_PREPARING:=true
else
IS_PREPARING:=false
endif

# Is this a Croquet VM (defaults to OGL instead of D3D)?
CROQUET:=-DCROQUET

Expand Down Expand Up @@ -140,28 +149,29 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC)
# Common build rules
#

default: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST)
default: product # ensure two-pass initialization, see below
defaultBuild: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST)

svnver:
echo $(RC) $(RCFLAGS)

productmt:;
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=multi $(@,product=) default
productmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) defaultBuild

product:;
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=single $(@,product=) default
product:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) defaultBuild

assertmt:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=multi $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) defaultBuild

assert:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=single $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) defaultBuild

debugmt:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=multi $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) defaultBuild

debug:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=single $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) defaultBuild

# Do make init to allow make -n to function.
init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe
Expand Down
34 changes: 22 additions & 12 deletions building/win32x86/common/Makefile.msvc
Expand Up @@ -19,10 +19,19 @@ all: default

VM?=Squeak
VM_NAME?=$(VM)
CONFIGURATION=product
THREADING=single
export VM VM_NAME CONFIGURATION COGDEFS

# This Makefile has a two-pass initialization scheme for COGDEFS, which
# sets VM-specific compilation flags such as for multi-threaded and
# debug builds. We encode this by checking whether CONFIGURATION was
# provided from the outer invocation. We want to avoid expanding COGDEFS
# with the wrong default values in the first, preparatory pass.
ifeq ($(CONFIGURATION),)
IS_PREPARING:=true
else
IS_PREPARING:=false
endif

# Is this a Croquet VM (defaults to OGL instead of D3D)?
CROQUET:=-DCROQUET

Expand Down Expand Up @@ -137,29 +146,30 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC)
# Common build rules
#

#default: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) nukelibs $(APPPOST)
default: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(APPPOST)
default: product # ensure two-pass initialization, see below
#defaultBuild: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) nukelibs $(APPPOST)
defaultBuild: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(APPPOST)

svnver:
echo $(RC) $(RCFLAGS)

productmt:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) default
productmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) defaultBuild

product:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) default
product:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) defaultBuild

assertmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) defaultBuild

assert:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) defaultBuild

debugmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) defaultBuild

debug:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) defaultBuild

# Do make init to allow make -n to function.
init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe
Expand Down
12 changes: 7 additions & 5 deletions building/win32x86/common/Makefile.msvc.tools
Expand Up @@ -40,11 +40,13 @@ DEBUGVM=1
NDEBUG:=-D'VM_LABEL(foo)=0'
endif

ifeq ($(THREADING),multi)
COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
else
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
endif
ifeq ($(IS_PREPARING),false)
ifeq ($(THREADING),multi)
COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
else
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
endif
endif # IS_PREPARING

# MSVC's preprocessor (bless its heart) can't manage complex expansions
# and so unless we specify USE_INLINE_MEMORY_ACCESSORS lots of things
Expand Down
16 changes: 11 additions & 5 deletions building/win32x86/common/Makefile.tools
Expand Up @@ -39,11 +39,17 @@ DEBUGVM=1
NDEBUG:= -DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0'
endif

ifeq ($(THREADING),multi)
COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
else
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
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
Expand Down
46 changes: 32 additions & 14 deletions building/win32x86/squeak.cog.spur/mvm
@@ -1,12 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'Aadf?' opt "$@"; do
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=1;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -18,18 +21,33 @@ else
A=1;D=1;F=1
fi
fi
shift `expr $OPTIND - 1`
shift `expr $OPTIND - 1` # drop options, pass other args to make
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
rm -rf builddbg/vm/*.exe
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
rm -rf buildast/vm/*.exe
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
rm -rf build/vm/*.exe
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then # single-threaded VM
if [ -n "$D" ]; then
rm -rf builddbg/vm/*.exe
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
rm -rf buildast/vm/*.exe
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
rm -rf build/vm/*.exe
make $@ product 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else # multi-threaded VM
if [ -n "$D" ]; then
rm -rf buildmtdbg/vm/*.exe
make $@ debugmt 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
rm -rf buildmtast/vm/*.exe
make $@ assertmt 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
rm -rf buildmt/vm/*.exe
make $@ productmt 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
2 changes: 1 addition & 1 deletion building/win64x64/common/MAKEASSERT.BAT
@@ -1 +1 @@
make CONFIGURATION=assert THREADING=single default 2>&1 | tee LOGA
make assert 2>&1 | tee LOGA
2 changes: 1 addition & 1 deletion building/win64x64/common/MAKEDEBUG.BAT
@@ -1 +1 @@
make CONFIGURATION=debug THREADING=single default 2>&1 | tee LOGD
make debug 2>&1 | tee LOGD
2 changes: 1 addition & 1 deletion building/win64x64/common/MAKEFAST.BAT
@@ -1 +1 @@
make CONFIGURATION=product THREADING=single default 2>&1 | tee LOGF
make product 2>&1 | tee LOGF
32 changes: 21 additions & 11 deletions building/win64x64/common/Makefile
Expand Up @@ -17,10 +17,19 @@ all: default

VM?=Squeak
VM_NAME?=$(VM)
CONFIGURATION=product
THREADING=single
export VM VM_NAME CONFIGURATION COGDEFS

# This Makefile has a two-pass initialization scheme for COGDEFS, which
# sets VM-specific compilation flags such as for multi-threaded and
# debug builds. We encode this by checking whether CONFIGURATION was
# provided from the outer invocation. We want to avoid expanding COGDEFS
# with the wrong default values in the first, preparatory pass.
ifeq ($(CONFIGURATION),)
IS_PREPARING:=true
else
IS_PREPARING:=false
endif

# Is this a Croquet VM (defaults to OGL instead of D3D)?
CROQUET:=-DCROQUET

Expand Down Expand Up @@ -140,28 +149,29 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC)
# Common build rules
#

default: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST)
default: product # ensure two-pass initialization, see below
defaultBuild: print-tools print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs $(APPPOST)

svnver:
echo $(RC) $(RCFLAGS)

productmt:;
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=multi $(@,product=) default
productmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) defaultBuild

product:;
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=single $(@,product=) default
product:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) defaultBuild

assertmt:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=multi $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) defaultBuild

assert:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=single $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) defaultBuild

debugmt:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=multi $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) defaultBuild

debug:
$(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=single $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) defaultBuild

# Do make init to allow make -n to function.
init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe
Expand Down
32 changes: 21 additions & 11 deletions building/win64x64/common/Makefile.msvc
Expand Up @@ -19,10 +19,19 @@ all: default

VM?=Squeak
VM_NAME?=$(VM)
CONFIGURATION=product
THREADING=single
export VM VM_NAME CONFIGURATION COGDEFS

# This Makefile has a two-pass initialization scheme for COGDEFS, which
# sets VM-specific compilation flags such as for multi-threaded and
# debug builds. We encode this by checking whether CONFIGURATION was
# provided from the outer invocation. We want to avoid expanding COGDEFS
# with the wrong default values in the first, preparatory pass.
ifeq ($(CONFIGURATION),)
IS_PREPARING:=true
else
IS_PREPARING:=false
endif

# Is this a Croquet VM (defaults to OGL instead of D3D)?
CROQUET:=-DCROQUET

Expand Down Expand Up @@ -143,28 +152,29 @@ INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC)
# Common build rules
#

default: print-settings init libs $(VMEXE) $(CONSOLEVMEXE) dlls $(APPPOST)
default: product # ensure two-pass initialization, see below
defaultBuild: print-settings init libs $(VMEXE) $(CONSOLEVMEXE) dlls $(APPPOST)

svnver:
echo $(RC) $(RCFLAGS)

productmt:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) default
productmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=multi $(@,product=) defaultBuild

product:;
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) default
product:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=product THREADING=single $(@,product=) defaultBuild

assertmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=multi $(@,assert=) defaultBuild

assert:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=assert THREADING=single $(@,assert=) defaultBuild

debugmt:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=multi $(@,debug=) defaultBuild

debug:
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) default
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CONFIGURATION=debug THREADING=single $(@,debug=) defaultBuild

# Do make init to allow make -n to function.
init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe
Expand Down
4 changes: 2 additions & 2 deletions building/win64x64/common/Makefile.msvc.tools
Expand Up @@ -36,7 +36,7 @@ DEBUGVM=1
NDEBUG:=-D'VM_LABEL(foo)=0'
endif

ifeq ($(findstring -DCOGMTVM=,$(COGDEFS)),)
ifeq ($(IS_PREPARING),false)
ifeq ($(THREADING),multi)
COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
else
Expand All @@ -45,7 +45,7 @@ ifeq ($(findstring -DCOGMTVM=,$(COGDEFS)),)
ifdef BIT_IDENTICAL_FLOATING_POINT
COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1
endif
endif
endif # IS_PREPARING

# Set minimum version to Windows 8 (see /cygwin/usr/include/w32api/w32api.h)
#but if so, sqWin32AEC.cpp includes DeviceTopology.h & barfs
Expand Down

1 comment on commit 256f332

@marceltaeumel
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, typo. I also updated the Makefile.msvc and Makefile.msvc.tools files.

Please sign in to comment.