Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc static improvements (mainly ocaml and a regression linked to b0b5ef7286dca098f40f5075175105c3c0dfbe05) #133008

Merged
merged 35 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
061f70f
ocaml: fix static compilation on recent versions
symphorien Aug 5, 2021
ddd479f
ocamlPackages.mkDerivation: use nativeBuildInputs for build tools
symphorien Aug 7, 2021
856fa06
buildDunePackage: use nativeBuildInputs for build tools
symphorien Aug 7, 2021
37962fc
python27: fix static build
symphorien Aug 7, 2021
36acee3
python3: fix static build
symphorien Aug 7, 2021
a9e2620
libbfd: fix static build
symphorien Aug 7, 2021
652f7fa
libxml2: fix static build
symphorien Aug 7, 2021
2d4dd13
lzo: fix static build
symphorien Aug 7, 2021
cd97a3d
curl: fix static build by disabling gssSupport
symphorien Aug 7, 2021
a2c5662
ocaml: add strictDeps = true
symphorien Aug 11, 2021
79b32fc
python27: use strictDeps = true;
symphorien Aug 11, 2021
b1b2305
libbfd: add strictDeps = true
symphorien Aug 11, 2021
bf74dfb
libxml2: add strictDeps = true
symphorien Aug 11, 2021
842c163
lzo: add strictDeps = true;
symphorien Aug 11, 2021
73dee3a
python3: add strictDeps = true
symphorien Aug 11, 2021
81d185a
curl: add strictDeps = true
symphorien Aug 11, 2021
c476094
pkgStatics.ocaml-ng: fix eval when there are no buildInputs
symphorien Aug 14, 2021
e6f82a9
ocamlPackages.easy-format: fix nativeBuildInputs vs buildInputs
symphorien Aug 14, 2021
2c35af2
dune: fix buildInputs vs nativeBuildInputs
symphorien Aug 14, 2021
4c0020b
ocamlPackages.findlib: fix buildInputs vs nativeBuildInputs
symphorien Aug 14, 2021
fc3806b
ocamlPackages.gen: fix cross
symphorien Aug 14, 2021
0631aa0
ocamlPackages.process: fix static cross
symphorien Aug 14, 2021
0b134b0
ocamlPackages.seq: fix static cross
symphorien Aug 14, 2021
dd8a674
ocamlPackages.wasm: fix static cross
symphorien Aug 14, 2021
a99983b
ocamlPackages.zarith: fix static cross
symphorien Aug 14, 2021
e98be5d
ocamlPackages.findlib: refactor
symphorien Aug 14, 2021
a3ab43d
ocamlPackages.findlib: create destdir even when there are no buildInputs
symphorien Aug 14, 2021
ce31d52
ocamlbuild: fix static cross
symphorien Aug 14, 2021
fd60747
ocamlPackages.syslog: fix static cross
symphorien Aug 14, 2021
9ae5ae7
opaline: fix static build
symphorien Aug 14, 2021
6506d2a
pkgsStatic.ocaml: migrate some logic from static adapter to ocaml
symphorien Aug 14, 2021
41e07ee
pkgsStatic.ocaml-ng: migrate more logic to derivations
symphorien Aug 14, 2021
a17fc03
pkgsStatic.ocaml-ng: migrate static adapter to derivations themselves
symphorien Aug 14, 2021
9046258
pkgsStatic: Inline more of static overlay
Ericson2314 Aug 19, 2021
a5c133a
ocamlbuild: fix build
symphorien Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/build-support/ocaml/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, writeText, ocaml, findlib, ocamlbuild, camlp4 }:

