From 51a5f347ea4826c61349c5f0890d7f984c166eac Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Fri, 17 May 2024 16:19:32 -0500 Subject: Setup everything for static and non-static release --- Dockerfile | 2 +- README | 11 +++++++---- bin/dune | 8 ++++++-- flake.nix | 9 +-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5c3395..e4b9ed2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,4 +22,4 @@ RUN git config --global --add safe.directory /tmp/build RUN opam install . --update-invariant --yes COPY . . -CMD eval `opam env` && dune build --profile release +CMD eval `opam env` && dune build --profile release-static diff --git a/README b/README index 3f7c386..9f96ede 100644 --- a/README +++ b/README @@ -87,6 +87,10 @@ _________________ dune build + Optimized build with + + dune build --profile release + And to run: dune exec -- stitch @@ -95,11 +99,10 @@ _________________ dune exec -- stitch --help=groff - To prepare for release, we need to statically link the binary, which - unless you use a musl based distro it will not do out of the box. + When the system is built with Nix, it will be dynamically linked. - There is a Dockerfile included that prepares the release, use it with - podman: + To build a static release, There is a Dockerfile included that + compiles it with musl, use it with podman: podman pull docker.io/alpine:edge podman build . -t stitch:latest diff --git a/bin/dune b/bin/dune index b255cb0..d57f39c 100644 --- a/bin/dune +++ b/bin/dune @@ -1,7 +1,7 @@ (executable (public_name stitch) (package stitch) - (flags (:standard -cclib -static -cclib -no-pie)) + (name main) (libraries stitch @@ -13,7 +13,11 @@ shexp.process lambda-term)) - +(env + (release-static + (ocamlc_flags (-g)) + (ocamlopt_flags (-g)) + (flags (:standard -cclib -static -cclib -no-pie -w -40)))) ; Rule to generate a man page for stitch (rule (target stitch.1) diff --git a/flake.nix b/flake.nix index a51608b..8190cae 100644 --- a/flake.nix +++ b/flake.nix @@ -33,14 +33,7 @@ ${package} = prev.${package}.overrideAttrs (_: { # Prevent the ocaml dependencies from leaking into dependent environments doNixSupport = false; - buildInputs = [ - pkgs.glibc.static - pkgs.zlib.static - pkgs.binutils-unwrapped - pkgs.ocaml - pkgs.musl - pkgs.gcc - ]; + buildInputs = []; }); }; scope' = scope.overrideScope' overlay; -- cgit v1.2.3