Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for ARM64 Windows #8142

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1ee5dfd
added aarch64 target support for wsl_tools
cocoa-xu Feb 17, 2024
f4eb21e
added aarch64 target support
cocoa-xu Feb 19, 2024
554b2e3
added config cache files for aarch64 windows target
cocoa-xu Feb 17, 2024
53c2f2e
added installation guide for aarch64 windows
cocoa-xu Feb 17, 2024
af26c84
arm64 jit now works on windows
cocoa-xu Feb 17, 2024
e820d26
fix cross-compile on x86_64 for aarch64
cocoa-xu Feb 18, 2024
52b7d79
[WIP] updated find_redist
cocoa-xu Feb 19, 2024
4d00bfc
fix i_perf_counter on aarch64 windows
cocoa-xu Feb 19, 2024
51be569
fix typo in wsl_tools reg_query.sh
cocoa-xu Feb 19, 2024
945c8a1
Update configure scripts
cocoa-xu Feb 19, 2024
b5f6d21
set linker opt `/MACHINE` for all `$CONFIG_SUBTYPE`
cocoa-xu Feb 19, 2024
021c2d1
updated emu_cc.sh
cocoa-xu Feb 19, 2024
d97c4bc
clang-format
cocoa-xu Feb 19, 2024
ede4e58
updated otp_build
cocoa-xu Feb 19, 2024
0f5b5b9
use simple list initializers instead of designated initializers
cocoa-xu Feb 19, 2024
6bf0b6e
added back base case local-*-windows
cocoa-xu Feb 19, 2024
30f9c35
format
cocoa-xu Feb 19, 2024
5726b54
only set VEREDIST var for arm64
cocoa-xu Feb 19, 2024
a7ac04d
updated installation guide for using wxWidgets
cocoa-xu Feb 19, 2024
27d808c
updated nsis script
cocoa-xu Feb 19, 2024
db43638
check newer vcredist.exe filenames
cocoa-xu Feb 19, 2024
576dcb0
fix a typo
cocoa-xu Feb 19, 2024
747e27a
updated nsis script
cocoa-xu Feb 19, 2024
7a719a0
Update erts/etc/win32/nsis/find_redist.sh
cocoa-xu Feb 20, 2024
551751f
fix typo in nsis script
cocoa-xu Feb 20, 2024
2d79abb
use fwrite in `display_string_2` for windows
cocoa-xu Feb 23, 2024
892019a
handle nanosecond in erlang code
cocoa-xu Feb 24, 2024
0641273
fix display_string_2
cocoa-xu Mar 9, 2024
f61d617
Merge branch 'master' into cx/windows-arm64
cocoa-xu May 20, 2024
88a1244
Merge branch 'master' into cx/windows-arm64
cocoa-xu Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
521 changes: 521 additions & 0 deletions HOWTO/INSTALL-WIN32-ARM64.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions HOWTO/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ Operating system
* Ubuntu 10.04 - 22.04
* Windows 11, Windows 10, Windows Server 2019


[DESTDIR]: http://www.gnu.org/prep/standards/html_node/DESTDIR.html
[Building in Git]: #advanced-configuration-and-build-of-erlang-otp_Building_Within-Git
[Advanced Configure]: #advanced-configuration-and-build-of-erlang-otp_Configuring
Expand Down
76 changes: 70 additions & 6 deletions erts/configure
Original file line number Diff line number Diff line change
Expand Up @@ -3837,6 +3837,27 @@ test -n "$target_alias" &&

# Adjust for local legacy windows hack...
case $host in #(
local-aarch64-*-windows) :

host=win32
host_os=win32
host_vendor=
host_cpu=aarch64
;; #(
local-x86_64-*-windows) :

host=win32
host_os=win32
host_vendor=
host_cpu=x86_64
;; #(
local-i686-*-windows) :

host=win32
host_os=win32
host_vendor=
host_cpu=i686
;; #(
local-*-windows) :

host=win32
Expand All @@ -3851,6 +3872,27 @@ esac

# Adjust for local legacy windows hack...
case $build in #(
local-aarch64-*-windows) :

build=win32
build_os=win32
build_vendor=
build_cpu=aarch64
;; #(
local-x86_64-*-windows) :

build=win32
build_os=win32
build_vendor=
build_cpu=x86_64
;; #(
local-i686-*-windows) :

build=win32
build_os=win32
build_vendor=
build_cpu=i686
;; #(
local-*-windows) :

build=win32
Expand All @@ -3865,6 +3907,27 @@ esac

# Adjust for local legacy windows hack...
case $target in #(
local-aarch64-*-windows) :

