Skip to content

Commit

Permalink
Add support for Windows Aarch64
Browse files Browse the repository at this point in the history
Co-authored-by: Cheng Shao <[email protected]>
  • Loading branch information
GulinSS and TerrorJack committed Jan 10, 2025
1 parent 45e3289 commit 7f7451f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Compat/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ setEnv_ key value = withCWString key $ \k -> withCWString value $ \v -> do
{- FOURMOLU_DISABLE -}
# if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
# elif defined(x86_64_HOST_ARCH)
# elif defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH)
# define WINDOWS_CCONV ccall
# else
# error Unknown mingw32 arch
Expand Down
1 change: 1 addition & 0 deletions Cabal/src/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ generatePathsModule pkg_descr lbi clbi =
, Z.zIsWindows = isWindows
, Z.zIsI386 = buildArch == I386
, Z.zIsX8664 = buildArch == X86_64
, Z.zIsAarch64 = buildArch == AArch64
, Z.zNot = not
, Z.zManglePkgName = showPkgName
, Z.zPrefix = show flat_prefix
Expand Down
5 changes: 3 additions & 2 deletions Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data Z
zIsWindows :: Bool,
zIsI386 :: Bool,
zIsX8664 :: Bool,
zIsAarch64 :: Bool,
zPrefix :: FilePath,
zBindir :: FilePath,
zLibdir :: FilePath,
Expand Down Expand Up @@ -278,13 +279,13 @@ render z_root = execWriter $ do
tell " c_GetModuleFileName :: Ptr () -> CWString -> Int32 -> IO Int32\n"
return ()
else do
if (zIsX8664 z_root)
if (zIsX8664 z_root || zIsAarch64 z_root)
then do
tell "foreign import ccall unsafe \"windows.h GetModuleFileNameW\"\n"
tell " c_GetModuleFileName :: Ptr () -> CWString -> Int32 -> IO Int32\n"
return ()
else do
tell "-- win32 supported only with I386, X86_64\n"
tell "-- win32 supported only with I386, X86_64, Aarch64\n"
tell "c_GetModuleFileName :: Ptr () -> CWString -> Int32 -> IO Int32\n"
tell "c_GetModuleFileName = _\n"
return ()
Expand Down
1 change: 1 addition & 0 deletions cabal-dev-scripts/src/GenPathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $(capture "decls" [d|
, zIsWindows :: Bool
, zIsI386 :: Bool
, zIsX8664 :: Bool
, zIsAarch64 :: Bool

, zPrefix :: FilePath
, zBindir :: FilePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ getExecutablePath = readSymbolicLink $ "/proc/self/exe"

# if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
# elif defined(x86_64_HOST_ARCH)
# elif defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH)
# define WINDOWS_CCONV ccall
# else
# error Unknown mingw32 arch
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/pr-10705
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
synopsis: 'Add support for Windows Aarch64'
packages: [Cabal, cabal-install]
prs: 10705
---

Adds to preprocessor branches the option to support `aarch64_HOST_ARCH` platform on Windows Aarch64 target.
`ccall` convention is used at Aarch64, same as for `x86_64_HOST_ARCH`. Introduce `zIsAarch64` to make paths generation support Windows Aarch64 target.

0 comments on commit 7f7451f

Please sign in to comment.