mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-24 22:04:19 +08:00
Allow fallback to static builds on targets with broken dynamic linking
This commit is contained in:
parent
00ff0c5ff9
commit
5064d0e02e
@ -9,12 +9,8 @@ autotools_recursive_regenerate
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
DYNAMIC_STATIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(
|
||||
--without-docbook
|
||||
--without-examples
|
||||
--without-tests
|
||||
|
||||
@ -13,12 +13,6 @@ autotools_recursive_regenerate -I$(realpath ./m4)
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
)
|
||||
DYNAMIC_STATIC_INIT
|
||||
cookbook_configure
|
||||
"""
|
||||
@ -19,12 +19,8 @@ autotools_recursive_regenerate -I$(realpath ./m4) -I$(realpath ./srcm4)
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
DYNAMIC_STATIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(
|
||||
ac_cv_have_decl_program_invocation_name=no
|
||||
)
|
||||
cookbook_configure
|
||||
|
||||
@ -12,12 +12,6 @@ autotools_recursive_regenerate
|
||||
template = "custom"
|
||||
dependencies = ["zlib"]
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
)
|
||||
DYNAMIC_STATIC_INIT
|
||||
cookbook_configure
|
||||
"""
|
||||
|
||||
@ -13,12 +13,8 @@ dependencies = [
|
||||
"zlib"
|
||||
]
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
DYNAMIC_STATIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(
|
||||
--without-python
|
||||
)
|
||||
cookbook_configure
|
||||
|
||||
@ -12,12 +12,6 @@ patches = [
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
)
|
||||
DYNAMIC_STATIC_INIT
|
||||
cookbook_configure
|
||||
"""
|
||||
|
||||
@ -9,12 +9,6 @@ autotools_recursive_regenerate
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
)
|
||||
DYNAMIC_STATIC_INIT
|
||||
cookbook_configure
|
||||
"""
|
||||
|
||||
@ -6,9 +6,20 @@ blake3 = "ec1abc6f672a7a6ee6f49ba544cc9529f73121b478310473be44fee22a140ebf"
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(--prefix="/usr")
|
||||
if [ "${COOKBOOK_DYNAMIC}" == "1" ]
|
||||
then
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(--shared)
|
||||
else
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(--static)
|
||||
fi
|
||||
# See https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar.
|
||||
CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" --prefix="/usr"
|
||||
env CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}"
|
||||
"${COOKBOOK_MAKE}" -j "$(nproc)"
|
||||
"${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}"
|
||||
patchelf --set-soname 'libz.so.1.3' "${COOKBOOK_STAGE}/usr/lib/libz.so.1.3"
|
||||
solib="${COOKBOOK_STAGE}/usr/lib/libz.so.1.3"
|
||||
if [ -e "${solib}" ]
|
||||
then
|
||||
patchelf --set-soname 'libz.so.1.3' "${solib}"
|
||||
fi
|
||||
"""
|
||||
@ -23,10 +23,8 @@ dependencies = [
|
||||
"libiconv"
|
||||
]
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
DYNAMIC_STATIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(
|
||||
--enable-static
|
||||
--enable-shared
|
||||
ac_cv_have_decl_program_invocation_name=no
|
||||
gt_cv_locale_fr=false
|
||||
gt_cv_locale_fr_utf8=false
|
||||
|
||||
@ -9,16 +9,12 @@ autotools_recursive_regenerate
|
||||
[build]
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
DYNAMIC_STATIC_INIT
|
||||
COOKBOOK_CONFIGURE_FLAGS+=(
|
||||
--disable-lzmadec
|
||||
--disable-lzmainfo
|
||||
--disable-xz
|
||||
--disable-xzdec
|
||||
--enable-shared=yes
|
||||
--enable-static=yes
|
||||
--enable-threads=no
|
||||
)
|
||||
cookbook_configure
|
||||
|
||||
@ -203,29 +203,66 @@ fn serialize_and_write<T: Serialize>(file_path: &Path, content: &T) -> Result<()
|
||||
}
|
||||
|
||||
static SHARED_PRESCRIPT: &str = r#"
|
||||
# Build dynamically
|
||||
function DYNAMIC_INIT {
|
||||
COOKBOOK_AUTORECONF="autoreconf"
|
||||
autotools_recursive_regenerate() {
|
||||
for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do
|
||||
echo "* autotools regen in '$(dirname $f)'..."
|
||||
( cd "$(dirname "$f")" && "${COOKBOOK_AUTORECONF}" -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal )
|
||||
done
|
||||
}
|
||||
COOKBOOK_AUTORECONF="autoreconf"
|
||||
autotools_recursive_regenerate() {
|
||||
for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do
|
||||
echo "* autotools regen in '$(dirname $f)'..."
|
||||
( cd "$(dirname "$f")" && "${COOKBOOK_AUTORECONF}" -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal )
|
||||
done
|
||||
}
|
||||
|
||||
echo "DEBUG: Program is being compiled dynamically."
|
||||
if [ "${TARGET}" != "x86_64-unknown-redox" ]
|
||||
then
|
||||
echo "WARN: ${TARGET} does not support dynamic linking." >&2
|
||||
return
|
||||
fi
|
||||
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--disable-static
|
||||
)
|
||||
echo "DEBUG: Program is being compiled dynamically."
|
||||
|
||||
# TODO: check paths for spaces
|
||||
export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib"
|
||||
export LDFLAGS="-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib $LDFLAGS"
|
||||
export RUSTFLAGS="-C target-feature=-crt-static"
|
||||
export COOKBOOK_DYNAMIC=1
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--disable-static
|
||||
)
|
||||
|
||||
COOKBOOK_MESON_FLAGS=(
|
||||
--buildtype release
|
||||
--wrap-mode nofallback
|
||||
--strip
|
||||
-Ddefault_library=shared
|
||||
-Dprefix=/usr
|
||||
)
|
||||
|
||||
# TODO: check paths for spaces
|
||||
export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib"
|
||||
export LDFLAGS="-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib $LDFLAGS"
|
||||
export RUSTFLAGS="-C target-feature=-crt-static"
|
||||
export COOKBOOK_DYNAMIC=1
|
||||
}
|
||||
|
||||
# Build both dynamically and statically
|
||||
function DYNAMIC_STATIC_INIT {
|
||||
DYNAMIC_INIT
|
||||
if [ "${COOKBOOK_DYNAMIC}" == "1" ]
|
||||
then
|
||||
COOKBOOK_CONFIGURE_FLAGS=(
|
||||
--host="${GNU_TARGET}"
|
||||
--prefix="/usr"
|
||||
--enable-shared
|
||||
--enable-static
|
||||
)
|
||||
|
||||
COOKBOOK_MESON_FLAGS=(
|
||||
--buildtype release
|
||||
--wrap-mode nofallback
|
||||
--strip
|
||||
-Ddefault_library=both
|
||||
-Dprefix=/usr
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
function GNU_CONFIG_GET {
|
||||
@ -938,6 +975,7 @@ COOKBOOK_MESON_FLAGS=(
|
||||
--buildtype release
|
||||
--wrap-mode nofallback
|
||||
--strip
|
||||
-Ddefault_library=static
|
||||
-Dprefix=/usr
|
||||
)
|
||||
function cookbook_meson {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user