Skip to content

Commit

Permalink
Apply patch to build for ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Feb 25, 2022
1 parent 674867e commit ee45625
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 37 deletions.
Binary file added compat/zlib/win64-arm/zdll.lib
Binary file not shown.
6 changes: 3 additions & 3 deletions generic/tclTest.c
Expand Up @@ -326,7 +326,7 @@ static Tcl_NRPostProc NREUnwind_callback;
static Tcl_ObjCmdProc TestNREUnwind;
static Tcl_ObjCmdProc TestNRELevels;
static Tcl_ObjCmdProc TestInterpResolverCmd;
#if defined(HAVE_CPUID) || defined(_WIN32)
#if defined(HAVE_CPUID)
static Tcl_ObjCmdProc TestcpuidCmd;
#endif

Expand Down Expand Up @@ -600,7 +600,7 @@ Tcltest_Init(
NULL, NULL);
Tcl_CreateCommand(interp, "testexitmainloop", TestexitmainloopCmd,
NULL, NULL);
#if defined(HAVE_CPUID) || defined(_WIN32)
#if defined(HAVE_CPUID)
Tcl_CreateObjCommand(interp, "testcpuid", TestcpuidCmd,
NULL, NULL);
#endif
Expand Down Expand Up @@ -6951,7 +6951,7 @@ TestFindLastCmd(
return TCL_OK;
}

