Skip to content

Commit

Permalink
2024-09-14 18:36 UTC+0200 Aleksander Czajczynski (hb fki.pl)
Browse files Browse the repository at this point in the history
  + config/win/msvcarm.mk
  + config/win/msvcarm64.mk
  * config/global.mk
  * include/hbsetup.h
  * utils/hbmk2/hbmk2.prg
    + introduced support for Windows (10,11) ARM 64-bit platform
      native compilers using Visual Studio 2022 Build Tools

      before calling win-make, setup environment with:
      <InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm64.bat

      toolchain should be autodetected as following:
      ! HB_HOST_PLAT: win (arm64)  HB_SHELL: nt
      ! HB_PLATFORM: win (arm64) (auto-detected)
      ! HB_COMPILER: msvcarm64 (auto-detected: C:/Program[...]/ARM64/)

      to build final application with hbmk2 adding a valid Windows
      Platform SDK / CRT paths to INCLUDE= and/or LIB= variable
      is needed

    ; cross compilation from AMD64 hosts is possible:
      vcvars64.bat
      win-make (build Harbour for your host first)
      set HB_HOST_BIN=<HarbourPath>\bin\win\msvc64
      vcvarsamd64_arm64.bat
      win-make

    + also added support for Windows for ARM 32-bit

      before calling win-make, setup environment using:
      <InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm.bat
      or when cross compiling from ARM64 host:
      <InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm64_arm.bat

    ; please test Windows CE builds if you're using compiler newer
      than VC2003 for ARM for possible regressions

  * contrib/hbmlzo/3rd/minilzo/lzodefs.h
    ! recognize ARM64 architecture on Windows to fix build error

    ; consider updating to upstream minilzo 2.10, issue is fixed there

  * src/common/hbver.c
    * changed to add processor architecture for MSVC compiler string
      on non-Intel systems, as exposed by hb_compiler(), harbour /build,
      finalapp.exe //build

  * tests/speedtst.prg
    * workaround that processor architecture can now appear
      in hb_compiler(), so it's not printed by speed test twice
  • Loading branch information
alcz committed Sep 14, 2024
1 parent 368508e commit 26849d3
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 117 deletions.
52 changes: 52 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,58 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2024-09-14 18:36 UTC+0200 Aleksander Czajczynski (hb fki.pl)
+ config/win/msvcarm.mk
+ config/win/msvcarm64.mk
* config/global.mk
* include/hbsetup.h
* utils/hbmk2/hbmk2.prg
+ introduced support for Windows (10,11) ARM 64-bit platform
native compilers using Visual Studio 2022 Build Tools

before calling win-make, setup environment with:
<InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm64.bat

toolchain should be autodetected as following:
! HB_HOST_PLAT: win (arm64) HB_SHELL: nt
! HB_PLATFORM: win (arm64) (auto-detected)
! HB_COMPILER: msvcarm64 (auto-detected: C:/Program[...]/ARM64/)

to build final application with hbmk2 adding a valid Windows
Platform SDK / CRT paths to INCLUDE= and/or LIB= variable
is needed

; cross compilation from AMD64 hosts is possible:
vcvars64.bat
win-make (build Harbour for your host first)
set HB_HOST_BIN=<HarbourPath>\bin\win\msvc64
vcvarsamd64_arm64.bat
win-make

+ also added support for Windows for ARM 32-bit

before calling win-make, setup environment using:
<InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm.bat
or when cross compiling from ARM64 host:
<InstallPath>\BuildTools\VC\Auxiliary\Build\vcvarsarm64_arm.bat

; please test Windows CE builds if you're using compiler newer
than VC2003 for ARM for possible regressions

* contrib/hbmlzo/3rd/minilzo/lzodefs.h
! recognize ARM64 architecture on Windows to fix build error

; consider updating to upstream minilzo 2.10, issue is fixed there

* src/common/hbver.c
* changed to add processor architecture for MSVC compiler string
on non-Intel systems, as exposed by hb_compiler(), harbour /build,
finalapp.exe //build

* tests/speedtst.prg
* workaround that processor architecture can now appear
in hb_compiler(), so it's not printed by speed test twice