target=win32
target_os=win32
target_vendor=
target_cpu=aarch64
;; #(
local-x86_64-*-windows) :

target=win32
target_os=win32
target_vendor=
target_cpu=x86_64
;; #(
local-i686-*-windows) :

target=win32
target_os=win32
target_vendor=
target_cpu=i686
;; #(
local-*-windows) :

target=win32
Expand All @@ -3876,18 +3939,19 @@ esac
;;
esac

if test "$cross_compiling" = "yes" -a "$build" = "$host"
if test "$cross_compiling" = "yes" -a "$build" = "$host" -a "$build_cpu" = "$host_cpu"
then :
as_fn_error $? "
Cross compiling with the same canonicalized 'host' value
as the canonicalized 'build' value.
Cross compiling with the same canonicalized 'host' and 'host_cpu'
values as the canonicalized 'build' and 'build_cpu' values

We are cross compiling since the '--host=$host_alias'
and the '--build=$build_alias' arguments differ. When
cross compiling Erlang/OTP, also the canonicalized values of
the '--build' and the '--host' arguments *must* differ. The
canonicalized values of these arguments however both equals:
$host
host = build = $host,
host_cpu = build_cpu = $host_cpu

You can check the canonical value by passing a value as
argument to the 'make/autoconf/config.sub' script.
Expand Down Expand Up @@ -6550,7 +6614,7 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx11+y}
if test ${ac_cv_prog_cxx_11+y}
then :
printf %s "(cached) " >&6
else case e in #(
Expand Down Expand Up @@ -6599,7 +6663,7 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
if test ${ac_cv_prog_cxx_cxx98+y}
if test ${ac_cv_prog_cxx_98+y}
then :
printf %s "(cached) " >&6
else case e in #(
Expand Down
12 changes: 5 additions & 7 deletions erts/emulator/beam/bif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3901,11 +3901,11 @@ BIF_RETTYPE display_string_2(BIF_ALIST_2)
int res;