#if defined(HAVE_CPUID) || defined(_WIN32)
#if defined(HAVE_CPUID)
/*
*----------------------------------------------------------------------
*
Expand Down
4 changes: 3 additions & 1 deletion tests/env.test
Expand Up @@ -102,7 +102,9 @@ variable keep {
SHLIB_PATH SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING MSYSTEM
__CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM
CommonProgramFiles ProgramFiles CommonProgramW6432 ProgramW6432
CommonProgramFiles CommonProgramFiles(x86) ProgramFiles
ProgramFiles(x86) CommonProgramW6432 ProgramW6432
WINECONFIGDIR WINEDATADIR WINEDLLDIR0 WINEHOMEDIR PROCESSOR_ARCHITECTURE
}

variable printenvScript [makeFile [string map [list @keep@ [list $keep]] {
Expand Down
6 changes: 5 additions & 1 deletion win/Makefile.in
Expand Up @@ -519,7 +519,11 @@ ${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}

# use pre-built zlib1.dll
${ZLIB_DLL_FILE}: ${TCL_STUB_LIB_FILE}
@if test "@ZLIB_LIBS@set" != "${ZLIB_DIR_NATIVE}/win32/zdll.libset" ; then \
@if test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win64-arm/zdll.libset" ; then \
$(COPY) $(ZLIB_DIR)/win64-arm/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
elif test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.aset" ; then \
$(COPY) $(ZLIB_DIR)/win64-arm/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
elif test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win32/zdll.libset" ; then \
$(COPY) $(ZLIB_DIR)/win64/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
else \
$(COPY) $(ZLIB_DIR)/win32/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
Expand Down
61 changes: 49 additions & 12 deletions win/configure
Expand Up @@ -3279,7 +3279,7 @@ fi
SHLIB_SUFFIX=".dll"
# MACHINE is IX86 for LINK, but this is used by the manifest,
# which requires x86|amd64|ia64.
# which requires x86|amd64|arm64|ia64.
MACHINE="X86"
if test "$GCC" = "yes"; then
Expand Down Expand Up @@ -3352,6 +3352,13 @@ echo "${ECHO_T}$ac_cv_cross" >&6
RANLIB="x86_64-w64-mingw32-ranlib"
RC="x86_64-w64-mingw32-windres"
;;
arm64|aarch64)
CC="aarch64-w64-mingw32-${CC}"
LD="aarch64-w64-mingw32-ld"
AR="aarch64-w64-mingw32-ar"
RANLIB="aarch64-w64-mingw32-ranlib"
RC="aarch64-w64-mingw32-windres"
;;
*)
CC="i686-w64-mingw32-${CC}"
LD="i686-w64-mingw32-ld"
Expand Down Expand Up @@ -3470,6 +3477,9 @@ echo "${ECHO_T}$ac_cv_win32" >&6
echo "$as_me: error: ${CC} cannot produce win32 executables." >&2;}
{ (exit 1); exit 1; }; }
fi
if test "$MACHINE" != "ARM64"; then
extra_cflags="$extra_cflags -DHAVE_CPUID=1"
fi
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -mwindows -municode -Dmain=xxmain"
echo "$as_me:$LINENO: checking for working -municode linker flag" >&5
Expand Down Expand Up @@ -3702,10 +3712,15 @@ echo "$as_me: error: ${CC} does not support the -shared option.
echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
;;
arm64|aarch64)
MACHINE="ARM64"
echo "$as_me:$LINENO: result: Using ARM64 $MACHINE mode" >&5
echo "${ECHO_T} Using ARM64 $MACHINE mode" >&6
;;
ia64)
MACHINE="IA64"
echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
echo "$as_me:$LINENO: result: Using IA64 $MACHINE mode" >&5
echo "${ECHO_T} Using IA64 $MACHINE mode" >&6
;;
*)
cat >conftest.$ac_ext <<_ACEOF
Expand Down Expand Up @@ -3759,9 +3774,9 @@ tcl_win_64bit=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$tcl_win_64bit" = "yes" ; then
do64bit=amd64
MACHINE="AMD64"
echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
do64bit=amd64
MACHINE="AMD64"
echo "$as_me:$LINENO: result: Using 64-bit $MACHINE mode" >&5
echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
fi
;;
Expand Down Expand Up @@ -3802,6 +3817,9 @@ echo "${ECHO_T}using shared flags" >&6
amd64|x64|yes)
MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
;;
arm64|aarch64)
MACHINE="ARM64"
;;
ia64)
MACHINE="IA64"
;;
Expand All @@ -3823,8 +3841,7 @@ echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
if test "$do64bit" != "no" ; then
RC="rc"
CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
# Do not use -O2 for Win64 - this has proved buggy in code gen.
CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
CFLAGS_OPTIMIZE="-nologo -O2 ${runtime}"
lflags="${lflags} -nologo -MACHINE:${MACHINE}"
LINKBIN="link"
# Avoid 'unresolved external symbol __security_cookie' errors.
Expand Down Expand Up @@ -4317,14 +4334,34 @@ if test "$tcl_ok" = "yes"; then
if test "$do64bit" != "no"; then
if test "$GCC" == "yes"; then
if test "$do64bit" = "arm64"; then
if test "$GCC" == "yes"; then
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/libz.dll.a
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.a
else
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/zdll.lib
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64-arm/zdll.lib
fi
else
if test "$GCC" == "yes"; then
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/libz.dll.a
else
ZLIB_LIBS=\${ZLIB_DIR_NATIVE}/win64/zdll.lib
fi
fi
Expand Down Expand Up @@ -5208,7 +5245,7 @@ case "$TCL_PATCH_LEVEL" in
esac
TCL_WIN_VERSION="$TCL_VERSION.$TCL_RELEASE_LEVEL.`echo $TCL_PATCH_LEVEL | tr -d ab.`"
# X86|AMD64|IA64 for manifest
# X86|AMD64|ARM64|IA64 for manifest
Expand Down
16 changes: 12 additions & 4 deletions win/configure.in
Expand Up @@ -144,10 +144,18 @@ AS_IF([test "${enable_shared+set}" = "set"], [
AS_IF([test "$tcl_ok" = "yes"], [
AC_SUBST(ZLIB_DLL_FILE,[\${ZLIB_DLL_FILE}])
AS_IF([test "$do64bit" != "no"], [
AS_IF([test "$GCC" == "yes"],[
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/libz.dll.a])
AS_IF([test "$do64bit" = "arm64"], [
AS_IF([test "$GCC" == "yes"],[
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.a])
], [
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64-arm/zdll.lib])
])
], [
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/zdll.lib])
AS_IF([test "$GCC" == "yes"],[
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/libz.dll.a])
], [
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64/zdll.lib])
])
])
], [
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win32/zdll.lib])
Expand Down Expand Up @@ -375,7 +383,7 @@ case "$TCL_PATCH_LEVEL" in
esac
TCL_WIN_VERSION="$TCL_VERSION.$TCL_RELEASE_LEVEL.`echo $TCL_PATCH_LEVEL | tr -d ab.`"
AC_SUBST(TCL_WIN_VERSION)
# X86|AMD64|IA64 for manifest
# X86|AMD64|ARM64|IA64 for manifest
AC_SUBST(MACHINE)

AC_SUBST(TCL_VERSION)
Expand Down
3 changes: 2 additions & 1 deletion win/makefile.vc
Expand Up @@ -97,7 +97,7 @@
# nodep = Turns off compatibility macros to ensure the core
# isn't being built with deprecated functions.
#
# MACHINE=(ALPHA|AMD64|IA64|IX86)
# MACHINE=(ALPHA|AMD64|ARM64|IA64|IX86)
# Set the machine type used for the compiler, linker, and
# resource compiler. This hook is needed to tell the tools
# when alternate platforms are requested. IX86 is the default
Expand Down Expand Up @@ -911,6 +911,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata
@$(CPY) "$(WIN_DIR)\tclooConfig.sh" "$(LIB_INSTALL_DIR)\"
@$(CPY) "$(WIN_DIR)\rules.vc" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(WIN_DIR)\targets.vc" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(WIN_DIR)\x86_64-w64-mingw32-nmakehlp.exe" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(WIN_DIR)\nmakehlp.c" "$(LIB_INSTALL_DIR)\nmake\"
@$(CPY) "$(OUT_DIR)\tcl.nmake" "$(LIB_INSTALL_DIR)\nmake\"
@echo Installing package http 1.0 (obsolete)
Expand Down
26 changes: 23 additions & 3 deletions win/rules.vc
Expand Up @@ -24,7 +24,7 @@ _RULES_VC = 1
# For modifications that are not backward-compatible, you *must* change
# the major version.
RULES_VERSION_MAJOR = 1
RULES_VERSION_MINOR = 9
RULES_VERSION_MINOR = 10

# The PROJECT macro must be defined by parent makefile.
!if "$(PROJECT)" == ""
Expand Down Expand Up @@ -411,8 +411,8 @@ _INSTALLDIR=$(_INSTALLDIR)\lib
# compiler version 1200. This is kept only for legacy reasons as it
# does not make sense for recent Microsoft compilers. Only used for
# output directory names.
# ARCH - set to IX86 or AMD64 depending on 32- or 64-bit target
# NATIVE_ARCH - set to IX86 or AMD64 for the host machine
# ARCH - set to IX86, ARM64 or AMD64 depending on 32- or 64-bit target
# NATIVE_ARCH - set to IX86, ARM64 or AMD64 for the host machine
# MACHINE - same as $(ARCH) - legacy
# _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed

Expand All @@ -435,6 +435,8 @@ VCVER=0
&& ![echo ARCH=IX86 >> vercl.x] \
&& ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
&& ![echo ARCH=AMD64 >> vercl.x] \
&& ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \
&& ![echo ARCH=ARM64 >> vercl.x] \
&& ![echo $(_HASH)endif >> vercl.x] \
&& ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
!include vercl.i
Expand All @@ -459,6 +461,9 @@ VCVER = $(VCVERSION)
!if "$(MACHINE)" == "x86"
!undef MACHINE
MACHINE = IX86
!elseif "$(MACHINE)" == "arm64"
!undef MACHINE
MACHINE = ARM64
!elseif "$(MACHINE)" == "x64"
!undef MACHINE
MACHINE = AMD64
Expand All @@ -475,6 +480,8 @@ MACHINE=$(ARCH)
# the Tcl platform::identify command
!if "$(MACHINE)" == "AMD64"
PLATFORM_IDENTIFY = win32-x86_64
!elseif "$(MACHINE)" == "ARM64"
PLATFORM_IDENTIFY = win32-arm
!else
PLATFORM_IDENTIFY = win32-ix86
!endif
Expand All @@ -490,6 +497,8 @@ MULTIPLATFORM_INSTALL = 0

!if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
NATIVE_ARCH=IX86
!elseif ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i ARM | findstr /i 64-bit]
NATIVE_ARCH=ARM64
!else
NATIVE_ARCH=AMD64
!endif
Expand Down Expand Up @@ -539,10 +548,16 @@ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c

!endif # NMAKEHLPC


# We always build nmakehlp even if it exists since we do not know
# what source it was built from.
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
!endif
!else
!if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL]
!endif
!endif

################################################################
# 5. Test for compiler features
Expand Down Expand Up @@ -1476,6 +1491,11 @@ carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
carch =
!endif

# cpuid is only available on intel machines
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "AMD64"
carch = $(carch) /DHAVE_CPUID=1
!endif

!if $(DEBUG)
# Turn warnings into errors
cwarn = $(cwarn) -WX
Expand Down

0 comments on commit ee45625

Please sign in to comment.