From 5884909b25bf9e870d7957447ecf45186b7733c0 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 10 May 2023 16:13:21 +0200 Subject: [PATCH 1/4] Add target aarch64_musl_* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have to mention that adding a new cross compiled target never seems so simple. --- kiwixbuild/dependencies/__init__.py | 1 + kiwixbuild/dependencies/arm_musl.py | 14 ++++ kiwixbuild/platforms/__init__.py | 1 + kiwixbuild/platforms/arm_musl.py | 114 ++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 kiwixbuild/dependencies/arm_musl.py create mode 100644 kiwixbuild/platforms/arm_musl.py diff --git a/kiwixbuild/dependencies/__init__.py b/kiwixbuild/dependencies/__init__.py index 70d5de8..24f68c9 100644 --- a/kiwixbuild/dependencies/__init__.py +++ b/kiwixbuild/dependencies/__init__.py @@ -5,6 +5,7 @@ from . import ( android_ndk, aria2, armhf, + arm_musl, docoptcpp, emsdk, flatpak, diff --git a/kiwixbuild/dependencies/arm_musl.py b/kiwixbuild/dependencies/arm_musl.py new file mode 100644 index 0000000..c7066ae --- /dev/null +++ b/kiwixbuild/dependencies/arm_musl.py @@ -0,0 +1,14 @@ +from .base import Dependency, ReleaseDownload, NoopBuilder +from kiwixbuild.utils import Remotefile + +class aarch64_musl_toolchain(Dependency): + dont_skip = True + neutral = True + name = "aarch64_musl" + + class Source(ReleaseDownload): + archive = Remotefile('aarch64-linux-musl-cross.tgz', + 'c909817856d6ceda86aa510894fa3527eac7989f0ef6e87b5721c58737a06c38', + 'https://musl.cc/aarch64-linux-musl-cross.tgz') + + Builder = NoopBuilder diff --git a/kiwixbuild/platforms/__init__.py b/kiwixbuild/platforms/__init__.py index b73ddbc..5222bd0 100644 --- a/kiwixbuild/platforms/__init__.py +++ b/kiwixbuild/platforms/__init__.py @@ -4,6 +4,7 @@ from .base import * from . import ( android, armhf, + arm_musl, flatpak, i586, ios, diff --git a/kiwixbuild/platforms/arm_musl.py b/kiwixbuild/platforms/arm_musl.py new file mode 100644 index 0000000..dc8ea10 --- /dev/null +++ b/kiwixbuild/platforms/arm_musl.py @@ -0,0 +1,114 @@ +from .base import PlatformInfo, MixedMixin + +from kiwixbuild.utils import pj +from kiwixbuild._global import get_target_step + + +class Aarch64MuslPlatformInfo(PlatformInfo): + build = 'aarch64_musl' + arch_full = 'aarch64-linux-musl' + toolchain_names = ['aarch64_musl'] + compatible_hosts = ['fedora', 'debian'] + libdir = "lib/aarch64-linux-musl" + + def get_cross_config(self): + return { + 'binaries': self.binaries, + 'exe_wrapper_def': '', + 'root_path': self.root_path, + 'extra_libs': [], + 'extra_cflags': ['-I{}'.format(include_dir) for include_dir in self.get_include_dirs()], + 'host_machine': { + 'system': 'linux', + 'lsystem': 'linux', + 'cpu_family': 'arm', + 'cpu': 'armhf', + 'endian': 'little', + 'abi': '' + } + } + + @property + def tlc_source(self): + return get_target_step(self.build, 'source') + + @property + def root_path(self): + return self.tlc_source.source_path + + @property + def binaries(self): + binaries = ((k,'{}-{}'.format(self.arch_full, v)) + for k, v in (('CC', 'gcc'), + ('CXX', 'g++'), + ('AR', 'ar'), + ('STRIP', 'strip'), + ('WINDRES', 'windres'), + ('RANLIB', 'ranlib'), + ('LD', 'ld'), + ('LDSHARED', 'g++ -shared') + ) + ) + binaries = {k:pj(self.root_path, 'bin', v) + for k,v in binaries} + binaries['PKGCONFIG'] = 'pkg-config' + return binaries + + @property + def exe_wrapper_def(self): + try: + which('qemu-arm') + except subprocess.CalledProcessError: + return "" + else: + return "exe_wrapper = 'qemu-arm'" + + @property + def configure_option(self): + return '--host={}'.format(self.arch_full) + + def get_bin_dir(self): + return [pj(self.root_path, 'bin')] + + def get_env(self): + env = super().get_env() + env['LD_LIBRARY_PATH'] = ':'.join([ + pj(self.root_path, self.arch_full, 'lib64'), + pj(self.root_path, 'lib'), + env['LD_LIBRARY_PATH'] + ]) + env['PKG_CONFIG_LIBDIR'] = pj(self.root_path, 'lib', 'pkgconfig') + env['QEMU_LD_PREFIX'] = pj(self.root_path, self.arch_full, "libc") + env['QEMU_SET_ENV'] = "LD_LIBRARY_PATH={}".format( + ':'.join([ + pj(self.root_path, self.arch_full, "lib"), + env['LD_LIBRARY_PATH'] + ])) + return env + + def set_comp_flags(self, env): + super().set_comp_flags(env) + env['CFLAGS'] = " -fPIC -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CFLAGS'] + env['CXXFLAGS'] = " -fPIC -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "+env['CXXFLAGS'] + + def set_compiler(self, env): + for k, v in self.binaries.items(): + env[k] = v + + def finalize_setup(self): + super().finalize_setup() + self.buildEnv.cmake_crossfile = self._gen_crossfile('cmake_cross_file.txt') + self.buildEnv.meson_crossfile = self._gen_crossfile('meson_cross_file.txt') + + +class Aarch64MuslDyn(Aarch64MuslPlatformInfo): + name = 'aarch64_musl_dyn' + static = False + +class Aarch64MuslStatic(Aarch64MuslPlatformInfo): + name = 'aarch64_musl_static' + static = True + +class Aarch64MuslMixed(MixedMixin('aarch64_musl_static'), Aarch64MuslPlatformInfo): + name = 'aarch64_musl_mixed' + static = False From 64a686effe140051bb41ad132e28b69fc8399951 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 10 May 2023 16:17:58 +0200 Subject: [PATCH 2/4] Build aarch64_musl on the CI. --- .github/scripts/build_definition.py | 3 +++ .github/workflows/ci.yml | 3 +++ .github/workflows/releaseNigthly.yml | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/.github/scripts/build_definition.py b/.github/scripts/build_definition.py index 073d55c..7a9675f 100644 --- a/.github/scripts/build_definition.py +++ b/.github/scripts/build_definition.py @@ -45,6 +45,9 @@ BUILD_DEF = """ | | aarch64_static | | | B | B | | | | aarch64_dyn | d | | B | B | | | | aarch64_mixed | B | | | | | + | | aarch64_musl_static| | | B | B | | + | | aarch64_musl_dyn | d | | B | B | | + | | aarch64_musl_mixed | B | | | | | | | win32_static | d | dB | dB | dB | | | | win32_dyn | d | dB | dB | dB | | | | i586_static | | | B | B | | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d35f98a..bddf776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ jobs: - aarch64_static - aarch64_dyn - aarch64_mixed + - aarch64_musl_static + - aarch64_musl_dyn + - aarch64_musl_mixed - i586_static - i586_dyn - android_arm diff --git a/.github/workflows/releaseNigthly.yml b/.github/workflows/releaseNigthly.yml index a1886de..831bd08 100644 --- a/.github/workflows/releaseNigthly.yml +++ b/.github/workflows/releaseNigthly.yml @@ -22,6 +22,8 @@ jobs: - armv8_mixed - aarch64_static - aarch64_mixed + - aarch64_musl_static + - aarch64_musl_mixed - win32_static - i586_static - android_arm @@ -53,6 +55,10 @@ jobs: image_variant: focal - target: aarch64_mixed image_variant: bionic + - target: aarch64_musl_static + image_variant: focal + - target: aarch64_musl_mixed + imagev_variant: focal - target: win32_static image_variant: f35 - target: i586_static From 1748f4819778167c62cc780bd8c8996353f61c38 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 10 May 2023 16:19:22 +0200 Subject: [PATCH 3/4] Publish aarch64_musl. --- .github/scripts/common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/scripts/common.py b/.github/scripts/common.py index 0aa2429..3654aec 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -49,6 +49,8 @@ PLATFORM_TO_RELEASE = { "armv8_mixed": "{os}-armv8".format(os=RELEASE_OS_NAME), "aarch64_static": "{os}-aarch64".format(os=RELEASE_OS_NAME), "aarch64_mixed": "{os}-aarch64{extra}".format(os=RELEASE_OS_NAME, extra=EXTRA_NAME), + "aarch64_musl_static": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME), + "aarch64_musl_mixed": "{os}-aarch64-musl".format(os=RELEASE_OS_NAME), "i586_static": "{os}-i586".format(os=RELEASE_OS_NAME), "macOS_arm64_static": "{os}-arm64".format(os=RELEASE_OS_NAME), "macOS_arm64_mixed": "{os}-arm64".format(os=RELEASE_OS_NAME), From 7cdffbe22fb4ab6a669c7db85d0e9336fb87f2fe Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 7 Jun 2023 16:17:33 +0200 Subject: [PATCH 4/4] Correctly add toolchains in deps archives. --- .github/scripts/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/common.py b/.github/scripts/common.py index 3654aec..a9192df 100644 --- a/.github/scripts/common.py +++ b/.github/scripts/common.py @@ -303,7 +303,7 @@ def make_deps_archive(target=None, name=None, full=False): files_to_archive += HOME.glob("BUILD_*/android-ndk*") files_to_archive += HOME.glob("BUILD_*/emsdk*") if PLATFORM_TARGET.startswith("aarch64"): - files_to_archive += (SOURCE_DIR / "aarch64").glob("*") + files_to_archive += SOURCE_DIR.glob("aarch64*/*") if PLATFORM_TARGET.startswith("armv"): files_to_archive += SOURCE_DIR.glob("armv*/*") if (BASE_DIR / "meson_cross_file.txt").exists():