diff --git a/ChangeLog.txt b/ChangeLog.txt index a91480b9b4..6d64d42e11 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,31 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2025-01-02 14:33 UTC+0100 Aleksander Czajczynski (hb fki.pl) + * config/global.mk + * config/win/clang-noauto.mk + * config/win/clang.mk + * supplemented config for Windows clang cross compilers + distributed in multilib fashion, like Martin Storsjo's: + https://github.com/mstorsjo/llvm-mingw + + + HB_CCPREFIX= support for clang on Windows, you can build + ARM64 Harbour from AMD64 hosts using mentioned toolchain: + set PATH=C:\llvm-mingw\bin;%PATH% + set HB_COMPILER=clang + win-make (build for your host first) + set HB_CCPREFIX=aarch64-w64-mingw32- + set HB_HOST_BIN=\bin\win\clang\ (if not autodetected) + win-make + + ; cross compiling from Unix hosts is not yet tested, but + looks very close to be possible + + ! fixed typo's + + * utils/hbmk2/hbmk2.prg + * changed llvm-ar call to also respect HB_CCPREFIX + 2024-12-29 00:28 UTC+0100 Aleksander Czajczynski (hb fki.pl) * src/rtl/hbproces.c ! in process creating functions like hb_processRun(), *Open(), diff --git a/config/global.mk b/config/global.mk index 936317dbb1..b9429955cc 100644 --- a/config/global.mk +++ b/config/global.mk @@ -711,22 +711,24 @@ ifeq ($(HB_COMPILER),) endif endif else - HB_COMP_PATH := $(call find_in_path_raw,clang.exe) + HB_COMP_PATH := $(call find_in_path_raw,$(HB_CCPREFIX)clang$(HB_HOST_BIN_EXT)) HB_COMP_PWD := $(call dir_with_spaces,$(HB_COMP_PATH)) ifneq ($(HB_COMP_PATH),) HB_COMPILER := clang - ifneq ($(wildcard $(HB_COMP_PWD)aarch64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) - HB_CPU := arm64 - MSYSTEM := CLANGARM64 - else - ifneq ($(wildcard $(HB_COMP_PWD)x86_64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + # following $(HB_CCPREFIX)x86_64..., etc. looks wrong, but it's intentional + # the goal is to pacify this multilib env best guessing when HB_CCPREFIX= is set + ifneq ($(wildcard $(HB_COMP_PWD)$(HB_CCPREFIX)x86_64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) HB_CPU := x86_64 MSYSTEM := CLANG64 else - ifneq ($(wildcard $(HB_COMP_PWD)i686-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + ifneq ($(wildcard $(HB_COMP_PWD)$(HB_CCPREFIX)i686-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) HB_CPU := x86 MSYSTEM := CLANG32 else + ifneq ($(wildcard $(HB_COMP_PWD)$(HB_CCPREFIX)aarch64-w64-mingw32-clang$(HB_HOST_BIN_EXT)),) + HB_CPU := arm64 + MSYSTEM := CLANGARM64 + else ifneq ($(findstring /VC/Tools/Llvm/ARM64/,$(HB_COMP_PATH)),) MSYSTEM := HB_CPU := arm64 @@ -743,7 +745,7 @@ ifeq ($(HB_COMPILER),) HB_CPU := x86 MSYSTEM := CLANG32 else - MSYSTEM := $(shell clang --version) + MSYSTEM := $(shell $(HB_CCPREFIX)clang --version) ifneq ($(findstring x86_64-pc-windows-msvc,$(MSYSTEM)),) MSYSTEM := HB_CPU := x86_64 @@ -755,6 +757,7 @@ ifeq ($(HB_COMPILER),) ifneq ($(findstring aarch64-pc-windows-msvc,$(MSYSTEM)),) MSYSTEM := HB_CPU := arm64 + else ifneq ($(findstring x86_64-w64-windows-gnu,$(MSYSTEM)),) HB_CPU := x86_64 MSYSTEM := CLANG64 @@ -791,7 +794,7 @@ ifeq ($(HB_COMPILER),) ifeq ($(HB_CPU),x86_64) export HB_BUILD_NAME := 64 else - export HB_BUILD_NAME := HB_CPU + export HB_BUILD_NAME := $(HB_CPU) endif endif endif diff --git a/config/win/clang-noauto.mk b/config/win/clang-noauto.mk index 4bd552e4df..cef8e4e8a3 100644 --- a/config/win/clang-noauto.mk +++ b/config/win/clang-noauto.mk @@ -3,19 +3,23 @@ # in Harbour 3.2 gcc has priority over clang for backwards compatibility # supp. actions if the set HB_COMPILER=clang was specified, not auto-detected + ifneq ($(HB_COMPILER_ORI),) - HB_COMP_PATH := $(call find_in_path_raw,clang.exe) + HB_COMP_PATH := $(call find_in_path_raw,$(HB_CCPREFIX)clang$(HB_HOST_BIN_EXT)) HB_COMP_PWD := $(call dir_with_spaces,$(HB_COMP_PATH)) + ifneq ($(HB_COMP_PATH),) - ifneq ($(wildcard $(HB_COMP_PWD)../x86_64-w64-mingw32/lib/lib*.a),) + # following $(HB_CCPREFIX)x86_64..., etc. looks wrong, but it's intentional + # the goal is to pacify this multilib env best guessing when HB_CCPREFIX= is set + ifneq ($(wildcard $(HB_COMP_PWD)../$(HB_CCPREFIX)x86_64-w64-mingw32/lib/lib*.a),) MSYSTEM := CLANG64 HB_CPU := x86_64 else - ifneq ($(wildcard $(HB_COMP_PWD)../i686-w64-mingw32/lib/lib*.a),) + ifneq ($(wildcard $(HB_COMP_PWD)../$(HB_CCPREFIX)i686-w64-mingw32/lib/lib*.a),) MSYSTEM := CLANG32 HB_CPU := x86 else - ifneq ($(wildcard $(HB_COMP_PWD)../aarch64-w64-mingw32/lib/lib*.a),) + ifneq ($(wildcard $(HB_COMP_PWD)../$(HB_CCPREFIX)aarch64-w64-mingw32/lib/lib*.a),) MSYSTEM := CLANGARM64 HB_CPU := arm64 else @@ -34,7 +38,7 @@ ifneq ($(HB_COMPILER_ORI),) MSYSTEM := CLANG32 HB_CPU := x86 else - MSYSTEM := $(shell clang --version) + MSYSTEM := $(shell $(HB_CCPREFIX)clang --version) ifneq ($(findstring x86_64-pc-windows-msvc,$(MSYSTEM)),) MSYSTEM := HB_CPU := x86_64 @@ -46,6 +50,7 @@ ifneq ($(HB_COMPILER_ORI),) ifneq ($(findstring aarch64-pc-windows-msvc,$(MSYSTEM)),) MSYSTEM := HB_CPU := arm64 + else ifneq ($(findstring x86_64-w64-windows-gnu,$(MSYSTEM)),) HB_CPU := x86_64 MSYSTEM := CLANG64 @@ -82,7 +87,7 @@ ifneq ($(HB_COMPILER_ORI),) ifeq ($(HB_CPU),x86_64) export HB_BUILD_NAME := 64 else - export HB_BUILD_NAME := HB_CPU + export HB_BUILD_NAME := $(HB_CPU) endif endif endif diff --git a/config/win/clang.mk b/config/win/clang.mk index 7291aa4410..ca881587ea 100644 --- a/config/win/clang.mk +++ b/config/win/clang.mk @@ -15,7 +15,7 @@ endif HB_DYN_COPT := -DHB_DYNLIB -CC := $(HB_CCPATH)$(HB_CMP)$(HB_CCSUFFIX) +CC := $(HB_CCPATH)$(HB_CCPREFIX)$(HB_CMP)$(HB_CCSUFFIX) ifneq ($(filter --analyze, $(HB_USER_CFLAGS)),) CC_IN := else diff --git a/utils/hbmk2/hbmk2.prg b/utils/hbmk2/hbmk2.prg index dc5bce5588..060d65781a 100644 --- a/utils/hbmk2/hbmk2.prg +++ b/utils/hbmk2/hbmk2.prg @@ -135,7 +135,7 @@ 5. If HB_COMPILER is not set, use the highest one on the priority list. NOTES: - Priority list: HB_CCPATH, PATH, embedded. - - Priority list: mingw, msvc, bcc, watcom, pocc, xcc + - Priority list: mingw, clang, msvc, bcc, watcom, pocc, xcc - Compilers of native CPU target have higher priority. (extra) On x86_64 Windows: msvc64, msvc, msvcia64, mingw64, mingw, ... On x86 Windows: msvc, msvc64, msvcia64, mingw, mingw64, ... @@ -4458,7 +4458,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit ENDIF cImpLibExt := cLibLibExt IF hbmk[ _HBMK_cCOMP ] == "clang" - cBin_Lib := "llvm-ar.exe" + cBin_Lib := hbmk[ _HBMK_cCCPREFIX ] + "llvm-ar" + hbmk[ _HBMK_cCCEXT ] ELSEIF hbmk[ _HBMK_cCOMP ] == "tcc" cBin_Lib := "tiny_libmaker.exe" ELSE