Skip to content

Commit

Permalink
2025-01-02 14:33 UTC+0100 Aleksander Czajczynski (hb fki.pl)
Browse files Browse the repository at this point in the history
  * 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=<HarbourPath>\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
  • Loading branch information
alcz committed Jan 2, 2025
1 parent a23ea49 commit 21ea321
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 18 deletions.
25 changes: 25 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=<HarbourPath>\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(),
Expand Down
21 changes: 12 additions & 9 deletions config/global.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions config/win/clang-noauto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/win/clang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions utils/hbmk2/hbmk2.prg
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 21ea321

Please sign in to comment.