diff --git a/config/cc/gcc.in b/config/cc/gcc.in index d5b19c79..37c79efa 100644 --- a/config/cc/gcc.in +++ b/config/cc/gcc.in @@ -180,9 +180,10 @@ config CC_GCC_USE_LTO config CC_GCC_LTO_ZSTD tristate prompt "Support LTO compression with zstd" - default m if !CANADIAN && !STATIC_TOOLCHAIN + default m depends on CC_GCC_USE_LTO depends on GCC_10_or_later + select ZSTD_NEEDED help Support zstd compression for LTO object files. This will require libzstd to be installed when using the toolchain diff --git a/config/comp_libs.in b/config/comp_libs.in index 6dd8099e..502e95a3 100644 --- a/config/comp_libs.in +++ b/config/comp_libs.in @@ -105,6 +105,11 @@ config ZLIB_NEEDED bool "Build local zlib" select COMP_LIBS_ZLIB +config ZSTD_NEEDED + bool "Build local zstd" + default y if CANADIAN || CROSS_NATIVE + select COMP_LIBS_ZSTD + # FIXME remove these legacy knobs config LIBICONV def_bool y @@ -150,4 +155,8 @@ config ZLIB def_bool y depends on ZLIB_NEEDED +config ZSTD + def_bool y + depends on ZSTD_NEEDED + endmenu diff --git a/config/comp_libs/zstd.in b/config/comp_libs/zstd.in new file mode 100644 index 00000000..fe7655e0 --- /dev/null +++ b/config/comp_libs/zstd.in @@ -0,0 +1 @@ +# Zstd options diff --git a/packages/zstd/1.5.2/chksum b/packages/zstd/1.5.2/chksum new file mode 100644 index 00000000..03b03a51 --- /dev/null +++ b/packages/zstd/1.5.2/chksum @@ -0,0 +1,4 @@ +md5 zlib-1.5.2.tar.gz 072b10f71f5820c24761a65f31f43e73 +sha1 zlib-1.5.2.tar.gz c56c8e6d703d14029464b2a1a66164dc5cf80855 +sha256 zlib-1.5.2.tar.gz 7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0 +sha512 zlib-1.5.2.tar.gz 96dbd2eb6623e3564a0fd36489b61bc3cb27758a584fdc9f064f3985d2e8b5605d7022890d00a6d15464d3cd0707d7e75d8cf6210323782d0af406b90a6d6784 \ No newline at end of file diff --git a/packages/zstd/1.5.2/version.desc b/packages/zstd/1.5.2/version.desc new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/packages/zstd/1.5.2/version.desc @@ -0,0 +1 @@ + diff --git a/packages/zstd/package.desc b/packages/zstd/package.desc new file mode 100644 index 00000000..2b9cdcd9 --- /dev/null +++ b/packages/zstd/package.desc @@ -0,0 +1,4 @@ +repository='git https://github.com/facebook/zstd.git' +mirrors='https://github.com/facebook/zstd/releases/download/v${CT_ZSTD_VERSION} https://www.zstd.net/' +archive_formats='.tar.gz' +signature_format='packed/.sig' 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