{ name, version, buildInputs ? [],
{ name, version, nativeBuildInputs ? [],
createFindlibDestdir ? true,
dontStrip ? true,
minimumSupportedOcamlVersion ? null,
Expand All @@ -19,7 +19,7 @@ in
stdenv.mkDerivation (args // {
name = "ocaml-${name}-${version}";

buildInputs = [ ocaml findlib ocamlbuild camlp4 ] ++ buildInputs;
nativeBuildInputs = [ ocaml findlib ocamlbuild camlp4 ] ++ nativeBuildInputs;

setupHook = if setupHook == null && hasSharedObjects
then writeText "setupHook.sh" ''
Expand Down
6 changes: 4 additions & 2 deletions pkgs/build-support/ocaml/dune.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, ocaml, findlib, dune_1, dune_2 }:

{ pname, version, buildInputs ? [], enableParallelBuilding ? true, ... }@args:
{ pname, version, nativeBuildInputs ? [], enableParallelBuilding ? true, ... }@args:

let Dune = if args.useDune2 or false then dune_2 else dune_1; in

Expand All @@ -12,6 +12,8 @@ else
stdenv.mkDerivation ({

inherit enableParallelBuilding;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

buildPhase = ''
runHook preBuild
Expand All @@ -33,7 +35,7 @@ stdenv.mkDerivation ({

name = "ocaml${ocaml.version}-${pname}-${version}";

buildInputs = [ ocaml Dune findlib ] ++ buildInputs;
nativeBuildInputs = [ ocaml Dune findlib ] ++ nativeBuildInputs;

meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };

Expand Down
18 changes: 15 additions & 3 deletions pkgs/development/compilers/ocaml/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let
versionNoPatch = "${toString major_version}.${toString minor_version}";
version = "${versionNoPatch}.${toString patch_version}";
safeX11 = stdenv: !(stdenv.isAarch32 || stdenv.isMips);
safeX11 = stdenv: !(stdenv.isAarch32 || stdenv.isMips || stdenv.hostPlatform.isStatic);
in

{ lib, stdenv, fetchurl, ncurses, buildEnv, libunwind
Expand All @@ -13,7 +13,7 @@ in
, spaceTimeSupport ? false
}:

assert useX11 -> !stdenv.isAarch32 && !stdenv.isMips;
assert useX11 -> safeX11 stdenv;
assert aflSupport -> lib.versionAtLeast version "4.05";
assert flambdaSupport -> lib.versionAtLeast version "4.03";
assert spaceTimeSupport -> lib.versionAtLeast version "4.04";
Expand Down Expand Up @@ -44,6 +44,8 @@ stdenv.mkDerivation (args // {

inherit src;

strictDeps = true;

prefixKey = "-prefix ";
configureFlags =
let flags = new: old:
Expand All @@ -56,7 +58,15 @@ stdenv.mkDerivation (args // {
++ optional aflSupport (flags "--with-afl" "-afl-instrument")
++ optional flambdaSupport (flags "--enable-flambda" "-flambda")
++ optional spaceTimeSupport (flags "--enable-spacetime" "-spacetime")
;
++ optional (stdenv.hostPlatform.isStatic && (lib.versionOlder version "4.08")) "-no-shared-libs"
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform && lib.versionOlder version "4.08") [
"-host ${stdenv.hostPlatform.config}"
"-target ${stdenv.targetPlatform.config}"
];
dontAddStaticConfigureFlags = lib.versionOlder version "4.08";
configurePlatforms = lib.optionals (lib.versionAtLeast version "4.08") [ "host" "target" ];
# x86_64-unknown-linux-musl-ld: -r and -pie may not be used together
hardeningDisable = lib.optional (lib.versionAtLeast version "4.09" && stdenv.hostPlatform.isMusl) "pie";

buildFlags = [ "world" ] ++ optionals useNativeCompilers [ "bootstrap" "world.opt" ];
buildInputs = optional (!lib.versionAtLeast version "4.07") ncurses
Expand All @@ -70,6 +80,8 @@ stdenv.mkDerivation (args // {
# Do what upstream does by default now: https://github.com/ocaml/ocaml/pull/10176
# This is required for aarch64-darwin, everything else works as is.
AS="${stdenv.cc}/bin/cc -c" ASPP="${stdenv.cc}/bin/cc -c"
'' + optionalString (lib.versionOlder version "4.08" && stdenv.hostPlatform.isStatic) ''
configureFlagsArray+=("-cc" "$CC" "-as" "$AS" "-partialld" "$LD -r")
'';
postBuild = ''
mkdir -p $out/include
Expand Down
8 changes: 5 additions & 3 deletions pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
, sourceVersion
, sha256
, passthruFun
, static ? false
, stripBytecode ? true
, static ? stdenv.hostPlatform.isStatic
, stripBytecode ? reproducibleBuild
, rebuildBytecode ? true
, reproducibleBuild ? false
, enableOptimizations ? false
Expand Down Expand Up @@ -187,8 +187,9 @@ let

configureFlags = optionals enableOptimizations [
"--enable-optimizations"
] ++ [
] ++ optionals (!static) [
"--enable-shared"
] ++ [
"--with-threads"
"--enable-unicode=ucs${toString ucsEncoding}"
] ++ optionals (stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isAarch64) [
Expand Down Expand Up @@ -226,6 +227,7 @@ let
++ optional stdenv.hostPlatform.isLinux "ac_cv_func_lchmod=no"
++ optional static "LDFLAGS=-static";

strictDeps = true;
buildInputs =
optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
[ bzip2 openssl zlib ]
Expand Down
5 changes: 4 additions & 1 deletion pkgs/development/interpreters/python/cpython/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ let

version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";

strictDeps = true;

nativeBuildInputs = optionals (!stdenv.isDarwin) [
autoreconfHook
] ++ optionals (!stdenv.isDarwin && passthru.pythonAtLeast "3.10") [
Expand Down Expand Up @@ -287,10 +289,11 @@ in with passthru; stdenv.mkDerivation {
PYTHONHASHSEED=0;

configureFlags = [
"--enable-shared"
"--without-ensurepip"
"--with-system-expat"
"--with-system-ffi"
] ++ optionals (!static) [
"--enable-shared"
] ++ optionals enableOptimizations [
"--enable-optimizations"
] ++ optionals enableLTO [
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/libraries/boost/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ stdenv.mkDerivation {

configureScript = "./bootstrap.sh";
configurePlatforms = [];
dontDisableStatic = true;
dontAddStaticConfigureFlags = true;
configureFlags = [
"--includedir=$(dev)/include"
"--libdir=$(out)/lib"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/libraries/libbfd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ stdenv.mkDerivation {
# We update these ourselves
dontUpdateAutotoolsGnuConfigScripts = true;

strictDeps = true;
nativeBuildInputs = [ autoreconfHook bison ];
buildInputs = [ libiberty zlib.dev ];

configurePlatforms = [ "build" "host" ];
configureFlags = [
"--enable-targets=all" "--enable-64-bit-bfd"
"--enable-install-libbfd"
"--enable-shared"
"--with-system-zlib"
];
] ++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared";

enableParallelBuilding = true;

Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/libraries/libxml2/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, zlib, xz, libintl, python, gettext, ncurses, findXMLCatalogs
, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform
, icuSupport ? false, icu ? null
, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic
, enableStatic ? !enableShared
}:

Expand Down Expand Up @@ -40,6 +40,8 @@ stdenv.mkDerivation rec {
++ lib.optional pythonSupport "py"
++ lib.optional (enableStatic && enableShared) "static";

strictDeps = true;

buildInputs = lib.optional pythonSupport python
++ lib.optional (pythonSupport && python?isPy2 && python.isPy2) gettext
++ lib.optional (pythonSupport && python?isPy3 && python.isPy3) ncurses
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/libraries/lzo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ stdenv.mkDerivation rec {
sha256 = "0wm04519pd3g8hqpjqhfr72q8qmbiwqaxcs3cndny9h86aa95y60";
};

configureFlags = [ "--enable-shared" ];
configureFlags = lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared" ;

enableParallelBuilding = true;

doCheck = true; # not cross;

strictDeps = true;

meta = with lib; {
description = "Real-time data (de)compression library";
longDescription = ''
Expand Down
10 changes: 6 additions & 4 deletions pkgs/development/libraries/zlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ stdenv.mkDerivation (rec {
# and giving nothing builds both.
# So we have 3 possible ways to build both:
# `--static --shared`, `--shared` and giving nothing.
# Of these, we choose `--shared`, only because that's
# what we did in the past and we can avoid mass rebuilds this way.
# As a result, we pass `--static` only when we want just static.
configureFlags = lib.optional (static && !shared) "--static"
# Of these, we choose `--static --shared`, for clarity and simpler
# conditions.
configureFlags = lib.optional static "--static"
++ lib.optional shared "--shared";
# We do the right thing manually, above, so don't need these.
dontDisableStatic = true;
dontAddStaticConfigureFlags = true;

# Note we don't need to set `dontDisableStatic`, because static-disabling
# works by grepping for `enable-static` in the `./configure` script
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/bolt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ EOF
# The custom `configure` script does not expect the --prefix
# option. Installation is handled by ocamlfind.
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

createFindlibDestdir = true;

Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/ocaml-modules/easy-format/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ stdenv.mkDerivation {
sha256 = "00ga7mrlycjc99gzp3bgx6iwhf7i6j8856f8xzrf1yas7zwzgzm9";
};

buildInputs = [ ocaml findlib ];
nativeBuildInputs = [ ocaml findlib ];
strictDeps = true;

createFindlibDestdir = true;

Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/ocaml-modules/gen/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ stdenv.mkDerivation {
sha256 = "14b8vg914nb0yp1hgxzm29bg692m0gqncjj43b599s98s1cwl92h";
};

buildInputs = [ ocaml findlib ocamlbuild qtest ounit ];
nativeBuildInputs = [ ocaml findlib ocamlbuild ];
buildInputs = [ qtest ounit ];
strictDeps = true;

configureFlags = [
"--enable-tests"
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/hacl-star/raw.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ stdenv.mkDerivation rec {
installTargets = "install-hacl-star-raw";

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

buildInputs = [
which
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/janestreet/buildOcamlJane.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ buildOcaml (args // {
buildInputs = [ ocaml_oasis js_build_tools opaline ] ++ buildInputs;

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

configurePhase = "./configure --prefix $out";

Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/janestreet/js-build-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ buildOcaml rec {
buildInputs = [ ocaml_oasis opaline ];

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];
configurePhase = "./configure --prefix $prefix";
installPhase = "opaline -prefix $prefix -libdir $OCAMLFIND_DESTDIR ${name}.install";

Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/javalib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ stdenv.mkDerivation rec {

configureScript = "./configure.sh";
dontAddPrefix = "true";
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

propagatedBuildInputs = [ camlzip extlib ];

Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/labltk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ stdenv.mkDerivation rec {

configureFlags = [ "--use-findlib" "--installbindir" "$(out)/bin" ];
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

buildFlags = [ "all" "opt" ];

Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/ocamlnet/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
createFindlibDestdir = true;

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

preConfigure = ''
configureFlagsArray=(
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/ocsigen-server/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ buildDunePackage rec {
configureFlags = [ "--root $(out)" "--prefix /" ];

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

postConfigure = ''
make -C src confs
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/ocaml-modules/process/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ stdenv.mkDerivation rec {
sha256 = "0m1ldah5r9gcq09d9jh8lhvr77910dygx5m309k1jm60ah9mdcab";
};

buildInputs = [ ocaml findlib ocamlbuild ];
nativeBuildInputs = [ ocaml findlib ocamlbuild ];
strictDeps = true;

createFindlibDestdir = true;

Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/ocaml-modules/sawja/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ stdenv.mkDerivation {

configureScript = "./configure.sh";
dontAddPrefix = "true";
dontAddStaticConfigureFlags = true;
configurePlatforms = [];

propagatedBuildInputs = [ javalib ];

Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/ocaml-modules/seq/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ stdenv.mkDerivation ({
sha256 = "1cjpsc7q76yfgq9iyvswxgic4kfq2vcqdlmxjdjgd4lx87zvcwrv";
};

buildInputs = [ ocaml findlib ocamlbuild ];
nativeBuildInputs = [ ocaml findlib ocamlbuild ];
strictDeps = true;

createFindlibDestdir = true;

Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/ocaml-modules/syslog/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ stdenv.mkDerivation rec {
sha256 = "1kqpc55ppzv9n555qgqpda49n7nvkqimzisyjx2a7338r7q4r5bw";
};

buildInputs = [ ocaml findlib ];
nativeBuildInputs = [ ocaml findlib ];
strictDeps = true;

buildFlags = [ "all" "opt" ];

Expand Down
6 changes: 5 additions & 1 deletion pkgs/development/ocaml-modules/wasm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ stdenv.mkDerivation rec {
sha256 = "1kp72yv4k176i94np0m09g10cviqp2pnpm7jmiq6ik7fmmbknk7c";
};

buildInputs = [ ocaml findlib ocamlbuild ];
nativeBuildInputs = [ ocaml findlib ocamlbuild ];
strictDeps = true;

# x86_64-unknown-linux-musl-ld: -r and -pie may not be used together
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";

makeFlags = [ "-C" "interpreter" ];

Expand Down
6 changes: 4 additions & 2 deletions pkgs/development/ocaml-modules/zarith/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ stdenv.mkDerivation rec {
sha256 = "1jslm1rv1j0ya818yh23wf3bb6hz7qqj9pn5fwl45y9mqyqa01s9";
};

nativeBuildInputs = [ pkg-config ];
buildInputs = [ ocaml findlib ];
nativeBuildInputs = [ pkg-config ocaml findlib ];
propagatedBuildInputs = [ gmp ];
strictDeps = true;

dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [];
configureFlags = [ "-installdir ${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib" ];

preInstall = "mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs";
Expand Down
Loading