diff --git a/.github/matrix_container.json b/.github/matrix_container.json index 23ae503..102e5bd 100644 --- a/.github/matrix_container.json +++ b/.github/matrix_container.json @@ -29,6 +29,11 @@ "arch": "armv7", "info": "musleabihf" }, + { + "platform": "linux", + "arch": "armv7", + "info": "uclibceabihf" + }, { "platform": "win-mingw", "arch": "amd64" diff --git a/.github/workflows/_matrix.yml b/.github/workflows/_matrix.yml index 7cb8140..71beec9 100644 --- a/.github/workflows/_matrix.yml +++ b/.github/workflows/_matrix.yml @@ -29,7 +29,7 @@ on: required: false type: string container_vers: - default: "20260710T070440Z-9115325" + default: "20260731T142118Z-44014fd" required: false type: string diff --git a/build_v2.py b/build_v2.py index 351d04a..c498143 100755 --- a/build_v2.py +++ b/build_v2.py @@ -344,14 +344,14 @@ def _setctx_linux( x.loge(f'unsupported target arch: {state.target_arch}') state.target_info = x.detect_libc_runtime() - state.cc.extend(['clang']) + state.cc.extend(['clang', '-march=native']) state.ar.extend(['llvm-ar']) state.nm.extend(['llvm-nm']) state.ldflags.extend(['-fuse-ld=lld']) state.objcopy.extend(['llvm-objcopy']) - x.ENVIRON['CC'] = 'clang' - x.ENVIRON['CXX'] = 'clang++' + x.ENVIRON['CC'] = 'clang -march=native' + x.ENVIRON['CXX'] = 'clang++ -march=native' x.ENVIRON['LDFLAGS'] = '-fuse-ld=lld' else: CROSS_TOOLCHAIN_ROOT = x.get_cross_toolchain_dir(state.target_plat) @@ -359,16 +359,30 @@ def _setctx_linux( state.target_arch = _tuple[2] state.target_info = _tuple[3] state.llvm_triple = { - 'arm64': f'aarch64-unknown-linux-{state.target_info}', - 'amd64': f'x86_64-pc-linux-{state.target_info}', - 'armv7': f'arm-unknown-linux-{state.target_info}', + 'arm64': f'aarch64-unknown-linux', + 'amd64': f'x86_64-pc-linux', + 'armv7': f'arm-unknown-linux', }[state.target_arch] - _sysroot = (Path(CROSS_TOOLCHAIN_ROOT) / state.llvm_triple).absolute().resolve().as_posix() + + _sysroot_triple = f'{state.llvm_triple}-{state.target_info}' + _sysroot = (Path(CROSS_TOOLCHAIN_ROOT) / _sysroot_triple).absolute().resolve().as_posix() + + _dynamic_linker = { + 'arm64-gnu': f'/lib/ld-linux-aarch64.so.1', + 'amd64-gnu': f'/lib64/ld-linux-x86-64.so.2', + 'armv7-gnueabihf': f'/lib/ld-linux-armhf.so.3', + 'arm64-musl': f'/lib/ld-musl-aarch64.so.1', + 'amd64-musl': f'/lib/ld-musl-x86_64.so.1', + 'armv7-musleabihf': f'/lib/ld-musl-armhf.so.1', + 'armv7-uclibceabihf': f'/lib/ld-uClibc.so.1', + }[f'{state.target_arch}-{state.target_info}'] + state.ldflags.append(f'-Wl,--dynamic-linker={_dynamic_linker}') state.cc.extend([ f'clang', f'--target={state.llvm_triple}', f'--gcc-toolchain={_sysroot}/usr', + f'--gcc-triple={_sysroot_triple}', f'--sysroot={_sysroot}' ]) if state.target_arch == 'amd64': @@ -383,13 +397,13 @@ def _setctx_linux( state.objcopy.extend(['llvm-objcopy']) # pkgconf - state.pkgconf.extend([f'{CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper.{state.llvm_triple}']) + state.pkgconf.extend([f'{CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper.{state.target_arch}-{state.target_info}']) # cmake toolchain file - state.extra_cmake.extend(["-D", f"CMAKE_TOOLCHAIN_FILE='{CROSS_TOOLCHAIN_ROOT}/crossfile.cmake.{state.llvm_triple}'"]) + state.extra_cmake.extend(["-D", f"CMAKE_TOOLCHAIN_FILE='{CROSS_TOOLCHAIN_ROOT}/crossfile.cmake.{state.target_arch}-{state.target_info}'"]) # meson toolchain file - state.extra_meson.extend(["--cross-file", f"{CROSS_TOOLCHAIN_ROOT}/crossfile.meson.{state.llvm_triple}"]) - if (meson_sccache := x.meson_compiler_cache_generate(state.compiler_cache)): - state.extra_meson.extend(["--cross-file", meson_sccache.as_posix()]) + state.extra_meson.extend(["--cross-file", f"{CROSS_TOOLCHAIN_ROOT}/crossfile.meson.{state.target_arch}-{state.target_info}"]) + if (meson_compiler_cache := x.meson_compiler_cache_generate(state.compiler_cache)): + state.extra_meson.extend(["--cross-file", meson_compiler_cache.as_posix()]) def _setctx_apple( state: _state, _native: "bool", _tuple: "tuple[str, ...]", ): @@ -449,8 +463,8 @@ def _setctx_apple( state.extra_cmake.extend(['-D', f'PKG_CONFIG_EXECUTABLE={pkgconf_wrapper.as_posix()}']) # meson toolchain file state.extra_meson.extend(["--cross-file", meson_crossfile.as_posix()]) - if (meson_sccache := x.meson_compiler_cache_generate(state.compiler_cache)): - state.extra_meson.extend(["--cross-file", meson_sccache.as_posix()]) + if (meson_compiler_cache := x.meson_compiler_cache_generate(state.compiler_cache)): + state.extra_meson.extend(["--cross-file", meson_compiler_cache.as_posix()]) def _setctx_win32_mingw( state: _state, _native: "bool", _tuple: "tuple[str, ...]", ): @@ -484,8 +498,8 @@ def _setctx_win32_mingw( state.extra_cmake.extend(["-D", f"CMAKE_TOOLCHAIN_FILE='{CROSS_TOOLCHAIN_ROOT}/crossfile.cmake.{state.target_arch}'"]) # meson toolchain file state.extra_meson.extend(["--cross-file", f"{CROSS_TOOLCHAIN_ROOT}/crossfile.meson.{state.target_arch}"]) - if (meson_sccache := x.meson_compiler_cache_generate(state.compiler_cache)): - state.extra_meson.extend(["--cross-file", meson_sccache.as_posix()]) + if (meson_compiler_cache := x.meson_compiler_cache_generate(state.compiler_cache)): + state.extra_meson.extend(["--cross-file", meson_compiler_cache.as_posix()]) def _setctx_win32_msvc( state: _state, _native: "bool", _tuple: "tuple[str, ...]", ): @@ -596,8 +610,10 @@ def _setctx_android( state.extra_cmake.extend(['-D', f"PKG_CONFIG_EXECUTABLE:STRING='{' '.join(state.pkgconf)}'"]) # meson toolchain file state.extra_meson.extend(["--cross-file", f"{ANDROID_NDK_ROOT}/crossfile.meson.{state.target_arch}-{state.target_info}"]) - if (meson_sccache := x.meson_compiler_cache_generate(state.compiler_cache)): - state.extra_meson.extend(["--cross-file", meson_sccache.as_posix()]) + meson_android_api_lv = x.meson_android_api_lv_generate(state.android_api_level); \ + state.extra_meson.extend(["--cross-file", meson_android_api_lv.as_posix()]) + if (meson_compiler_cache := x.meson_compiler_cache_generate(state.compiler_cache)): + state.extra_meson.extend(["--cross-file", meson_compiler_cache.as_posix()]) # ---------------------------- class TargetSpec(TypedDict): native: "bool" @@ -617,6 +633,7 @@ class TargetSpec(TypedDict): ('linux', 'crossbuild', 'amd64', 'musl'), ('linux', 'crossbuild', 'arm64', 'musl'), ('linux', 'crossbuild', 'armv7', 'musleabihf'), + ('linux', 'crossbuild', 'armv7', 'uclibceabihf'), ], }, 'macosx': { diff --git a/modules/sqlite3.py b/modules/sqlite3.py index ca69dbe..54eebc4 100755 --- a/modules/sqlite3.py +++ b/modules/sqlite3.py @@ -70,7 +70,7 @@ def _build_step_0(): '-std=c11', '-fPIC', '-Wall', '-Wextra', '-shared', '-v', '-O3', '-DNDEBUG', '-ffunction-sections', '-fdata-sections', - '-pthread', '-Wl,--strip-all', + '-pthread', ] output = (Path(ctx.args.pkg_inst_dir)) @@ -78,6 +78,7 @@ def _build_step_0(): output = (output / 'lib' / 'libsqlite3.so'); \ output.parent.mkdir(parents=True, exist_ok=True) args.extend([ + '-Wl,--strip-all', '-Wl,--gc-sections', '-Wl,--build-id', '-Wl,--icf=safe', '-Wl,-rpath,$ORIGIN', '-o', output.as_posix(), f'-Wl,--soname={output.name}', '-lm', @@ -88,7 +89,7 @@ def _build_step_0(): output = (output / 'lib' / 'libsqlite3.dylib'); \ output.parent.mkdir(parents=True, exist_ok=True) args.extend([ - '-Wl,-dead_strip', + '-Wl,-s,-dead_strip', '-o', output.as_posix(), '-install_name', output.name, ]) args.extend([ diff --git a/x_utils.py b/x_utils.py index ed2d93f..dd61539 100644 --- a/x_utils.py +++ b/x_utils.py @@ -368,7 +368,16 @@ def meson_compiler_cache_generate(compiler_cache: str) -> "Path | None": [constants] ccache = ['{compiler_cache}'] ''' - if not meson_crossfile.exists(): - _ = meson_crossfile.write_text(meson_crossfile_content) + _ = meson_crossfile.write_text(meson_crossfile_content) + return meson_crossfile + +def meson_android_api_lv_generate(android_api_lv: int) -> "Path": + meson_crossfile = (Path(PROJ_ROOT) / 'tmp' / f'.meson_android_api_lv.ini'); \ + meson_crossfile.parent.mkdir(parents=True, exist_ok=True) + meson_crossfile_content = f'''\ +[constants] +android_api_level = '{android_api_lv}' +''' + _ = meson_crossfile.write_text(meson_crossfile_content) return meson_crossfile # ----------------------------