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=<InstallPath>\BuildTools\VC\Tools\Llvm\x64\bin;%PATH%
      win-make

      Clang/MS ARM64:
      PATH=<InstallPath>\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
This commit is contained in:
Aleksander Czajczynski
2024-10-07 11:40:17 +02:00
parent 1044334a0d
commit 77d37481be
6 changed files with 343 additions and 158 deletions

View File

@@ -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
else
HB_COMP_PATH := $(call find_in_path_raw,clarm.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER_VER := 1310
HB_COMPILER := msvcarm
HB_PLATFORM := wce
HB_CPU := arm
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
HB_COMP_PATH := $(call find_in_path_raw,armasm.exe)
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,wcc386)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := watcom
else
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
else
HB_COMP_PATH := $(call find_in_path_raw,pocc.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 := msvc
ifneq ($(findstring VC98,$(HB_COMP_PATH)),)
HB_COMPILER_VER := 1200
else
HB_COMP_PATH := $(call find_in_path_raw,xCC.exe)
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
# TODO: Add bcc64 autodetection
HB_COMP_PATH := $(call find_in_path_raw,bcc32.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := bcc
else
HB_COMP_PATH := $(call find_in_path_raw,pocc.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := xcc
else
HB_COMP_PATH := $(call find_in_path_raw,dmc.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := dmc
ifneq ($(call find_in_path_prw,coredll.lib,$(LIB)),)
HB_PLATFORM := wce
HB_COMPILER := poccarm
HB_CPU := arm
else
# 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-
ifneq ($(call find_in_path_prw,dbgeng.lib,$(LIB)),)
HB_COMPILER := pocc64
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
HB_COMPILER := pocc
endif
endif
else
HB_COMP_PATH := $(call find_in_path_raw,xCC.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := xcc
else
HB_COMP_PATH := $(call find_in_path_raw,dmc.exe)
ifneq ($(HB_COMP_PATH),)
HB_COMPILER := dmc
else
# 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

View File

@@ -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