aboutsummaryrefslogtreecommitdiff
path: root/scripts/build
diff options
context:
space:
mode:
authorQuentin Boswank <62326551+QBos07@users.noreply.github.com>2023-02-04 15:23:40 +0000
committerChris Packham <judge.packham@gmail.com>2023-02-08 17:13:42 +1300
commit4cba29946029391a8eced017f65acb6407e0bf23 (patch)
tree7dd98667eab2d782222db7054b4bbb007286f208 /scripts/build
parent0ce5b27385e35d610317ee1baa9b38dfa564b1f0 (diff)
downloadcrosstool-ng-4cba29946029391a8eced017f65acb6407e0bf23.tar.gz
crosstool-ng-4cba29946029391a8eced017f65acb6407e0bf23.tar.bz2
crosstool-ng-4cba29946029391a8eced017f65acb6407e0bf23.zip
Add zstd to the companion libs
Add zstd to the companion libs witch allows to use lto zstd compression in a canadian or cross-native enviroment Signed-off-by: QBos07 <62326551+QBos07@users.noreply.github.com> Signed-off-by: Quentin Boswank <62326551+QBos07@users.noreply.github.com>
Diffstat (limited to 'scripts/build')
-rw-r--r--scripts/build/cc/gcc.sh2
-rw-r--r--scripts/build/companion_libs/070-zstd.sh102
2 files changed, 103 insertions, 1 deletions
diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh
index 18558533..6eeda28d 100644
--- a/scripts/build/cc/gcc.sh
+++ b/scripts/build/cc/gcc.sh
@@ -1087,7 +1087,7 @@ do_gcc_backend() {
extra_config+=("--disable-lto")
fi
case "${CT_CC_GCC_LTO_ZSTD}" in
- y) extra_config+=("--with-zstd");;
+ y) extra_config+=("--with-zstd=${complibs}");;
m) ;;
*) extra_config+=("--without-zstd");;
esac
diff --git a/scripts/build/companion_libs/070-zstd.sh b/scripts/build/companion_libs/070-zstd.sh
new file mode 100644
index 00000000..bc334142
--- /dev/null
+++ b/scripts/build/companion_libs/070-zstd.sh
@@ -0,0 +1,102 @@
+# This file adds the functions to build the zstd library
+# Copyright 2023 Q. BOSWANK
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_zstd_get() { :; }
+do_zstd_extract() { :; }
+do_zstd_for_build() { :; }
+do_zstd_for_host() { :; }
+do_zstd_for_target() { :; }
+
+# Overide functions depending on configuration
+if [ "${CT_ZSTD}" = "y" ]; then
+
+# Download zstd
+do_zstd_get() {
+ CT_Fetch ZSTD
+}
+
+# Extract zstd
+do_zstd_extract() {
+ CT_ExtractPatch ZSTD
+}
+
+# Build zstd for running on build
+# - always build statically
+# - install in build-tools prefix
+do_zstd_for_build() {
+ local -a zstd_opts
+
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross) return 0;;
+ esac
+
+ CT_DoStep INFO "Installing zstd for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-zstd-build-${CT_BUILD}"
+
+ zstd_opts+=( "host=${CT_BUILD}" )
+ zstd_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ zstd_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ zstd_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
+
+ do_zstd_backend "${zstd_opts[@]}"
+
+ CT_Popd
+ CT_EndStep
+}
+
+# Build ZSTD zstd running on host
+do_zstd_for_host() {
+ local -a zstd_opts
+
+ CT_DoStep INFO "Installing zstd for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-zstd-host-${CT_HOST}"
+
+ zstd_opts+=( "host=${CT_HOST}" )
+ zstd_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
+ zstd_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ zstd_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+ do_zstd_backend "${zstd_opts[@]}"
+
+ CT_Popd
+ CT_EndStep
+}
+
+# Build zstd
+# Parameter : description : type : default
+# host : machine to run on : tuple : (none)
+# prefix : prefix to install into : dir : (none)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
+do_zstd_backend() {
+ local host
+ local prefix
+ local cflags
+ local ldflags
+ local arg
+ local -a extra_config
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Building zstd"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C "${CT_SRC_DIR}/zstd/lib" libzstd.a BUILD_DIR="${PWD}" CC="${host}-gcc" AS="${host}-as" CFLAGS="${cflags}" LDFLAGS="${ldflags}"
+
+ # TODO: Has to be tested
+
+ #if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
+ # if [ "${host}" = "${CT_BUILD}" ]; then
+ # CT_DoLog EXTRA "Checking zstd"
+ # CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
+ # else
+ # # Cannot run host binaries on build in a canadian cross
+ # CT_DoLog EXTRA "Skipping check for zstd on the host"
+ # fi
+ #fi
+
+ CT_DoLog EXTRA "Installing zstd"
+ CT_DoExecLog ALL make -C "${CT_SRC_DIR}/zstd/lib" install-static install-includes BUILD_DIR="${PWD}" PREFIX="$prefix"
+}
+
+fi # CT_ZSTD