2024-08-17 17:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/xhb/xhberror.c
% cleaned code] to overload ERRORNEW() with XHB_ERRORNEW()
Expand Down
232 changes: 133 additions & 99 deletions config/global.mk

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/win/msvcarm.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(TOP)$(ROOT)config/$(HB_PLATFORM)/msvc.mk
1 change: 1 addition & 0 deletions config/win/msvcarm64.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(TOP)$(ROOT)config/$(HB_PLATFORM)/msvc.mk
3 changes: 3 additions & 0 deletions contrib/hbmlzo/3rd/minilzo/lzodefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@
# define LZO_ARCH_I086 1
# define LZO_ARCH_IA16 1
# define LZO_INFO_ARCH "i086"
#elif defined(__aarch64__) || defined(_M_ARM64)
# define LZO_ARCH_ARM64 1
# define LZO_INFO_ARCH "arm64"
#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
# define LZO_ARCH_ALPHA 1
# define LZO_INFO_ARCH "alpha"
Expand Down
3 changes: 2 additions & 1 deletion include/hbsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@
#define HB_CPU_X86_64

#elif defined( __arm64__ ) || \
defined( __aarch64__ )
defined( __aarch64__ ) || \
defined( _M_ARM64 )
#define HB_CPU_ARM_64

#elif defined( __arm__ ) || \
Expand Down
9 changes: 8 additions & 1 deletion src/common/hbver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ char * hb_verCompiler( void )
hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
#endif

#if ! defined( HB_CPU_X86 ) && ! defined( HB_CPU_X86_64 )
#define __HB_ARCH_VERSION /* add string supplement for "non-classic" architectures */
#endif

iVerMajor = _MSC_VER / 100;
iVerMinor = _MSC_VER % 100;

Expand Down Expand Up @@ -1313,7 +1317,10 @@ char * hb_verCompiler( void )
hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );
#endif

#if defined( HB_ARCH_16BIT )
#if defined( __HB_ARCH_VERSION )
hb_strncat( pszCompiler, " ", COMPILER_BUF_SIZE - 1 );
hb_strncat( pszCompiler, hb_verCPU(), COMPILER_BUF_SIZE - 1 );
#elif defined( HB_ARCH_16BIT )
hb_strncat( pszCompiler, " (16-bit)", COMPILER_BUF_SIZE - 1 );
#elif defined( HB_ARCH_32BIT )
hb_strncat( pszCompiler, " (32-bit)", COMPILER_BUF_SIZE - 1 );
Expand Down
3 changes: 3 additions & 0 deletions tests/speedtst.prg
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ return
#ifdef __HARBOUR__
#ifndef __XHARBOUR__
static function spd_cpu()
if right( hb_compiler(), len( spd_cpu() ) ) == spd_cpu()
return ""
endif
return hb_version( HB_VERSION_CPU )
#endif
#endif
Expand Down
40 changes: 24 additions & 16 deletions utils/hbmk2/hbmk2.prg
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
CASE "mingw64"
CASE "msvc"
CASE "msvc64"
CASE "msvcarm64"
CASE "msvcia64"
CASE "bcc"
CASE "bcc64"
Expand All @@ -1810,7 +1811,6 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
hbmk[ _HBMK_cPLAT ] := "win"
EXIT
CASE "mingwarm"
CASE "msvcarm"
CASE "poccarm"
hbmk[ _HBMK_cPLAT ] := "wce"
EXIT
Expand Down Expand Up @@ -1943,12 +1943,16 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
NIL, ;
FindInPath( "wcc386" ) ) }, "watcom" }, ;
{ {|| FindInPath( "clarm.exe" ) }, "msvcarm" }, ;
{ {|| FindInPath( "armasm.exe" ) }, "msvcarm" }, ;
{ {|| iif( FindInPath( "vctip.exe" ) == NIL, ;
FindInPath( "armasm.exe" ), ;
NIL ) }, "msvcarm",,, "wce" }, ;
{ {|| FindInPath( "armasm.exe" ) }, "msvcarm",,, "win" }, ;
{ {|| FindInPath( "armasm64.exe" ) }, "msvcarm64" }, ;
{ {|| FindInPath( "ml64.exe" ) }, "msvc64" }, ;
{ {|| FindInPath( "ias.exe" ) }, "msvcia64" }, ;
{ {|| iif( FindInPath( "wcc386" ) == NIL, ;
FindInPath( "cl.exe" ), ;
NIL ) }, "msvc" }, ;
NIL ) }, "msvc" }, ;
{ {|| _BCC_BIN_DETECT() }, "bcc" }, ; /* TODO: Add bcc64 auto-detection */
{ {|| iif( FindInPath( "dbgeng.lib", GetEnv( "LIB" ) ) != NIL .AND. ( tmp1 := FindInPath( "pocc.exe" ) ) != NIL, tmp1, NIL ) }, "pocc64" }, ;
{ {|| FindInPath( "pocc.exe" ) }, "pocc" }, ;
Expand All @@ -1960,7 +1964,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
#endif
aCOMPSUP := { ;
"mingw", "msvc", "clang", "bcc", "watcom", "icc", "pocc", "xcc", "tcc", ;
"mingw64", "msvc64", "msvcia64", "bcc64", "iccia64", "pocc64" }
"mingw64", "msvc64", "msvcarm", "msvcarm64", "msvcia64", "bcc64", "iccia64", "pocc64" }
l_aLIBHBGT := { "gtwin", "gtwvt", "gtgui" }
hbmk[ _HBMK_cGTDEFAULT ] := "gtwin"
hbmk[ _HBMK_cDynLibPrefix ] := ""
Expand Down Expand Up @@ -2323,7 +2327,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
hbmk[ _HBMK_nCOMPVer ] := 34
ENDCASE

