external/harfbuzz/ExternalProject_harfbuzz.mk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
New commits: commit 56d64a40c1a257de817406130ca6551d0f3233bf Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Apr 24 08:03:47 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Apr 30 07:29:00 2025 +0200 harfbuzz: Honor USE_LD, don't force specific linker if unset With the harfbuzz build having been switched to meson in commit commit ae24fc8c639b230284f94e837497cd7919f79d21 Date: Tue Apr 8 12:19:31 2025 +0200 harfbuzz: migrate to meson , building harbuzz in my local Android build using an autogen.input containing --with-android-ndk=$HOME/Android/Sdk/ndk/28.0.13004108 --with-android-sdk=$HOME/Android/Sdk --with-distro=LibreOfficeAndroidX86_64 --enable-sal-log --enable-android-editing --with-external-tar=/home/michi/development/libreoffice-external --disable-ccache --with-jdk-home=/usr/lib/jvm/java-21-openjdk-amd64/ started to fail because it couldn't detect the linker to use. This is caused by `c_ld` and `cpp_ld` explicitly being set to the *compiler* command in `cross-file.txt` that meson evaluates which is then used by meson to set the *linker* to use via `-fuse-ld=<command>` for gcc or clang (see [1]). However, ccache or clang are not suitable to be used as linkers. Fix that problem by evaluating the USE_LD variable and using the linker set this way. (It is `USE_LD=-fuse-ld=lld` for above-mentioned Android build.) If it's not set, then having an empty `c_ld` and `cpp_ld` is fine and will result in no particular linker being forced, i.e. let meson use its default logic. Leaving it empty is also fine on Windows. Quoting Christian Lohmaier's comment [2]: > re windows: linker can be empty, it then would try link from the vsenv, > but for static libraries it defaults to using LIB / so in the case > for harfbuzz c_ld / cpp_ld are in fact ignored/unused. for this case > ar setting would be used to override. Also, replace "X86_64" by "x86_64" for the `cpu_family` to address the WARNING: Unknown CPU family X86_64, please report this at https://github.com/mesonbuild/meson/issues/new warning seen in the below output. Thanks to Christian Lohmaier on whose feedback on earlier versions of the Gerrit change this is heavily based! --------------------------------------------------------- Error seen previously with an `--enable-ccache` build, where `-fuse-ld=/usr/bin/ccache` would be used: $ make harfbuzz cd /home/michi/development/git/libreoffice-WORKTREE-android/external/harfbuzz && make -j 32 -rs [LOC] top level modules: harfbuzz WARNING: Unknown CPU family X86_64, please report this at https://github.com/mesonbuild/meson/issues/new The Meson build system Version: 1.7.0 Source dir: /home/michi/development/git/libreoffice-WORKTREE-android/workdir/UnpackedTarball/harfbuzz Build dir: /home/michi/development/git/libreoffice-WORKTREE-android/workdir/UnpackedTarball/harfbuzz/builddir Build type: cross build Project name: harfbuzz Project version: 11.0.1 meson.build:1:0: ERROR: Unable to detect linker for compiler `/usr/bin/ccache /home/michi/Android/Sdk/ndk/28.0.13004108/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target x86_64-linux-android21 -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments -Wl,--version -fuse-ld=/usr/bin/ccache` stdout: stderr: /usr/bin/ccache: unrecognized option '--hash-style=both' clang: error: linker command failed with exit code 1 (use -v to see invocation) [...] --------------------------------------------------------- Error seen previously with a `--disable-ccache build`, where `-fuse-ld=/home/michi/Android/Sdk/ndk/28.0.13004108/toolchains/llvm/prebuilt/linux-x86_64/bin/clang` would be used: $ make harfbuzz cd /home/michi/development/git/libreoffice-WORKTREE-android/external/harfbuzz && make -j 32 -rs [LOC] harfbuzz [UPK] harfbuzz-11.0.1.tar.xz [LOC] top level modules: harfbuzz [PAT] harfbuzz WARNING: Unknown CPU family X86_64, please report this at https://github.com/mesonbuild/meson/issues/new The Meson build system Version: 1.7.0 Source dir: /home/michi/development/git/libreoffice-WORKTREE-android/workdir/UnpackedTarball/harfbuzz Build dir: /home/michi/development/git/libreoffice-WORKTREE-android/workdir/UnpackedTarball/harfbuzz/builddir Build type: cross build Project name: harfbuzz Project version: 11.0.1 meson.build:1:0: ERROR: Unable to detect linker for compiler `/home/michi/Android/Sdk/ndk/28.0.13004108/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target x86_64-linux-android21 -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments -Wl,--version -fuse-ld=/home/michi/Android/Sdk/ndk/28.0.13004108/toolchains/llvm/prebuilt/linux-x86_64/bin/clang` stdout: Android (12896553, +pgo, +bolt, +lto, +mlgo, based on r530567c) clang version 19.0.0 (https://android.googlesource.com/toolchain/llvm-project 97a699bf4812a18fb657c2779f5296a4ab2694d2) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/michi/Android/Sdk/ndk/28.0.13004108/toolchains/llvm/prebuilt/linux-x86_64/bin stderr: clang: error: unknown argument: '--hash-style=both' clang: error: unknown argument: '--eh-frame-hdr' clang: error: unknown argument: '-m' clang: error: linker command failed with exit code 1 (use -v to see invocation) [...] [1] https://mesonbuild.com/Machine-files.html#binaries [2] https://gerrit.libreoffice.org/c/core/+/184459/comments/dbb124af_3c49b1e0 Change-Id: I0793d7cc3428a13a050b5989a9e326b1b80595f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184459 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/external/harfbuzz/ExternalProject_harfbuzz.mk b/external/harfbuzz/ExternalProject_harfbuzz.mk index ab09f2a96ad6..ee43a541aecc 100644 --- a/external/harfbuzz/ExternalProject_harfbuzz.mk +++ b/external/harfbuzz/ExternalProject_harfbuzz.mk @@ -21,20 +21,23 @@ $(eval $(call gb_ExternalProject_use_externals,harfbuzz,\ # We cannot use environment vars inside the meson cross-build file, # so we're going to have to generate one on-the-fly. # mungle variables into python list format -cross_c = '$(subst $(WHITESPACE),'$(COMMA)',$(strip $(gb_CC)))' -cross_cxx = '$(subst $(WHITESPACE),'$(COMMA)',$(strip $(gb_CXX)))' +python_listify = '$(subst $(WHITESPACE),'$(COMMA)',$(strip $(1)))' +cross_c = $(call python_listify,$(gb_CC)) +cross_cxx = $(call python_listify,$(gb_CXX)) +cross_ld := $(call python_listify,$(subst -fuse-ld=,,$(USE_LD))) + define gb_harfbuzz_cross_compile [binaries] c = [$(cross_c)] cpp = [$(cross_cxx)] -c_ld = [$(subst cl.exe,link.exe,$(cross_c))] -cpp_ld = [$(subst cl.exe,link.exe,$(cross_c))] +c_ld = [$(cross_ld)] +cpp_ld = [$(cross_ld)] ar = '$(AR)' strip = '$(STRIP)' # TODO: this is pretty ugly... [host_machine] system = '$(if $(filter WNT,$(OS)),windows,$(if $(filter MACOSX,$(OS)),darwin,$(if $(filter ANDROID,$(OS)),android,linux)))' -cpu_family = '$(RTL_ARCH)' +cpu_family = '$(subst X86_64,x86_64,$(RTL_ARCH))' cpu = '$(if $(filter x86,$(RTL_ARCH)),i686,$(if $(filter X86_64,$(RTL_ARCH)),x86_64,$(if $(filter AARCH64,$(RTL_ARCH)),aarch64,armv7)))' endian = '$(ENDIANNESS)' endef