From 0f6a6e259c9e4427840697fbb33308bda47a5c0f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 26 Dec 2024 16:10:31 +1100 Subject: [PATCH 01/24] feat(cook): prescript for source scripts Signed-off-by: Anhad Singh --- src/bin/cook.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 4b394b74..071b77ad 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -168,6 +168,30 @@ fn run_command_stdin(mut command: process::Command, stdin_data: &[u8]) -> Result Ok(()) } +static SHARED_PRESCRIPT: &str = r#" +function DYNAMIC_INIT { + echo "WARN: Program is being compiled dynamically." + + COOKBOOK_CONFIGURE_FLAGS=( + --host="${GNU_TARGET}" + --prefix="" + --enable-shared + --disable-static + ) + + # TODO: check paths for spaces + export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" + + 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 + } +} +"#; + fn fetch(recipe_dir: &Path, source: &Option) -> Result { let source_dir = recipe_dir.join("source"); match source { @@ -392,7 +416,7 @@ fi"#, let mut command = Command::new("bash"); command.arg("-ex"); command.current_dir(&source_dir_tmp); - run_command_stdin(command, script.as_bytes())?; + run_command_stdin(command, format!("{SHARED_PRESCRIPT}\n{script}").as_bytes())?; } // Move source.tmp to source atomically @@ -716,7 +740,7 @@ done command }; - let full_script = format!("{}\n{}\n{}", pre_script, script, post_script); + let full_script = format!("{}\n{}\n{}\n{}", pre_script, SHARED_PRESCRIPT, script, post_script); run_command_stdin(command, full_script.as_bytes())?; // Move stage.tmp to stage atomically From 69e5aef6f3580a3176840bed8b6a58e2fea5c302 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 26 Dec 2024 16:11:03 +1100 Subject: [PATCH 02/24] feat(gnu-make): dynamic Signed-off-by: Anhad Singh --- recipes/dev/gnu-make/recipe.toml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/recipes/dev/gnu-make/recipe.toml b/recipes/dev/gnu-make/recipe.toml index 7db31a04..fb274e60 100644 --- a/recipes/dev/gnu-make/recipe.toml +++ b/recipes/dev/gnu-make/recipe.toml @@ -1,9 +1,19 @@ -#TODO very basic makefiles are tested to work but needs more testing -[source] -tar = "http://ftp.gnu.org/gnu/make/make-4.4.tar.gz" -patches = [ - "redox.patch" -] - -[build] -template = "configure" +#TODO very basic makefiles are tested to work but needs more testing +[source] +tar = "http://ftp.gnu.org/gnu/make/make-4.4.tar.gz" +patches = [ + "redox.patch" +] +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" + +[build] +template = "custom" +script = """ +DYNAMIC_INIT +cp -rp "$COOKBOOK_SOURCE/." ./ +cookbook_configure +""" + From b4dcf6b9c0ebe509bca050754c7b9421c014dad4 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 26 Dec 2024 16:39:45 +1100 Subject: [PATCH 03/24] feat(libgmp): dynamic Signed-off-by: Anhad Singh --- recipes/libs/libgmp/recipe.toml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/recipes/libs/libgmp/recipe.toml b/recipes/libs/libgmp/recipe.toml index e464785c..40057bb7 100644 --- a/recipes/libs/libgmp/recipe.toml +++ b/recipes/libs/libgmp/recipe.toml @@ -1,5 +1,19 @@ +# GNU Multiple Precision Arithmetic Library (GMP) is a free and open source +# library for arbitrary-precision arithmetic, operating on signed integers, +# rational numbers, and floating-point numbers. + [source] tar = "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz" blake3 = "52cecfbbe286820d1f8bc118769008acb6451bd074fe6dea9e868d54b2ada855" +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" + [build] -template = "configure" +template = "custom" +script = """ +DYNAMIC_INIT +cookbook_configure +""" + From 2551aeeea0d0aae3061cfb37d5519ce2f54a55dd Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 26 Dec 2024 23:57:27 +1100 Subject: [PATCH 04/24] feat(libgmp): bump to 6.3.0 Signed-off-by: Anhad Singh --- recipes/libs/libgmp/recipe.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libs/libgmp/recipe.toml b/recipes/libs/libgmp/recipe.toml index 40057bb7..a2330bd6 100644 --- a/recipes/libs/libgmp/recipe.toml +++ b/recipes/libs/libgmp/recipe.toml @@ -3,8 +3,8 @@ # rational numbers, and floating-point numbers. [source] -tar = "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz" -blake3 = "52cecfbbe286820d1f8bc118769008acb6451bd074fe6dea9e868d54b2ada855" +tar = "https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz" +blake3 = "fffe4996713928ae19331c8ef39129e46d3bf5b7182820656fd4639435cd83a4" script = """ DYNAMIC_INIT autotools_recursive_regenerate From 55fcf436d16d14122d843d2ec42105436887a6d2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 26 Dec 2024 23:57:54 +1100 Subject: [PATCH 05/24] feat(libmpfr): dynamic Signed-off-by: Anhad Singh --- recipes/libs/libmpfr/recipe.toml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/recipes/libs/libmpfr/recipe.toml b/recipes/libs/libmpfr/recipe.toml index a1f9d91f..3e653153 100644 --- a/recipes/libs/libmpfr/recipe.toml +++ b/recipes/libs/libmpfr/recipe.toml @@ -1,9 +1,18 @@ [source] tar = "https://www.mpfr.org/mpfr-current/mpfr-4.2.1.tar.xz" blake3 = "f428023b8f7569fc1178faf63265ecb6cab4505fc3fce5d8c46af70db848a334" +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" [build] +template = "custom" dependencies = [ "libgmp", ] -template = "configure" +script = """ +DYNAMIC_INIT +cookbook_configure +""" + From ebfbfde5320abadd275a0e0ed28824692429e93b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 00:33:21 +1100 Subject: [PATCH 06/24] feat(zlib): dynamic Signed-off-by: Anhad Singh --- recipes/libs/zlib/recipe.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/recipes/libs/zlib/recipe.toml b/recipes/libs/zlib/recipe.toml index 8e9a8709..fe1fc839 100644 --- a/recipes/libs/zlib/recipe.toml +++ b/recipes/libs/zlib/recipe.toml @@ -4,11 +4,10 @@ blake3 = "ec1abc6f672a7a6ee6f49ba544cc9529f73121b478310473be44fee22a140ebf" [build] template = "custom" script = """ - export LDFLAGS="--static" + DYNAMIC_INIT # See https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar. - CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" \ - --prefix="" \ - --static + CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" --prefix="" "${COOKBOOK_MAKE}" -j "$(nproc)" "${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" """ + From 51e8e1a015889d65bface80c9021dfac5715dc8a Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 01:53:05 +1100 Subject: [PATCH 07/24] feat(libiconv): dynamic We also statically build as cosmic-files requires it. Signed-off-by: Anhad Singh --- recipes/libs/libiconv/recipe.toml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index 3c0970b7..d5b4161c 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -4,11 +4,27 @@ blake3 = "b736af4e8245ae9f1618ef226a3bf2a998334b745520565cf413c0a7d54b6924" patches = [ "01_redox.patch" ] +script = """ +DYNAMIC_INIT +cp ${COOKBOOK_HOST_SYSROOT}/share/aclocal/libtool.m4 ./m4/ +cp ${COOKBOOK_HOST_SYSROOT}/share/aclocal/libtool.m4 ./libcharset/m4/ +cp -fp ${COOKBOOK_HOST_SYSROOT}/share/libtool/build-aux/ltmain.sh ./build-aux/ +cp -fp ${COOKBOOK_HOST_SYSROOT}/share/libtool/build-aux/ltmain.sh ./libcharset/build-aux/ +cp ${COOKBOOK_HOST_SYSROOT}/share/aclocal/ltversion.m4 ./m4/ +cp ${COOKBOOK_HOST_SYSROOT}/share/aclocal/ltversion.m4 ./libcharset/m4/ + +autotools_recursive_regenerate -I$(realpath ./m4) -I$(realpath ./srcm4) +""" [build] template = "custom" script = """ +DYNAMIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( + --host="${GNU_TARGET}" + --prefix="" + --enable-shared + --enable-static ac_cv_have_decl_program_invocation_name=no ) cookbook_configure From e4f0e28b579d8c2014a7a9962cd542a057fb68dc Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 01:54:05 +1100 Subject: [PATCH 08/24] feat(libiconv): bump to 1.17 Signed-off-by: Anhad Singh --- recipes/libs/libiconv/01_redox.patch | 20 ++++++++++---------- recipes/libs/libiconv/recipe.toml | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/recipes/libs/libiconv/01_redox.patch b/recipes/libs/libiconv/01_redox.patch index 860bbed5..1e083ca8 100644 --- a/recipes/libs/libiconv/01_redox.patch +++ b/recipes/libs/libiconv/01_redox.patch @@ -1,7 +1,7 @@ -diff -ruw source/srclib/getprogname.c source-new/srclib/getprogname.c ---- source/srclib/getprogname.c 2017-01-01 16:02:21.000000000 -0700 -+++ source-new/srclib/getprogname.c 2018-12-29 08:08:09.138286508 -0700 -@@ -43,6 +43,14 @@ +diff '--color=auto' -ur source/srclib/getprogname.c source-new/srclib/getprogname.c +--- source/srclib/getprogname.c 2022-01-04 19:33:29.000000000 +1100 ++++ source-new/srclib/getprogname.c 2024-11-24 00:42:48.384997609 +1100 +@@ -28,6 +28,14 @@ # include #endif @@ -13,13 +13,13 @@ diff -ruw source/srclib/getprogname.c source-new/srclib/getprogname.c +# include +#endif + - #include "dirname.h" - - #ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ -@@ -143,6 +151,17 @@ - free (buf.ps_pathptr); + #ifdef __MVS__ + # ifndef _OPEN_SYS + # define _OPEN_SYS +@@ -287,6 +295,17 @@ + close (fd); } - return p; + return "?"; +# elif defined(__redox__) + char filename[PATH_MAX]; + int fd = open ("sys:exe", O_RDONLY); diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index d5b4161c..378d6875 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -1,6 +1,6 @@ [source] -tar = "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz" -blake3 = "b736af4e8245ae9f1618ef226a3bf2a998334b745520565cf413c0a7d54b6924" +tar = "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz" +blake3 = "820b3b9fd3e2181bfb95475f01e9a3451e6d751e4f8c98ebcdcca1d8aa720f7f" patches = [ "01_redox.patch" ] From a1c6409153140e6a2756d566ac3192226fb9a869 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 03:05:08 +1100 Subject: [PATCH 09/24] feat(gnu-binutils): dynamic * dynamic * shell to toml recipe Signed-off-by: Anhad Singh --- recipes/tools/gnu-binutils/01_build_fix.patch | 24 ++++++++++ recipes/tools/gnu-binutils/recipe.sh | 47 ------------------- recipes/tools/gnu-binutils/recipe.toml | 40 ++++++++++++++++ 3 files changed, 64 insertions(+), 47 deletions(-) create mode 100644 recipes/tools/gnu-binutils/01_build_fix.patch delete mode 100644 recipes/tools/gnu-binutils/recipe.sh create mode 100644 recipes/tools/gnu-binutils/recipe.toml diff --git a/recipes/tools/gnu-binutils/01_build_fix.patch b/recipes/tools/gnu-binutils/01_build_fix.patch new file mode 100644 index 00000000..9bf0ddac --- /dev/null +++ b/recipes/tools/gnu-binutils/01_build_fix.patch @@ -0,0 +1,24 @@ +diff '--color=auto' -ur source/gprofng/libcollector/configure.ac source-new/gprofng/libcollector/configure.ac +--- source/gprofng/libcollector/configure.ac 2024-08-17 09:00:00.000000000 +1000 ++++ source-new/gprofng/libcollector/configure.ac 2024-12-04 15:59:58.407412951 +1100 +@@ -18,7 +18,7 @@ + + m4_include([../../bfd/version.m4]) + AC_INIT([gprofng], [BFD_VERSION]) +-AC_CONFIG_MACRO_DIRS([../../config ../..]) ++#AC_CONFIG_MACRO_DIRS([../../config ../..]) + AC_CONFIG_AUX_DIR(../..) + AC_CANONICAL_TARGET + AM_INIT_AUTOMAKE +diff '--color=auto' -ur source/libiberty/configure.ac source-new/libiberty/configure.ac +--- source/libiberty/configure.ac 2024-08-17 09:00:00.000000000 +1000 ++++ source-new/libiberty/configure.ac 2024-12-04 15:59:31.572203764 +1100 +@@ -37,7 +37,7 @@ + libiberty_topdir="${srcdir}/.." + fi + AC_SUBST(libiberty_topdir) +-AC_CONFIG_AUX_DIR($libiberty_topdir) ++AC_CONFIG_AUX_DIR([.]) + + dnl Very limited version of automake's enable-maintainer-mode + diff --git a/recipes/tools/gnu-binutils/recipe.sh b/recipes/tools/gnu-binutils/recipe.sh deleted file mode 100644 index f87b12bc..00000000 --- a/recipes/tools/gnu-binutils/recipe.sh +++ /dev/null @@ -1,47 +0,0 @@ -GIT=https://gitlab.redox-os.org/redox-os/binutils-gdb.git -BRANCH=redox-2.41 -GIT_UPSTREAM=https://sourceware.org/git/binutils-gdb.git -BUILD_DEPENDS=(expat libgmp libmpfr) - -function recipe_version { - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" - skip=1 -} - -function recipe_build { - sysroot="$(realpath ../sysroot)" - mkdir -p "$sysroot/usr" - ln -sf "$sysroot/include" "$sysroot/usr/include" - ln -sf "$sysroot/lib" "$sysroot/usr/lib" - export CPPFLAGS="-I$sysroot/include -pie -fPIC -g" - export LDFLAGS="-L$sysroot/lib --static -g" - ./configure \ - --build=${BUILD} \ - --host=${HOST} \ - --target=${HOST} \ - --prefix=/ \ - --with-sysroot=/ \ - --with-build-sysroot="$sysroot" \ - --enable-gdb \ - --with-expat \ - --with-multilib \ - --with-interwork \ - --enable-targets="${TARGET}" \ - --disable-lto \ - --disable-nls \ - --disable-werror - "$REDOX_MAKE" -j"$($NPROC)" - skip=1 -} - -function recipe_clean { - "$REDOX_MAKE" clean - skip=1 -} - -function recipe_stage { - dest="$(realpath $1)" - "$REDOX_MAKE" DESTDIR="$dest" install - find "$dest/bin" -exec $STRIP {} ';' 2> /dev/null - skip=1 -} diff --git a/recipes/tools/gnu-binutils/recipe.toml b/recipes/tools/gnu-binutils/recipe.toml new file mode 100644 index 00000000..aead0fef --- /dev/null +++ b/recipes/tools/gnu-binutils/recipe.toml @@ -0,0 +1,40 @@ +[source] +tar = "https://ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.xz" +patches = ["01_build_fix.patch"] +script = """ +DYNAMIC_INIT + +COOKBOOK_AUTORECONF=autoreconf2.69 autotools_recursive_regenerate -I"$(realpath ./config)" +cp -fpv ${COOKBOOK_HOST_SYSROOT}/share/libtool/build-aux/{config.sub,config.guess,install-sh} libiberty/ +""" + +[build] +template = "custom" +dependencies = [ + "expat", + "libgmp", + "libmpfr", + "zlib", +] +script = """ +DYNAMIC_INIT + +COOKBOOK_CONFIGURE_FLAGS+=( + --target="${GNU_TARGET}" + --disable-werror + --disable-dependency-tracking + --disable-nls + --enable-colored-disassembly + --enable-gdb + --with-system-zlib + --with-multilib + --with-interwork + --with-pic +) + +cookbook_configure +""" + +[package] +dependencies = ["zlib"] + From 3e45672be64487bb7f758bd78384adb61cca1cdf Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 03:07:28 +1100 Subject: [PATCH 10/24] feat(mpc) Signed-off-by: Anhad Singh --- recipes/libs/mpc/recipe.toml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 recipes/libs/mpc/recipe.toml diff --git a/recipes/libs/mpc/recipe.toml b/recipes/libs/mpc/recipe.toml new file mode 100644 index 00000000..749805ad --- /dev/null +++ b/recipes/libs/mpc/recipe.toml @@ -0,0 +1,21 @@ + # C library for the arithmetic of complex numbers with arbitrarily high + # precision and correct rounding of the result. + +[source] +tar = "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz" +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" + +[build] +template = "custom" +dependencies = [ + "libgmp", + "libmpfr", +] +script = """ +DYNAMIC_INIT +cookbook_configure +""" + From f92b72224d288376b6c0185f3c6ad60ef64837e7 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 03:11:55 +1100 Subject: [PATCH 11/24] feat(nghttp2): dynamic Signed-off-by: Anhad Singh --- recipes/libs/nghttp2/recipe.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/recipes/libs/nghttp2/recipe.toml b/recipes/libs/nghttp2/recipe.toml index 81ef6277..2744490f 100644 --- a/recipes/libs/nghttp2/recipe.toml +++ b/recipes/libs/nghttp2/recipe.toml @@ -1,9 +1,16 @@ [source] tar = "https://github.com/nghttp2/nghttp2/releases/download/v1.62.1/nghttp2-1.62.1.tar.xz" blake3 = "77b1c0fed8e97db0aa7d6e1a5ed16e5a053093ed0006b7c747dca290d694f3af" +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" + [build] template = "custom" script = """ +DYNAMIC_INIT + COOKBOOK_CONFIGURE_FLAGS+=( --enable-lib-only ) From 11c96f8beecf0ed17c9416a5dbca63b70bb765b3 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 03:12:16 +1100 Subject: [PATCH 12/24] feat(nghttp2): bump to v1.64.0 Signed-off-by: Anhad Singh --- recipes/libs/nghttp2/recipe.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libs/nghttp2/recipe.toml b/recipes/libs/nghttp2/recipe.toml index 2744490f..ce862c9f 100644 --- a/recipes/libs/nghttp2/recipe.toml +++ b/recipes/libs/nghttp2/recipe.toml @@ -1,6 +1,6 @@ [source] -tar = "https://github.com/nghttp2/nghttp2/releases/download/v1.62.1/nghttp2-1.62.1.tar.xz" -blake3 = "77b1c0fed8e97db0aa7d6e1a5ed16e5a053093ed0006b7c747dca290d694f3af" +tar = "https://github.com/nghttp2/nghttp2/releases/download/v1.64.0/nghttp2-1.64.0.tar.xz" +blake3 = "1bbc08de4816769d800c42f501a00c1ba3f5efa1b76e1f65d2e5bdf3aa30354d" script = """ DYNAMIC_INIT autotools_recursive_regenerate From 30cd0e845d2666eb532067d3de87d259f81be4bf Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 14:09:30 +1100 Subject: [PATCH 13/24] feat(recipes): libgcc Signed-off-by: Anhad Singh --- recipes/libs/libgcc/recipe.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 recipes/libs/libgcc/recipe.toml diff --git a/recipes/libs/libgcc/recipe.toml b/recipes/libs/libgcc/recipe.toml new file mode 100644 index 00000000..cfdf136a --- /dev/null +++ b/recipes/libs/libgcc/recipe.toml @@ -0,0 +1,11 @@ +[source] +path = "../prefix/x86_64-unknown-redox/sysroot" + +[build] +template = "custom" +script = """ +mkdir -p "${COOKBOOK_STAGE}/lib" +cp -vr ${COOKBOOK_HOST_SYSROOT}/lib/gcc ${COOKBOOK_STAGE}/lib/ +cp -vr ${COOKBOOK_HOST_SYSROOT}/${TARGET}/lib/. ${COOKBOOK_STAGE}/lib/ +rm ${COOKBOOK_STAGE}/lib/{crt0.o,crt1.o,crti.o,crtn.o,libc.a,libc.so.6,ld64.so.1} +""" From aa7c69999e343908af3dc2d9277ba6cb54612067 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 14:10:10 +1100 Subject: [PATCH 14/24] misc(recipes): remove mpc from WIP Signed-off-by: Anhad Singh --- recipes/wip/libs/other/mpc/recipe.toml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 recipes/wip/libs/other/mpc/recipe.toml diff --git a/recipes/wip/libs/other/mpc/recipe.toml b/recipes/wip/libs/other/mpc/recipe.toml deleted file mode 100644 index bb6d1d4b..00000000 --- a/recipes/wip/libs/other/mpc/recipe.toml +++ /dev/null @@ -1,9 +0,0 @@ -#TODO compiled but not tested -[source] -tar = "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz" -[build] -template = "configure" -dependencies = [ - "libgmp", - "libmpfr", -] From dff2dcd4d632d8c70aa32d696c5e844929acddd2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 14:17:35 +1100 Subject: [PATCH 15/24] feat(git): dynamic Signed-off-by: Anhad Singh --- recipes/dev/git/recipe.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/dev/git/recipe.sh b/recipes/dev/git/recipe.sh index 0d6f14c2..90c672ef 100644 --- a/recipes/dev/git/recipe.sh +++ b/recipes/dev/git/recipe.sh @@ -1,7 +1,7 @@ VERSION=2.13.1 TAR=https://www.kernel.org/pub/software/scm/git/git-$VERSION.tar.xz BUILD_DEPENDS=(zlib curl openssl1 expat nghttp2) -DEPENDS="ca-certificates" +DEPENDS="ca-certificates nghttp2" MAKEFLAGS=( NEEDS_SSL_WITH_CURL=1 @@ -24,7 +24,7 @@ function recipe_version { function recipe_build { sysroot="$(realpath ../sysroot)" - export LDFLAGS="-L$sysroot/lib -static" + export LDFLAGS="-L$sysroot/lib" export CPPFLAGS="-I$sysroot/include" export CURL_CONFIG="$sysroot/bin/curl-config" ./configure \ From 9e3aa1b4802d078d8914e963da361b0986de52d5 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 27 Dec 2024 19:15:58 +1100 Subject: [PATCH 16/24] feat(llvm): dynamic Signed-off-by: Anhad Singh --- recipes/dev/llvm18/recipe.toml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/recipes/dev/llvm18/recipe.toml b/recipes/dev/llvm18/recipe.toml index daeb31ad..c0d3505c 100644 --- a/recipes/dev/llvm18/recipe.toml +++ b/recipes/dev/llvm18/recipe.toml @@ -9,18 +9,33 @@ dependencies = [ "zlib" ] script = """ -COOKBOOK_CONFIGURE="cmake" +DYNAMIC_INIT + +cat > CMakeToolchain-x86_64.cmake < Date: Fri, 27 Dec 2024 19:24:52 +1100 Subject: [PATCH 17/24] feat(mesa): dynamic Signed-off-by: Anhad Singh --- recipes/libs/mesa/recipe.toml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/recipes/libs/mesa/recipe.toml b/recipes/libs/mesa/recipe.toml index 9fd73d09..a3c73160 100644 --- a/recipes/libs/mesa/recipe.toml +++ b/recipes/libs/mesa/recipe.toml @@ -11,12 +11,13 @@ dependencies = [ "zlib", ] script = """ +DYNAMIC_INIT #TODO: do this in cook instead unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP export CFLAGS="-I${COOKBOOK_SYSROOT}/include -DHAVE_PTHREAD=1" export CPPFLAGS="-I${COOKBOOK_SYSROOT}/include -DHAVE_PTHREAD=1" -export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib --static" +export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" export LLVM_CONFIG="${TARGET}-llvm-config" # TODO: Fix this annoying shite @@ -46,18 +47,23 @@ meson "${COOKBOOK_SOURCE}" . \ --cross-file cross_file.txt \ --buildtype release \ --strip \ - -Ddefault_library=static \ + -Ddefault_library=shared \ -Dglx=disabled \ -Dllvm=enabled \ + -Dshared-llvm=enabled \ -Dosmesa=true \ -Dplatforms= \ -Dshader-cache=disabled \ - -Dshared-llvm=disabled \ -Dshared-glapi=disabled -ninja -v +ninja -j${COOKBOOK_MAKE_JOBS} DESTDIR="${COOKBOOK_STAGE}" ninja install - -# Hack to add LLVM libs -#TODO: only add necessary LLVM libs, not all of them -sed -i "s/ -lOSMesa / -lOSMesa $("${TARGET}-llvm-config" --libs) -lstdc++ /" "${COOKBOOK_STAGE}/lib/pkgconfig/osmesa.pc" """ + +[package] +dependencies = [ + "libgcc", + "zlib", + "llvm18", + "expat" +] + From 80c7e5a4387008cdd90e0b3256d12c26e986be62 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 13 Jan 2025 13:49:55 +1100 Subject: [PATCH 18/24] Revert "feat(mesa): dynamic" This reverts commit c284034cff0dcefd7fc8ac2983e231ec4c23af5c. --- recipes/libs/mesa/recipe.toml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/recipes/libs/mesa/recipe.toml b/recipes/libs/mesa/recipe.toml index a3c73160..9fd73d09 100644 --- a/recipes/libs/mesa/recipe.toml +++ b/recipes/libs/mesa/recipe.toml @@ -11,13 +11,12 @@ dependencies = [ "zlib", ] script = """ -DYNAMIC_INIT #TODO: do this in cook instead unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP export CFLAGS="-I${COOKBOOK_SYSROOT}/include -DHAVE_PTHREAD=1" export CPPFLAGS="-I${COOKBOOK_SYSROOT}/include -DHAVE_PTHREAD=1" -export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" +export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib --static" export LLVM_CONFIG="${TARGET}-llvm-config" # TODO: Fix this annoying shite @@ -47,23 +46,18 @@ meson "${COOKBOOK_SOURCE}" . \ --cross-file cross_file.txt \ --buildtype release \ --strip \ - -Ddefault_library=shared \ + -Ddefault_library=static \ -Dglx=disabled \ -Dllvm=enabled \ - -Dshared-llvm=enabled \ -Dosmesa=true \ -Dplatforms= \ -Dshader-cache=disabled \ + -Dshared-llvm=disabled \ -Dshared-glapi=disabled -ninja -j${COOKBOOK_MAKE_JOBS} +ninja -v DESTDIR="${COOKBOOK_STAGE}" ninja install + +# Hack to add LLVM libs +#TODO: only add necessary LLVM libs, not all of them +sed -i "s/ -lOSMesa / -lOSMesa $("${TARGET}-llvm-config" --libs) -lstdc++ /" "${COOKBOOK_STAGE}/lib/pkgconfig/osmesa.pc" """ - -[package] -dependencies = [ - "libgcc", - "zlib", - "llvm18", - "expat" -] - From 4958040529f5b8af5e72ed5a8797bfdad6424776 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 13 Jan 2025 23:52:18 +1100 Subject: [PATCH 19/24] Revert "feat(llvm): dynamic" This reverts commit 3ded192f52b46f635d59bfd0b3141d02c56ce7c0. --- recipes/dev/llvm18/recipe.toml | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/recipes/dev/llvm18/recipe.toml b/recipes/dev/llvm18/recipe.toml index c0d3505c..daeb31ad 100644 --- a/recipes/dev/llvm18/recipe.toml +++ b/recipes/dev/llvm18/recipe.toml @@ -9,33 +9,18 @@ dependencies = [ "zlib" ] script = """ -DYNAMIC_INIT - -cat > CMakeToolchain-x86_64.cmake < Date: Tue, 14 Jan 2025 00:21:59 +1100 Subject: [PATCH 20/24] feat(gcc13): dynamic Signed-off-by: Anhad Singh --- recipes/dev/gcc13/recipe.sh | 56 -------------------------- recipes/dev/gcc13/recipe.toml | 53 ++++++++++++++++++++++++ recipes/tools/gnu-binutils/recipe.toml | 29 ++++++++----- 3 files changed, 71 insertions(+), 67 deletions(-) delete mode 100644 recipes/dev/gcc13/recipe.sh create mode 100644 recipes/dev/gcc13/recipe.toml diff --git a/recipes/dev/gcc13/recipe.sh b/recipes/dev/gcc13/recipe.sh deleted file mode 100644 index fef38205..00000000 --- a/recipes/dev/gcc13/recipe.sh +++ /dev/null @@ -1,56 +0,0 @@ -VERSION="13.2.0" -TAR="https://gitlab.redox-os.org/redox-os/gcc/-/archive/redox-${VERSION}/gcc-redox-${VERSION}.tar.gz" -#GIT=https://gitlab.redox-os.org/redox-os/gcc.git -#GIT_UPSTREAM=https://gcc.gnu.org/git/gcc.git -#BRANCH="redox-${VERSION}" -BUILD_DEPENDS=(relibc) -DEPENDS="gnu-binutils relibc" - -function recipe_version { - echo "${VERSION}" - skip=1 -} - -function recipe_build { - ./contrib/download_prerequisites - cp config.sub gmp/config.sub - cp config.sub isl/config.sub - cp config.sub mpfr/config.sub - cp -f config.sub mpc/config.sub - - sysroot="$(realpath ../sysroot)" - mkdir -p "$sysroot/usr" - ln -sf "$sysroot/include" "$sysroot/usr/include" - ln -sf "$sysroot/lib" "$sysroot/usr/lib" - export LDFLAGS="--static" - ./configure \ - --build=${BUILD} \ - --host=${HOST} \ - --target=${HOST} \ - --prefix=/ \ - --with-sysroot=/ \ - --with-build-sysroot="$sysroot" \ - --with-static-standard-libraries \ - --disable-dlopen \ - --disable-lto \ - --disable-nls \ - --enable-languages=c,c++ \ - --enable-shared \ - --enable-static \ - --enable-threads=posix - "$REDOX_MAKE" -j "$(nproc)" all-gcc all-target-libgcc all-target-libstdc++-v3 - skip=1 -} - -function recipe_clean { - "$REDOX_MAKE" clean - skip=1 -} - -function recipe_stage { - dest="$(realpath $1)" - "$REDOX_MAKE" DESTDIR="$dest" install-gcc install-target-libgcc install-target-libstdc++-v3 - find "$dest"/{bin,libexec} -exec $STRIP {} ';' 2> /dev/null - ln -s "gcc" "$1/bin/cc" - skip=1 -} diff --git a/recipes/dev/gcc13/recipe.toml b/recipes/dev/gcc13/recipe.toml new file mode 100644 index 00000000..72405a87 --- /dev/null +++ b/recipes/dev/gcc13/recipe.toml @@ -0,0 +1,53 @@ +[source] +tar = "https://gitlab.redox-os.org/redox-os/gcc/-/archive/redox-13.2.0/gcc-redox-13.2.0.tar.gz" + +[build] +template = "custom" +dependencies = [ + "libgmp", + "libmpfr", + "mpc", + "zlib" +] +script = """ +DYNAMIC_INIT + +mkdir -p "${COOKBOOK_SYSROOT}/usr" +ln -sf "${COOKBOOK_SYSROOT}/include" "${COOKBOOK_SYSROOT}/usr/include" +ln -sf "${COOKBOOK_SYSROOT}/lib" "${COOKBOOK_SYSROOT}/usr/lib" + +pushd $COOKBOOK_SOURCE +COOKBOOK_AUTORECONF=autoreconf2.69 autotools_recursive_regenerate -I"$(realpath ./config)" +cp -fpv $COOKBOOK_HOST_SYSROOT/share/libtool/build-aux/{config.sub,config.guess,install-sh} libiberty/ +popd # pushd $COOKBOOK_SOURCE + +COOKBOOK_CONFIGURE_FLAGS=( + --host="${GNU_TARGET}" + --target="${GNU_TARGET}" + --prefix=/ + --enable-shared + --disable-static + --with-sysroot=/ + --with-build-sysroot="${COOKBOOK_SYSROOT}" + --enable-languages=c,c++,lto + --enable-initfini-array + --disable-multilib + --with-system-zlib + --enable-host-shared + --with-bugurl="https://gitlab.redox-os.org/redox-os/gcc/-/issues" +) + +"${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" +"${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}" all-gcc +"${COOKBOOK_MAKE}" install-gcc DESTDIR="${COOKBOOK_STAGE}" +ln -s "gcc" "${COOKBOOK_STAGE}/bin/cc" +""" + +[package] +dependencies = [ + "libgcc", + "libgmp", + "libmpfr", + "mpc", + "zlib" +] diff --git a/recipes/tools/gnu-binutils/recipe.toml b/recipes/tools/gnu-binutils/recipe.toml index aead0fef..198037b1 100644 --- a/recipes/tools/gnu-binutils/recipe.toml +++ b/recipes/tools/gnu-binutils/recipe.toml @@ -20,21 +20,28 @@ script = """ DYNAMIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( - --target="${GNU_TARGET}" - --disable-werror - --disable-dependency-tracking - --disable-nls - --enable-colored-disassembly - --enable-gdb - --with-system-zlib - --with-multilib - --with-interwork - --with-pic + --target="${GNU_TARGET}" + --disable-werror + --disable-dependency-tracking + --disable-nls + --enable-colored-disassembly + --enable-gdb + --with-system-zlib + --with-multilib + --with-interwork + --with-pic + --with-expat ) cookbook_configure """ [package] -dependencies = ["zlib"] +dependencies = [ + "libgcc", + "expat", + "libgmp", + "libmpfr", + "zlib", +] From bbead114d19e59754dc0bd625de3774ee8887535 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 20 Jan 2025 18:51:45 +1100 Subject: [PATCH 21/24] feat(openssl1): dynamic Signed-off-by: Anhad Singh --- recipes/libs/openssl1/openssl1.patch | 50 ++++++++++++++++++++++++++++ recipes/libs/openssl1/recipe.toml | 7 ++-- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 recipes/libs/openssl1/openssl1.patch diff --git a/recipes/libs/openssl1/openssl1.patch b/recipes/libs/openssl1/openssl1.patch new file mode 100644 index 00000000..82fe3ac2 --- /dev/null +++ b/recipes/libs/openssl1/openssl1.patch @@ -0,0 +1,50 @@ +diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf +index 45e2fc7a..2d7f7db3 100644 +--- a/Configurations/10-main.conf ++++ b/Configurations/10-main.conf +@@ -175,28 +175,32 @@ sub vms_info { + }, + + +-### Redox +- "redox-aarch64" => { +- inherit_from => [ "BASE_common", asm("aarch64_asm") ], ++### Redox configurations ++ "redox-common" => { ++ inherit_from => [ "BASE_common" ], + cc => "gcc", +- cflags => "-DL_ENDIAN -DOSSL_SSIZE_MAX=LONG_MAX -DNO_SYSLOG -O3 -static -Wall", ++ thread_scheme => "(unknown)", ++ dso_scheme => "dlfcn", ++ shared_target => "linux-shared", ++ shared_cflag => "-fPIC", ++ shared_ldflag => sub { $disabled{pinshared} ? () : "-Wl,-znodelete" }, ++ shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++ }, ++ "redox-aarch64" => { ++ inherit_from => [ "redox-common", asm("aarch64_asm") ], ++ cflags => "-DL_ENDIAN -DOSSL_SSIZE_MAX=LONG_MAX -DNO_SYSLOG -O3 -Wall", + bn_ops => "SIXTY_FOUR_BIT_LONG", + perlasm_scheme => "elf", +- thread_scheme => "(unknown)", + }, + "redox-i686" => { +- inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], +- cc => "gcc", +- cflags => "-DL_ENDIAN -DNO_SYSLOG -O3 -static -Wall", ++ inherit_from => [ "redox-common", asm("x86_elf_asm") ], ++ cflags => "-DL_ENDIAN -DNO_SYSLOG -O3 -Wall", + bn_ops => "BN_LLONG", +- thread_scheme => "(unknown)", + }, + "redox-x86_64" => { +- inherit_from => [ "BASE_common", asm("x86_64_asm") ], +- cc => "gcc", +- cflags => "-DL_ENDIAN -DOSSL_SSIZE_MAX=LONG_MAX -DNO_SYSLOG -O3 -static -Wall", ++ inherit_from => [ "redox-common", asm("x86_64_asm") ], ++ cflags => "-DL_ENDIAN -DOSSL_SSIZE_MAX=LONG_MAX -DNO_SYSLOG -O3 -Wall", + bn_ops => "SIXTY_FOUR_BIT_LONG", +- thread_scheme => "(unknown)", + }, + + #### Solaris configurations diff --git a/recipes/libs/openssl1/recipe.toml b/recipes/libs/openssl1/recipe.toml index 55b707c0..2666b386 100644 --- a/recipes/libs/openssl1/recipe.toml +++ b/recipes/libs/openssl1/recipe.toml @@ -5,15 +5,18 @@ branch = "redox-v1" [build] template = "custom" script = """ +DYNAMIC_INIT ARCH="${TARGET%%-*}" COOKBOOK_CONFIGURE="${COOKBOOK_SOURCE}/Configure" COOKBOOK_CONFIGURE_FLAGS=( - no-shared + shared no-dgram "redox-${ARCH}" --prefix="/" ) export CC="${TARGET}-gcc" -cookbook_configure +"${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" +"${COOKBOOK_MAKE}" -j"${COOKBOOK_MAKE_JOBS}" +"${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" rm -rfv "${COOKBOOK_STAGE}/"{share,ssl} """ From 9f2cb652a3ec77b1a0e251b55779c095fb95fb2b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 20 Jan 2025 18:58:42 +1100 Subject: [PATCH 22/24] feat(cookbook): rust dynamic Signed-off-by: Anhad Singh --- src/bin/cook.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 071b77ad..305d849f 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -181,6 +181,7 @@ function DYNAMIC_INIT { # TODO: check paths for spaces export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" + export RUSTFLAGS="-C target-feature=-crt-static" COOKBOOK_AUTORECONF="autoreconf" autotools_recursive_regenerate() { @@ -634,28 +635,6 @@ function cookbook_configure { "${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}" "${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" } - -function DYNAMIC_INIT { - echo "WARN: Program is being compiled dynamically." - - COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="" - --enable-shared - --disable-static - ) - - # TODO: check paths for spaces - export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" - - autotools_recursive_regenerate() { - for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do - echo "* autotools regenerate in '$(dirname $f)'..." - ( cd "$(dirname "$f")" && autoreconf -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal ) - done - } -} - "#; let post_script = r#"# Common post script From 48bed31e9280504b7b3a432f067de620bcea4093 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 20 Jan 2025 19:11:39 +1100 Subject: [PATCH 23/24] misc(libiconv): set the flags instead of appending Signed-off-by: Anhad Singh --- recipes/libs/libiconv/recipe.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index 378d6875..1ef97dc5 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -20,7 +20,7 @@ autotools_recursive_regenerate -I$(realpath ./m4) -I$(realpath ./srcm4) template = "custom" script = """ DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS+=( +COOKBOOK_CONFIGURE_FLAGS=( --host="${GNU_TARGET}" --prefix="" --enable-shared From 3ee1f4da0052802fc0cdd7162428708639db61a0 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 20 Jan 2025 19:12:15 +1100 Subject: [PATCH 24/24] feat(cookbook): add the option to prefer static By default all libraries and applications that can be dynamically linked will be dynamically linked. You can override this behaviour by setting the `COOKBOOK_PREFER_STATIC` environment variable. Note that if you perviously did not use this flag, it might (most likely will) require a complete userland sysroot recompilation. It will look like this: ```bash $ make clean $ COOKBOOK_PREFER_STATIC=yes make image ``` For testing, the following will also work: ```bash $ COOKBOOK_PREFER_STATIC=yes make cr.{PACKAGE_NAME} # obviously replace # PACKAGE_NAME with # the name of a package :) ``` Signed-off-by: Anhad Singh --- recipes/dev/gcc13/recipe.toml | 12 ++++++++++++ recipes/libs/libiconv/recipe.toml | 13 +++++++++++-- src/bin/cook.rs | 20 ++++++++++++-------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/recipes/dev/gcc13/recipe.toml b/recipes/dev/gcc13/recipe.toml index 72405a87..106e8e74 100644 --- a/recipes/dev/gcc13/recipe.toml +++ b/recipes/dev/gcc13/recipe.toml @@ -37,6 +37,18 @@ COOKBOOK_CONFIGURE_FLAGS=( --with-bugurl="https://gitlab.redox-os.org/redox-os/gcc/-/issues" ) +if [[ -n "$COOKBOOK_PREFER_STATIC" ]]; then + COOKBOOK_CONFIGURE_FLAGS+=( + --enable-static + --disable-shared + ) +else + COOKBOOK_CONFIGURE_FLAGS+=( + --enable-shared + --disable-static + ) +fi + "${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" "${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}" all-gcc "${COOKBOOK_MAKE}" install-gcc DESTDIR="${COOKBOOK_STAGE}" diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index 1ef97dc5..38e46cce 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -23,9 +23,18 @@ DYNAMIC_INIT COOKBOOK_CONFIGURE_FLAGS=( --host="${GNU_TARGET}" --prefix="" - --enable-shared - --enable-static ac_cv_have_decl_program_invocation_name=no ) +if [[ -n "$COOKBOOK_PREFER_STATIC" ]]; then + COOKBOOK_CONFIGURE_FLAGS+=( + --enable-static + --disable-shared + ) +else + COOKBOOK_CONFIGURE_FLAGS+=( + --enable-shared + --enable-static + ) +fi cookbook_configure """ diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 305d849f..fcfab14a 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -170,6 +170,18 @@ fn run_command_stdin(mut command: process::Command, stdin_data: &[u8]) -> Result static SHARED_PRESCRIPT: &str = r#" 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 + } + + if [[ -n "$COOKBOOK_PREFER_STATIC" ]]; then + return + fi + echo "WARN: Program is being compiled dynamically." COOKBOOK_CONFIGURE_FLAGS=( @@ -182,14 +194,6 @@ function DYNAMIC_INIT { # TODO: check paths for spaces export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" export RUSTFLAGS="-C target-feature=-crt-static" - - 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 - } } "#;