CASE ( hbmk[ _HBMK_cPLAT ] == "win" .AND. HBMK_ISCOMP( "msvc|msvc64|msvcia64|icc|iccia64" ) ) .OR. ;
CASE ( hbmk[ _HBMK_cPLAT ] == "win" .AND. HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64|msvcia64|icc|iccia64" ) ) .OR. ;
( hbmk[ _HBMK_cPLAT ] == "wce" .AND. hbmk[ _HBMK_cCOMP ] == "msvcarm" ) /* NOTE: Cross-platform: wce/ARM on win/x86 */

/* Compatibility with Harbour GNU Make system */
Expand Down Expand Up @@ -5120,7 +5124,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
l_aLIBSHAREDPOST := { "hbmainstd", "hbmainwin" }
l_aLIBSYS := ArrayAJoin( { l_aLIBSYS, l_aLIBSYSCORE, l_aLIBSYSMISC } )

CASE ( hbmk[ _HBMK_cPLAT ] == "win" .AND. HBMK_ISCOMP( "msvc|msvc64|msvcia64|icc|iccia64" ) ) .OR. ;
CASE ( hbmk[ _HBMK_cPLAT ] == "win" .AND. HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64|msvcia64|icc|iccia64" ) ) .OR. ;
( hbmk[ _HBMK_cPLAT ] == "wce" .AND. hbmk[ _HBMK_cCOMP ] == "msvcarm" ) /* NOTE: Cross-platform: wce/ARM on win/x86 */

hbmk[ _HBMK_nCmd_FNF ] := _FNF_BCKSLASH
Expand Down Expand Up @@ -5250,10 +5254,11 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
SWITCH hbmk[ _HBMK_cCOMP ]
CASE "msvc" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:x86" ) ; EXIT
CASE "msvc64" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:x64" ) ; EXIT
CASE "msvcarm" ; AAdd( hbmk[ _HBMK_aOPTI ], IIF( hbmk[ _HBMK_cPLAT ] == "wce", "-machine:xarm", "-machine:arm" ) ) ; EXIT
CASE "msvcarm64"; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:arm64" ) ; EXIT
CASE "msvcia64" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:ia64" ) ; EXIT
CASE "icc" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:x86" ) ; EXIT
CASE "iccia64" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:ia64" ) ; EXIT
CASE "msvcarm" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:xarm" ) ; EXIT
CASE "msvcmips" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:mips" ) ; EXIT
CASE "msvcsh" ; AAdd( hbmk[ _HBMK_aOPTI ], "-machine:sh5" ) ; EXIT
ENDSWITCH
Expand Down Expand Up @@ -6173,7 +6178,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit
DO CASE
CASE ! hbmk[ _HBMK_lSHARED ] .OR. ;
! HBMK_ISPLAT( "win|wce" ) .OR. ;
HBMK_ISCOMP( "msvc|msvc64|msvcia64|icc|iccia64" )
HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64|msvcia64|icc|iccia64" )

/* NOTE: MSVC gives the warning:
"LNK4217: locally defined symbol ... imported in function ..."
Expand Down Expand Up @@ -9396,7 +9401,7 @@ STATIC FUNCTION FindLib( hbmk, cLib, aLIBPATH, cLibPrefix, cLibExt )
LOCAL tmp

/* Check libs in their full paths */
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm|bcc|bcc64|pocc|pocc64|poccarm|watcom" )
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64|bcc|bcc64|pocc|pocc64|poccarm|watcom" )
IF ! Empty( hb_FNameDir( cLib ) )
IF hb_FileExists( cLib := hb_FNameExtSet( cLib, cLibExt ) )
RETURN cLib
Expand All @@ -9411,7 +9416,7 @@ STATIC FUNCTION FindLib( hbmk, cLib, aLIBPATH, cLibPrefix, cLibExt )
ENDIF

/* Check in current dir */
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm|bcc|bcc64|pocc|pocc64|poccarm|watcom" )
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64|bcc|bcc64|pocc|pocc64|poccarm|watcom" )
IF ! Empty( tmp := LibExists( hbmk, "", cLib, cLibPrefix, cLibExt ) )
RETURN tmp
ENDIF
Expand All @@ -9428,7 +9433,7 @@ STATIC FUNCTION FindLib( hbmk, cLib, aLIBPATH, cLibPrefix, cLibExt )

#if 0
/* Check in certain other compiler specific locations. */
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm" )
IF HBMK_ISCOMP( "msvc|msvc64|msvcarm|msvcarm64" )
FOR EACH cDir IN hb_ATokens( GetEnv( "LIB" ), hb_osPathListSeparator(), .T., .T. )
IF ! Empty( cDir )
IF ! Empty( tmp := LibExists( hbmk, cDir, cLib, cLibPrefix, cLibExt ) )
Expand Down Expand Up @@ -12029,6 +12034,7 @@ STATIC PROCEDURE PlatformPRGFlags( hbmk, aOPTPRG )
AAdd( aDf, "__LITTLE_ENDIAN__" ) /* Windows is currently little-endian on all supported CPUs. */
IF hbmk[ _HBMK_cCOMP ] == "mingw64" .OR. ;
hbmk[ _HBMK_cCOMP ] == "msvc64" .OR. ;
hbmk[ _HBMK_cCOMP ] == "msvcarm64" .OR. ;
hbmk[ _HBMK_cCOMP ] == "pocc64" .OR. ;
hbmk[ _HBMK_cCOMP ] == "msvcia64" .OR. ;
hbmk[ _HBMK_cCOMP ] == "iccia64"
Expand Down Expand Up @@ -13034,6 +13040,8 @@ STATIC FUNCTION hbmk_CPU( hbmk )
hbmk[ _HBMK_cCOMP ] == "msvcarm" .OR. ;
hbmk[ _HBMK_cCOMP ] == "poccarm"
RETURN "arm"
CASE hbmk[ _HBMK_cCOMP ] == "msvcarm64"
RETURN "arm64"
CASE hbmk[ _HBMK_cCOMP ] == "msvcmips"
RETURN "mips"
CASE hbmk[ _HBMK_cCOMP ] == "msvcsh"
Expand Down Expand Up @@ -13089,7 +13097,7 @@ FUNCTION hbmk_KEYW( hbmk, cFileName, cKeyword, cValue, cOperator )
CASE "allwin" ; RETURN HBMK_ISPLAT( "win|wce" )
CASE "allgcc" ; RETURN HBMK_ISCOMP( "gcc|mingw|mingw64|mingwarm|djgpp|gccomf|clang|open64|pcc" )
CASE "allmingw" ; RETURN HBMK_ISCOMP( "mingw|mingw64|mingwarm" )
CASE "allmsvc" ; RETURN HBMK_ISCOMP( "msvc|msvc64|msvcia64|msvcarm" )
CASE "allmsvc" ; RETURN HBMK_ISCOMP( "msvc|msvc64|msvcia64|msvcarm|msvcarm64" )
CASE "allbcc" ; RETURN HBMK_ISCOMP( "bcc|bcc64" )
CASE "allpocc" ; RETURN HBMK_ISCOMP( "pocc|pocc64|poccarm" )
CASE "allicc" ; RETURN HBMK_ISCOMP( "icc|iccia64" )
Expand All @@ -13110,13 +13118,13 @@ FUNCTION hbmk_KEYW( hbmk, cFileName, cKeyword, cValue, cOperator )
IF ! HBMK_IS_IN( cKeyword, ;
"|win|wce|dos|os2" + ;
"|bsd|hpux|sunos|beos|qnx|android|vxworks|symbian|linux|darwin|cygwin|minix|aix" + ;
"|msvc|msvc64|msvcia64|msvcarm" + ;
"|msvc|msvc64|msvcia64|msvcarm|msvcarm64" + ;
"|pocc|pocc64|poccarm|xcc|tcc" + ;
"|mingw|mingw64|mingwarm|bcc|bcc64|watcom" + ;
"|gcc|gccomf|djgpp" + ;
"|hblib|hbdyn|hbdynvm|hbimplib|hbexe" + ;
"|icc|iccia64|clang|open64|sunpro|diab|pcc" + ;
"|x86|x86_64|ia64|arm|mips|sh" )
"|x86|x86_64|ia64|arm|arm64|mips|sh" )

/* handle pseudo-functions */
IF cOperator == "=" .AND. cValue != NIL
Expand Down Expand Up @@ -15810,7 +15818,7 @@ STATIC PROCEDURE ShowHelp( hbmk, lMore, lLong )
, ;
{ "linux" , "gcc, clang, icc, watcom, sunpro, open64" }, ;
{ "darwin" , "gcc, clang, icc" }, ;
{ "win" , "mingw, msvc, clang, bcc, bcc64, watcom, icc, pocc, xcc, mingw64, msvc64, msvcia64, iccia64, pocc64" }, ;
{ "win" , "mingw, msvc, clang, bcc, bcc64, watcom, icc, pocc, xcc, mingw64, msvc64, msvcarm, msvcarm64, msvcia64, iccia64, pocc64" }, ;
{ "wce" , "mingwarm, mingw, msvcarm, poccarm" }, ;
{ "os2" , "gcc, gccomf, watcom" }, ;
{ "dos" , "djgpp, watcom" }, ;
Expand Down Expand Up @@ -16202,7 +16210,7 @@ STATIC PROCEDURE ShowHelp( hbmk, lMore, lLong )
{ "{allwin}" , I_( "target platform is Windows compatible (win, wce)" ) }, ;
{ "{allgcc}" , I_( "target C compiler belongs to gcc family (gcc, mingw, mingw64, mingwarm, djgpp, gccomf, clang, open64, pcc)" ) }, ;
{ "{allmingw}" , I_( "target C compiler is mingw* (mingw, mingw64, mingwarm)" ) }, ;
{ "{allmsvc}" , I_( "target C compiler is msvc* (msvc, msvc64, msvcia64, msvcarm)" ) }, ;
{ "{allmsvc}" , I_( "target C compiler is msvc* (msvc, msvc64, msvcia64, msvcarm, msvcarm64)" ) }, ;
{ "{allbcc}" , I_( "target C compiler is bcc* (bcc, bcc64)" ) }, ;
{ "{allpocc}" , I_( "target C compiler is pocc* (pocc, pocc64, poccarm)" ) }, ;
{ "{allicc}" , I_( "target C compiler is icc* (icc, iccia64)" ) }, ;
Expand Down

0 comments on commit 26849d3

Please sign in to comment.