From 77d37481beee4f964e90a0ad32bc2e127a6191f7 Mon Sep 17 00:00:00 2001 From: Aleksander Czajczynski Date: Mon, 7 Oct 2024 11:40:17 +0200 Subject: [PATCH] 2024-10-07 11:40 UTC+0200 Aleksander Czajczynski (hb fki.pl) * config/global.mk ! detect ARM64 CPU on Windows also under non-native shell (MSYS2 sh) * on unix also recognize aarch64 from uname * include/hbsetup.h * __MINGW64__ define is not x86_64 specific anymore * config/win/clang.mk * utils/hbmk2/hbmk2.prg * reworked Clang on Windows detection (ARM64, x86_64, x86), now it recognizes those flavours in PATH as distributed by MSYS2 project and also Visual Studio 2022 Build tools. Starting Harbour build process should be now possible both from MSYS2 shell (with the special note to use "make" command instead of "win-make" from sh) and regular batch script/cmd shell. Building on Clang distributed by MS x86_64: PATH=\BuildTools\VC\Tools\Llvm\x64\bin;%PATH% win-make Clang/MS ARM64: PATH=\BuildTools\VC\Tools\Llvm\ARM64\bin;%PATH% win-make Building on Clang x86_64 distributed by MSYS2 from cmd: PATH=C:\msys64\clang64\bin;%PATH% win-make Clang/MSYS ARM64 called from cmd: PATH=C:\msys64\clangarm64\bin;%PATH% win-make * src/common/hbver.c * patched clang version string builder to skip duplicate version number in some builds * append processor architecture to clang compiler string on non-Intel systems --- ChangeLog.txt | 43 +++++++ config/global.mk | 281 +++++++++++++++++++++++++----------------- config/win/clang.mk | 59 ++++++++- include/hbsetup.h | 2 +- src/common/hbver.c | 26 +++- utils/hbmk2/hbmk2.prg | 78 ++++++++---- 6 files changed, 337 insertions(+), 152 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3b9d553823..2754ccf4db 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,49 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2024-10-07 11:40 UTC+0200 Aleksander Czajczynski (hb fki.pl) + * config/global.mk + ! detect ARM64 CPU on Windows also under non-native shell (MSYS2 sh) + + * on unix also recognize aarch64 from uname + + * include/hbsetup.h + * __MINGW64__ define is not x86_64 specific anymore + + * config/win/clang.mk + * utils/hbmk2/hbmk2.prg + * reworked Clang on Windows detection (ARM64, x86_64, x86), + now it recognizes those flavours in PATH as distributed + by MSYS2 project and also Visual Studio 2022 Build tools. + + Starting Harbour build process should be now possible + both from MSYS2 shell (with the special note to use "make" + command instead of "win-make" from sh) and regular batch + script/cmd shell. + + Building on Clang distributed by MS x86_64: + PATH=\BuildTools\VC\Tools\Llvm\x64\bin;%PATH% + win-make + + Clang/MS ARM64: + PATH=\BuildTools\VC\Tools\Llvm\ARM64\bin;%PATH% + win-make + + Building on Clang x86_64 distributed by MSYS2 from cmd: + PATH=C:\msys64\clang64\bin;%PATH% + win-make + + Clang/MSYS ARM64 called from cmd: + PATH=C:\msys64\clangarm64\bin;%PATH% + win-make + + * src/common/hbver.c + * patched clang version string builder to skip duplicate version + number in some builds + + * append processor architecture to clang compiler string + on non-Intel systems + 2024-09-14 21:26 UTC+0200 Aleksander Czajczynski (hb fki.pl) * tests/speedtst.prg ! fix recursion bug i've made diff --git a/config/global.mk b/config/global.mk index 618360c63f..ead7c80c31 100644 --- a/config/global.mk +++ b/config/global.mk @@ -413,6 +413,7 @@ endif HB_HOST_CPU := ifeq ($(HB_HOST_PLAT),win) + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) HB_HOST_CPU := x86_64 else @@ -425,6 +426,9 @@ ifeq ($(HB_HOST_PLAT),win) ifeq ($(PROCESSOR_ARCHITEW6432),ARM64) HB_HOST_CPU := arm64 else + ifeq ($(PROCESSOR_ARCHITECTURE),ARM) + HB_HOST_CPU := arm + else ifeq ($(PROCESSOR_ARCHITECTURE),IA64) HB_HOST_CPU := ia64 else @@ -434,6 +438,18 @@ ifeq ($(HB_HOST_PLAT),win) endif endif endif + endif + + # workaround for MSYS2 distribution of MingW64 ARM environment for a while + # shell is not native and not 32-bit, therefore it tricks std detection + ifneq ($(HB_SHELL),nt) + ifneq ($(findstring ARM,$(PROCESSOR_IDENTIFIER)),) + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + HB_HOST_CPU := arm64 + endif + endif + endif + else ifneq ($(filter $(HB_HOST_PLAT),dos os2),) HB_HOST_CPU := x86 @@ -448,6 +464,9 @@ else ifneq ($(findstring Power,$(_UNAME_M)),) HB_HOST_CPU := ppc else + ifneq ($(findstring aarch64,$(_UNAME_M)),) + HB_HOST_CPU := arm64 + else ifneq ($(findstring arm64,$(_UNAME_M)),) HB_HOST_CPU := arm64 else @@ -502,6 +521,7 @@ else endif endif endif + endif endif endif @@ -688,65 +708,79 @@ ifeq ($(HB_COMPILER),) endif endif else - HB_COMP_PATH := $(call find_in_path,wcc386) + HB_COMP_PATH := $(call find_in_path,clang) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := watcom + HB_COMPILER = clang + ifneq ($(wildcard $(dir $(HB_COMP_PATH))aarch64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + HB_CPU := arm64 + ifeq ($(HB_BUILD_NAME),) + export HB_BUILD_NAME := arm64 + endif + ifneq ($(MSYSTEM),) + export MSYSTEM := CLANGARM64 + endif + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))x86_64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + HB_CPU := x86_64 + ifeq ($(HB_BUILD_NAME),) + export HB_BUILD_NAME := 64 + endif + ifneq ($(MSYSTEM),) + export MSYSTEM := CLANG64 + endif + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))i686-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + ifneq ($(MSYSTEM),) + export MSYSTEM := CLANG32 + endif + HB_CPU := x86 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))lldb-vscode$(HB_HOST_BIN_EXT)),) + export MSYSTEM := + endif + endif + endif + endif else - HB_COMP_PATH := $(call find_in_path_raw,clarm.exe) + HB_COMP_PATH := $(call find_in_path,wcc386) ifneq ($(HB_COMP_PATH),) - HB_COMPILER_VER := 1310 - HB_COMPILER := msvcarm - HB_PLATFORM := wce - HB_CPU := arm + HB_COMPILER := watcom else - HB_COMP_PATH := $(call find_in_path_raw,armasm.exe) + HB_COMP_PATH := $(call find_in_path_raw,clarm.exe) ifneq ($(HB_COMP_PATH),) + HB_COMPILER_VER := 1310 HB_COMPILER := msvcarm - HB_CPU := arm HB_PLATFORM := wce - ifneq ($(call find_in_path_raw,vctip.exe),) - HB_PLATFORM := win - endif + HB_CPU := arm else - HB_COMP_PATH := $(call find_in_path_raw,armasm64.exe) + HB_COMP_PATH := $(call find_in_path_raw,armasm.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := msvcarm64 - HB_PLATFORM := win - HB_CPU := arm64 + HB_COMPILER := msvcarm + HB_CPU := arm + HB_PLATFORM := wce + ifneq ($(call find_in_path_raw,vctip.exe),) + HB_PLATFORM := win + endif else - HB_COMP_PATH := $(call find_in_path_raw,idis.exe) + HB_COMP_PATH := $(call find_in_path_raw,armasm64.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := iccia64 - HB_CPU := ia64 + HB_COMPILER := msvcarm64 + HB_PLATFORM := win + HB_CPU := arm64 else - HB_COMP_PATH := $(call find_in_path_raw,icl.exe) + HB_COMP_PATH := $(call find_in_path_raw,idis.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := icc + HB_COMPILER := iccia64 + HB_CPU := ia64 else - HB_COMP_PATH := $(call find_in_path_raw,ml64.exe) + HB_COMP_PATH := $(call find_in_path_raw,icl.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := msvc64 - HB_CPU := x86_64 - ifneq ($(findstring 8/,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1400 - else - ifneq ($(findstring 9.0,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1500 - else - ifneq ($(findstring 10.0,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1600 - else - ifneq ($(findstring 11.0,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1700 - endif - endif - endif - endif + HB_COMPILER := icc else - HB_COMP_PATH := $(call find_in_path_raw,ias.exe) + HB_COMP_PATH := $(call find_in_path_raw,ml64.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := msvcia64 - HB_CPU := ia64 + HB_COMPILER := msvc64 + HB_CPU := x86_64 ifneq ($(findstring 8/,$(HB_COMP_PATH)),) HB_COMPILER_VER := 1400 else @@ -763,15 +797,10 @@ ifeq ($(HB_COMPILER),) endif endif else - HB_COMP_PATH := $(call find_in_path_raw,cl.exe) + HB_COMP_PATH := $(call find_in_path_raw,ias.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := msvc - ifneq ($(findstring VC98,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1200 - else - ifneq ($(findstring 2003,$(HB_COMP_PATH)),) - HB_COMPILER_VER := 1300 - else + HB_COMPILER := msvcia64 + HB_CPU := ia64 ifneq ($(findstring 8/,$(HB_COMP_PATH)),) HB_COMPILER_VER := 1400 else @@ -787,80 +816,106 @@ ifeq ($(HB_COMPILER),) endif endif endif - endif - endif else - # TODO: Add bcc64 autodetection - HB_COMP_PATH := $(call find_in_path_raw,bcc32.exe) + HB_COMP_PATH := $(call find_in_path_raw,cl.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := bcc + HB_COMPILER := msvc + ifneq ($(findstring VC98,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1200 + else + ifneq ($(findstring 2003,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1300 + else + ifneq ($(findstring 8/,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1400 + else + ifneq ($(findstring 9.0,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1500 + else + ifneq ($(findstring 10.0,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1600 + else + ifneq ($(findstring 11.0,$(HB_COMP_PATH)),) + HB_COMPILER_VER := 1700 + endif + endif + endif + endif + endif + endif else - HB_COMP_PATH := $(call find_in_path_raw,pocc.exe) + # TODO: Add bcc64 autodetection + HB_COMP_PATH := $(call find_in_path_raw,bcc32.exe) ifneq ($(HB_COMP_PATH),) - ifneq ($(call find_in_path_prw,coredll.lib,$(LIB)),) - HB_PLATFORM := wce - HB_COMPILER := poccarm - HB_CPU := arm - else - ifneq ($(call find_in_path_prw,dbgeng.lib,$(LIB)),) - HB_COMPILER := pocc64 - HB_CPU := x86_64 - else - HB_COMPILER := pocc - endif - endif + HB_COMPILER := bcc else - HB_COMP_PATH := $(call find_in_path_raw,xCC.exe) + HB_COMP_PATH := $(call find_in_path_raw,pocc.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := xcc + ifneq ($(call find_in_path_prw,coredll.lib,$(LIB)),) + HB_PLATFORM := wce + HB_COMPILER := poccarm + HB_CPU := arm + else + ifneq ($(call find_in_path_prw,dbgeng.lib,$(LIB)),) + HB_COMPILER := pocc64 + HB_CPU := x86_64 + else + HB_COMPILER := pocc + endif + endif else - HB_COMP_PATH := $(call find_in_path_raw,dmc.exe) + HB_COMP_PATH := $(call find_in_path_raw,xCC.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := dmc + HB_COMPILER := xcc else - # mingw-w64 build - HB_COMP_PATH := $(call find_in_path,i686-w64-mingw32-gcc) + HB_COMP_PATH := $(call find_in_path_raw,dmc.exe) ifneq ($(HB_COMP_PATH),) - HB_COMPILER := mingw64 - HB_CCPREFIX := i686-w64-mingw32- - HB_CPU := x86_64 - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.8*),) - HB_COMPILER_VER := 48 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.7*),) - HB_COMPILER_VER := 47 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.6*),) - HB_COMPILER_VER := 46 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.5*),) - HB_COMPILER_VER := 45 - endif - endif - endif - endif + HB_COMPILER := dmc else - ifeq ($(HB_HOST_CPU),x86_64) - # mingw-w64 build - HB_COMP_PATH := $(call find_in_path,x86_64-w64-mingw32-gcc) - ifneq ($(HB_COMP_PATH),) - HB_COMPILER := mingw64 - HB_CCPREFIX := x86_64-w64-mingw32- - HB_CPU := x86_64 - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.8*),) - HB_COMPILER_VER := 48 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.7*),) - HB_COMPILER_VER := 47 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.6*),) - HB_COMPILER_VER := 46 - else - ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.5*),) - HB_COMPILER_VER := 45 - endif - endif - endif + # mingw-w64 build + HB_COMP_PATH := $(call find_in_path,i686-w64-mingw32-gcc) + ifneq ($(HB_COMP_PATH),) + HB_COMPILER := mingw64 + HB_CCPREFIX := i686-w64-mingw32- + HB_CPU := x86_64 + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.8*),) + HB_COMPILER_VER := 48 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.7*),) + HB_COMPILER_VER := 47 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.6*),) + HB_COMPILER_VER := 46 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.5*),) + HB_COMPILER_VER := 45 + endif + endif + endif + endif + else + ifeq ($(HB_HOST_CPU),x86_64) + # mingw-w64 build + HB_COMP_PATH := $(call find_in_path,x86_64-w64-mingw32-gcc) + ifneq ($(HB_COMP_PATH),) + HB_COMPILER := mingw64 + HB_CCPREFIX := x86_64-w64-mingw32- + HB_CPU := x86_64 + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.8*),) + HB_COMPILER_VER := 48 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.7*),) + HB_COMPILER_VER := 47 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.6*),) + HB_COMPILER_VER := 46 + else + ifneq ($(wildcard $(dir $(HB_COMP_PATH))$(HB_CCPREFIX)gcc-4.5*),) + HB_COMPILER_VER := 45 + endif + endif + endif + endif endif endif endif diff --git a/config/win/clang.mk b/config/win/clang.mk index 6573664451..0c1aba9453 100644 --- a/config/win/clang.mk +++ b/config/win/clang.mk @@ -5,8 +5,13 @@ else endif OBJ_EXT := .o -LIB_PREF := lib -LIB_EXT := .a +ifeq ($(MSYSTEM),) + LIB_PREF := + LIB_EXT := .lib +else + LIB_PREF := lib + LIB_EXT := .a +endif HB_DYN_COPT := -DHB_DYNLIB @@ -45,14 +50,58 @@ LDLIBS := $(foreach lib,$(HB_USER_LIBS) $(LIBS) $(SYSLIBS),-l$(lib)) LDFLAGS += $(LIBPATHS) -AR := $(HB_CCPREFIX)ar -AR_RULE = ( $(AR) $(ARFLAGS) $(HB_AFLAGS) $(HB_USER_AFLAGS) rcs $(LIB_DIR)/$@ $(^F) $(ARSTRIP) ) || ( $(RM) $(LIB_DIR)/$@ && $(FALSE) ) +AR := $(HB_CCPREFIX)llvm-ar + +AR_RULE = ( $(AR) $(ARFLAGS) $(HB_AFLAGS) $(HB_USER_AFLAGS) rcs $(LIB_DIR)/$@ $(^F) $(ARSTRIP) ) || ( $(RM) $(subst /,$(DIRSEP),$(LIB_DIR)/$@) && $(FALSE) ) DY := $(CC) DFLAGS += -shared $(LIBPATHS) DY_OUT := -o$(subst x,x, ) DLIBS := $(foreach lib,$(HB_USER_LIBS) $(SYSLIBS),-l$(lib)) -DY_RULE = $(DY) $(DFLAGS) -Wl,-soname,$(DYN_NAME_CPT) $(HB_USER_DFLAGS) $(DY_OUT)$(DYN_DIR)/$@ $^ $(DLIBS) $(DYSTRIP) && $(LN) $(@F) $(DYN_FILE_NVR) && $(LN) $(@F) $(DYN_FILE_CPT) +ifeq ($(HB_SHELL),nt) + define dynlib_object + @$(ECHO) $(ECHOQUOTE)$(subst \,/,$(file)) $(ECHOQUOTE) >> __dyn__.tmp + + endef + ifneq ($(MSYSTEM),) + # no-op on MSYS under cmd.exe shell + define dynlib_ln + + endef + else + define dynlib_ln + $(LN) $(subst /,\,$(DYN_DIR)\$(LIB_PREF)$(basename $@)$(LIB_EXT)) $(subst /,\,$(LIB_DIR)\$(LIB_PREF)$(basename $@)$(LIB_EXT)) + endef + endif +else + define dynlib_object + @$(ECHO) -n $(ECHOQUOTE)$(subst \,/,$(file)) $(ECHOQUOTE) >> __dyn__.tmp + + endef + define dynlib_ln + $(LN) $(@F) $(DYN_FILE_NVR) && $(LN) $(@F) $(DYN_FILE_CPT) + endef +endif + +# clang distributed by MS uses lld-link, libs are *.lib not lib*.a +# in opposite MSYS/MinGW needs args to actually make an implib +ifeq ($(MSYSTEM),) + define create_dynlib + $(if $(wildcard __dyn__.tmp),@$(RM) __dyn__.tmp,) + $(foreach file,$^,$(dynlib_object)) + $(DY) $(DFLAGS) $(HB_USER_DFLAGS) $(DY_OUT)$(DYN_DIR)/$@ @__dyn__.tmp $(DLIBS) $(DYSTRIP) $(DYSTRIP) + $(dynlib_ln) + endef +else + define create_dynlib + $(if $(wildcard __dyn__.tmp),@$(RM) __dyn__.tmp,) + $(foreach file,$^,$(dynlib_object)) + $(DY) $(DFLAGS) $(HB_USER_DFLAGS) $(DY_OUT)$(DYN_DIR)/$@ @__dyn__.tmp $(DLIBS) -Wl,--out-implib,$(IMP_FILE),--output-def,$(DYN_DIR)/$(basename $@).def $(DYSTRIP) $(DYSTRIP) + $(dynlib_ln) + endef +endif + +DY_RULE = $(create_dynlib) include $(TOP)$(ROOT)config/rules.mk diff --git a/include/hbsetup.h b/include/hbsetup.h index 48395112c2..e3ee2343b6 100644 --- a/include/hbsetup.h +++ b/include/hbsetup.h @@ -148,7 +148,7 @@ defined( __x86_64 ) || \ defined( _M_AMD64 ) || \ defined( _M_X64 ) || \ - defined( __MINGW64__ ) + ( defined( __MINGW64__ ) && ! defined( __aarch64__ ) ) #define HB_CPU_X86_64 #elif defined( __arm64__ ) || \ diff --git a/src/common/hbver.c b/src/common/hbver.c index 7701eaffd0..441d99b087 100644 --- a/src/common/hbver.c +++ b/src/common/hbver.c @@ -1064,6 +1064,10 @@ char * hb_verCompiler( void ) iVerMinor = __clang_minor__; iVerPatch = __clang_patchlevel__; + #if ! defined( HB_CPU_X86 ) && ! defined( HB_CPU_X86_64 ) + #define __HB_ARCH_VERSION /* add string supplement for "non-classic" architectures */ + #endif + #elif defined( __clang__ ) pszName = "LLVM/Clang C"; @@ -1304,14 +1308,24 @@ char * hb_verCompiler( void ) hb_strncpy( pszCompiler, "(unknown)", COMPILER_BUF_SIZE - 1 ); #if defined( __clang_version__ ) - if( strstr( __clang_version__, "(" ) ) - /* "2.0 (trunk 103176)" -> "(trunk 103176)" */ - hb_snprintf( szSub, sizeof( szSub ), " %s", strstr( __clang_version__, "(" ) ); - else - hb_snprintf( szSub, sizeof( szSub ), " (%s)", __clang_version__ ); - hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 ); + #if defined( __clang_major__ ) + /* prevent dups like "LLVM/Clang C 18.1.8 (18.1.8 )" */ + hb_snprintf( szSub, sizeof( szSub ), "%d.%d.%d ", iVerMajor, iVerMinor, iVerPatch ); + if( ! strstr( szSub, __clang_version__ ) ) + { + #endif + if( strstr( __clang_version__, "(" ) ) + /* "2.0 (trunk 103176)" -> "(trunk 103176)" */ + hb_snprintf( szSub, sizeof( szSub ), " %s", strstr( __clang_version__, "(" ) ); + else + hb_snprintf( szSub, sizeof( szSub ), " (%s)", __clang_version__ ); + hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 ); + #if defined( __clang_major__ ) + } + #endif #endif + #if defined( __DJGPP__ ) hb_snprintf( szSub, sizeof( szSub ), " (DJGPP %i.%02i)", ( int ) __DJGPP__, ( int ) __DJGPP_MINOR__ ); hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 ); diff --git a/utils/hbmk2/hbmk2.prg b/utils/hbmk2/hbmk2.prg index e8f12c1450..cbe59d55fa 100644 --- a/utils/hbmk2/hbmk2.prg +++ b/utils/hbmk2/hbmk2.prg @@ -1939,6 +1939,9 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit { {|| FindInSamePath( "x86_64-w64-mingw32-gcc.exe", "gcc" ) }, "mingw64" }, ; /* mingw-w64 TDM build */ { {|| FindInPath( "x86_64-w64-mingw32-gcc" ) }, "mingw64", "x86_64-w64-mingw32-" }, ; /* mingw-w64 build */ { {|| FindInPath( hbmk[ _HBMK_cCCPREFIX ] + "gcc" + hbmk[ _HBMK_cCCSUFFIX ] ) }, "mingw" }, ; + { {|| FindInPath( "aarch64-w64-mingw32-clang" ) }, "clang" }, ; /* MSYS2 or mingw-w64 clang */ + { {|| FindInPath( "x86_64-w64-mingw32-clang" ) }, "clang" }, ; /* MSYS2 or mingw-w64 clang */ + { {|| FindInPath( "lldb-vscode.exe" ) }, "clang" }, ; /* Visual Studio Build Tools */ { {|| iif( Empty( GetEnv( "WATCOM" ) ), ; NIL, ; FindInPath( "wcc386" ) ) }, "watcom" }, ; @@ -3909,28 +3912,29 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit /* Command macros: - {LC} list of C files - {LR} list of resource source files (Windows specific) - {LS} list of resource binary files (Windows specific) - {LO} list of object files - {LA} list of object archive (.a) files - {LL} list of lib files - {LF} list of lib files (as flag) - {LB} list of lib files with paths - {FC} flags for C compiler (user + automatic) - {FL} flags for linker (user + automatic) - {FS} flags for code sign tool - {UT} url for timestamp (code sign tool) - {OW} working dir (when in -inc mode) - {OD} output dir - {OO} output object (when in -hbcmp mode) - {OE} output executable - {OM} output map name - {OI} output implib name - {DB} dir for binaries - {DI} dir for includes - {DL} dirs for libs - {SCRIPT} save command-line to script and pass it to command as @ + {LC} list of C files + {LR} list of resource source files (Windows specific) + {LS} list of resource binary files (Windows specific) + {LO} list of object files + {LA} list of object archive (.a) files + {LL} list of lib files + {LF} list of lib files (as flag) + {LB} list of lib files with paths + {FC} flags for C compiler (user + automatic) + {FL} flags for linker (user + automatic) + {FS} flags for code sign tool + {UT} url for timestamp (code sign tool) + {OW} working dir (when in -inc mode) + {OD} output dir + {OO} output object (when in -hbcmp mode) + {OE} output executable + {OM} output map name + {OI} output implib name + {DB} dir for binaries + {DI} dir for includes + {DL} dirs for libs + {SCRIPT} save command-line to script and pass it to command as @ + {ESCAPE_BS} escape backslashes in script */ /* Assemble library list */ @@ -4361,6 +4365,10 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit CASE hbmk[ _HBMK_cCOMP ] == "clang" cBin_CompCPP := hbmk[ _HBMK_cCCPREFIX ] + "clang++" + hbmk[ _HBMK_cCCSUFFIX ] + hbmk[ _HBMK_cCCEXT ] cBin_CompC := iif( hbmk[ _HBMK_lCPP ] != NIL .AND. hbmk[ _HBMK_lCPP ], cBin_CompCPP, hbmk[ _HBMK_cCCPREFIX ] + "clang" + hbmk[ _HBMK_cCCSUFFIX ] + hbmk[ _HBMK_cCCEXT ] ) + IF hb_fileExists( hb_DirSepAdd( hbmk[ _HBMK_cHB_INSTALL_LIB ] ) + "hbrtl.lib" ) /* selfcheck if clang ld emits .lib extension */ + cLibLibPrefix := "" + cLibLibExt := ".lib" + ENDIF CASE hbmk[ _HBMK_cCOMP ] == "tcc" cBin_CompCPP := "tcc.exe" cBin_CompC := cBin_CompCPP @@ -4427,7 +4435,9 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit AAddNotEmpty( hbmk[ _HBMK_aOPTCPPX ], gcc_opt_lngcpp_fill( hbmk ) ) cBin_Dyn := cBin_CompC cOpt_Dyn := "-shared -o {OD} {LO} {FD} {IM} {DL} {LS}" - IF ! hbmk[ _HBMK_cCOMP ] == "tcc" + IF hbmk[ _HBMK_cCOMP ] == "clang" + cOpt_Dyn += "{SCRIPT}{ESCAPE_BS}" + ELSEIF ! hbmk[ _HBMK_cCOMP ] == "tcc" cOpt_Dyn += "{SCRIPT_MINGW}" ENDIF cBin_Link := cBin_CompC @@ -4435,9 +4445,13 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit bBlk_ImpLib := {| cSourceDLL, cTargetLib, cFlags | win_implib_command_gcc( hbmk, hbmk[ _HBMK_cCCPREFIX ] + "dlltool" + hbmk[ _HBMK_cCCSUFFIX ] + hbmk[ _HBMK_cCCEXT ] + " {FI} -d {ID} -l {OL}", cSourceDLL, cTargetLib, cFlags ) } cLibPathPrefix := "-L" cLibPathSep := " " - cLibLibExt := ".a" + IF cLibLibExt == "" + cLibLibExt := ".a" + ENDIF cImpLibExt := cLibLibExt - IF hbmk[ _HBMK_cCOMP ] == "tcc" + IF hbmk[ _HBMK_cCOMP ] == "clang" + cBin_Lib := "llvm-ar.exe" + ELSEIF hbmk[ _HBMK_cCOMP ] == "tcc" cBin_Lib := "tiny_libmaker.exe" ELSE cBin_Lib := hbmk[ _HBMK_cCCPREFIX ] + "ar" + hbmk[ _HBMK_cCCEXT ] @@ -4487,8 +4501,14 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit AAdd( hbmk[ _HBMK_aOPTD ], "-Wl,-Map,{OM}" ) ENDIF IF hbmk[ _HBMK_lIMPLIB ] - AAdd( hbmk[ _HBMK_aOPTL ], "-Wl,--out-implib,{OI}" ) - AAdd( hbmk[ _HBMK_aOPTD ], "-Wl,--out-implib,{OI}" ) + IF ( ! hbmk[ _HBMK_cCOMP ] == "clang" .OR. ; /* selfcheck if clang ld is MinGW style */ + ! hb_fileExists( hb_DirSepAdd( hbmk[ _HBMK_cHB_INSTALL_LIB ] ) + "hbrtl.lib" ) ) + AAdd( hbmk[ _HBMK_aOPTL ], "-Wl,--out-implib,{OI}" ) + AAdd( hbmk[ _HBMK_aOPTD ], "-Wl,--out-implib,{OI}" ) + ELSE /* clang using lld-link on Windows has option similar to MS link */ + AAdd( hbmk[ _HBMK_aOPTL ], "-Wl,-implib:{OI}" ) + AAdd( hbmk[ _HBMK_aOPTD ], "-Wl,-implib:{OI}" ) + ENDIF ENDIF IF l_lLIBGROUPING .AND. HBMK_ISCOMP( "mingw|mingw64|mingwarm" ) AAdd( hbmk[ _HBMK_aOPTL ], "-Wl,--start-group {LL} {LB} {LF} -Wl,--end-group" ) @@ -7225,6 +7245,10 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit /* Handle moving the whole command-line to a script, if requested. */ IF Empty( cScriptFile ) .AND. "{SCRIPT}" $ cOpt_Dyn + IF "{ESCAPE_BS}" $ cOpt_Dyn + cOpt_Dyn := StrTran( cOpt_Dyn, "{ESCAPE_BS}" ) + cOpt_Dyn := StrTran( cOpt_Dyn, "\", "\\" ) + ENDIF fhnd := hb_FTempCreateEx( @cScriptFile, NIL, NIL, ".lnk" ) IF fhnd != F_ERROR FWrite( fhnd, StrTran( cOpt_Dyn, "{SCRIPT}" ) )