#ifdef __WIN32__
HANDLE fd;
FILE * fd;
if (ERTS_IS_ATOM_STR("stdout", BIF_ARG_1)) {
fd = GetStdHandle(STD_OUTPUT_HANDLE);
fd = stdout;
} else if (ERTS_IS_ATOM_STR("stderr", BIF_ARG_1)) {
fd = GetStdHandle(STD_ERROR_HANDLE);
fd = stderr;
}
#else
int fd;
Expand Down Expand Up @@ -3964,11 +3964,9 @@ BIF_RETTYPE display_string_2(BIF_ALIST_2)
#endif
{
#ifdef __WIN32__
Uint32 w;
if (!WriteFile(fd, str, len, &w, NULL)) {
res = fwrite(str, len, 1, fd);
if (res <= 0)
goto error;
}
written = (Sint)w;
#else
written = 0;
do {
Expand Down
4 changes: 1 addition & 3 deletions erts/emulator/beam/erl_time_sup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,9 +2302,7 @@ time_unit_conversion(Process *c_p, Eterm term, ErtsMonotonicTime val, ErtsMonoto
case am_nanosecond:
case am_nano_seconds:
case make_small(1000*1000*1000):
result = ERTS_MONOTONIC_TO_NSEC(val) + muloff*ERTS_MONOTONIC_OFFSET_NSEC;
ERTS_BIF_PREP_RET(ret, make_time_val(c_p, result));
break;
goto trap_to_erlang_code;
#endif
case am_perf_counter:
goto trap_to_erlang_code;
Expand Down
5 changes: 5 additions & 0 deletions erts/emulator/beam/jit/arm/instr_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,7 +3109,12 @@ void BeamModuleAssembler::emit_i_perf_counter() {
Label next = a.newLabel(), small = a.newLabel();

emit_enter_runtime_frame();
#ifdef WIN32
/* Call the function pointer used by erts_sys_perf_counter */
runtime_call<0>(erts_sys_time_data__.r.o.sys_hrtime);
#else
runtime_call<0>(erts_sys_time_data__.r.o.perf_counter);
#endif
emit_leave_runtime_frame();

a.asr(TMP1, ARG1, imm(SMALL_BITS - 1));
Expand Down
4 changes: 2 additions & 2 deletions erts/emulator/beam/jit/beam_jit_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ struct BeamModuleAssemblerCommon {
}

/* Helpers */
const auto &getTypeEntry(const ArgSource &arg) const {
const BeamArgType &getTypeEntry(const ArgSource &arg) const {
auto typeIndex =
arg.isRegister() ? arg.as<ArgRegister>().typeIndex() : 0;
ASSERT(typeIndex < beam->types.count);
return static_cast<BeamArgType &>(beam->types.entries[typeIndex]);
}

auto getTypeUnion(const ArgSource &arg) const {
BeamTypeId getTypeUnion(const ArgSource &arg) const {
if (arg.isRegister()) {
return getTypeEntry(arg).type();
}
Expand Down
4 changes: 2 additions & 2 deletions erts/etc/win32/nsis/erlang20.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ Var STARTMENU_FOLDER

;Folder selection page
!if ${WINTYPE} == "win64"
InstallDir "$PROGRAMFILES64\Erlang OTP"
InstallDir "$PROGRAMFILES64\Erlang OTP"
!else
InstallDir "$PROGRAMFILES\Erlang OTP"
InstallDir "$PROGRAMFILES\Erlang OTP"
!endif
;Remember install folder
InstallDirRegKey HKLM "SOFTWARE\Ericsson\Erlang\${ERTS_VERSION}" ""
Expand Down
12 changes: 10 additions & 2 deletions erts/etc/win32/wsl_tools/SetupWSLcross.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
rem Setup MCL and echo the environment
rem Usage: eval `cmd.exe /c SetupWSLcross.bat x64`

set MACHINE="%~1"
IF "%~1"=="x86" GOTO search
IF "%~1"=="x64" GOTO search
IF "%~1"=="arm64" GOTO search
IF "%~1"=="amd64_arm64" GOTO search

GOTO badarg

Expand Down Expand Up @@ -67,7 +70,12 @@ GOTO no_vcvars

:continue

FOR /F "delims==" %%F IN ('where cl.exe') DO SET _cl_exec_=%%F
FOR /F "delims==" %%F IN ('where cl.exe') DO (
SET _cl_exec_=%%F
goto set_cl_path
)

:set_cl_path
FOR %%F IN ("%_cl_exec_%") DO SET CL_PATH=%%~dpF

FOR /F "delims==" %%F IN ('where rc.exe') DO SET _rc_exec_=%%F
Expand All @@ -87,7 +95,7 @@ wsl.exe echo "# Eval this file eval \`cmd.exe /c SetupWSLcross.bat\`"
exit

:badarg
echo "Bad TARGET or not specified: %~1 expected x86 or x64"
echo "Bad TARGET or not specified: %~1 expected x86, x64, arm64 or x64_arm64"
exit

:no_vcvars
Expand Down
2 changes: 2 additions & 0 deletions erts/etc/win32/wsl_tools/reg_query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ BACKED=`echo "$1" | sed 's,/,\\\\,g'`

if [ $CONFIG_SUBTYPE = "win64" ]; then
REG_OPT=" /reg:64"
elif [ X"$CONFIG_SUBTYPE" = X"arm64" -o X"$CONFIG_SUBTYPE" = X"x64_arm64" ]; then
REG_OPT=" /reg:64"
else
REG_OPT=" /reg:32"
fi
Expand Down
11 changes: 10 additions & 1 deletion erts/etc/win32/wsl_tools/vc/cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ SAVE="$@"
# Constants
COMMON_CFLAGS="-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -D_CRT_SECURE_NO_DEPRECATE"

if [ "$CONFIG_SUBTYPE" = "x64_arm64" -o "$CONFIG_SUBTYPE" = "arm64" ]; then
MACHINE="ARM64"
COMMON_CFLAGS="${COMMON_CFLAGS} -D__aarch64__"
elif [ "$CONFIG_SUBTYPE" = "win64" ]; then
MACHINE="x64"
else
MACHINE="x86"
fi

# Variables
# The stdout and stderr for the compiler
MSG_FILE=/tmp/cl.exe.$$.1
Expand Down Expand Up @@ -64,7 +73,7 @@ CMD=""
# All the c source files, in unix style
SOURCES=""
# All the options to pass to the linker, kept in Unix style
LINKCMD=""
LINKCMD="-MACHINE:${MACHINE}"

cocoa-xu marked this conversation as resolved.
Show resolved Hide resolved

# Loop through the parameters and set the above variables accordingly
Expand Down
2 changes: 2 additions & 0 deletions erts/etc/win32/wsl_tools/vc/emu_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

if [ X"$CONFIG_SUBTYPE" = X"win64" ]; then
GCC="x86_64-w64-mingw32-gcc -m64"
elif [ X"$CONFIG_SUBTYPE" = X"arm64" || X"$CONFIG_SUBTYPE" = X"x64_arm64" ]; then
GCC="aarch64-w64-mingw32-gcc -m64"
else
GCC="x86_64-w64-mingw32-gcc -m32"
fi
Expand Down
Loading
Loading