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

ocaml: enable parallel building #142723

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 14 additions & 1 deletion pkgs/development/compilers/ocaml/4.00.1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ stdenv.mkDerivation rec {

prefixKey = "-prefix ";
configureFlags = [ "-no-tk" ] ++ optionals useX11 [ "-x11lib" xlibsWrapper ];
buildFlags = [ "world" ] ++ optionals useNativeCompilers [ "bootstrap" "world.opt" ];

# Older versions have some race:
# cp: cannot stat 'boot/ocamlrun': No such file or directory
# make[2]: *** [Makefile:199: backup] Error 1
enableParallelBuilding = lib.versionAtLeast version "4.06";

# Workaround lack of parallelism support among top-level targets:
# we place nixpkgs-specific targets to a separate file and set
# sequential order among them as a single rule.
makefile = ./Makefile.nixpkgs;
buildFlags = if useNativeCompilers
then ["nixpkgs_world_bootstrap_world_opt"]
else ["nixpkgs_world"];

buildInputs = [ ncurses ] ++ optional useX11 xlibsWrapper;
installTargets = "install" + optionalString useNativeCompilers " installopt";
preConfigure = ''
Expand Down
16 changes: 16 additions & 0 deletions pkgs/development/compilers/ocaml/Makefile.nixpkgs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ocaml build system does not allow for parallel building of some
# top-level targets like 'world', 'bootstrap', 'world.opt' as
# then spawn '$(MAKE) all' subprocesses that conflict among each
# other. But we would still like to run each target in parallel
# individually. This file defines such entry points.

# Re-export all existing phases to make 'make install' work as is.
include Makefile

nixpkgs_world:
$(MAKE) world

nixpkgs_world_bootstrap_world_opt:
$(MAKE) world
$(MAKE) bootstrap
$(MAKE) world.opt
13 changes: 12 additions & 1 deletion pkgs/development/compilers/ocaml/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ stdenv.mkDerivation (args // {
# 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" ];
# Older versions have some race:
# cp: cannot stat 'boot/ocamlrun': No such file or directory
# make[2]: *** [Makefile:199: backup] Error 1
enableParallelBuilding = lib.versionAtLeast version "4.06";

# Workaround lack of parallelism support among top-level targets:
# we place nixpkgs-specific targets to a separate file and set
# sequential order among them as a single rule.
makefile = ./Makefile.nixpkgs;
buildFlags = if useNativeCompilers
then ["nixpkgs_world_bootstrap_world_opt"]
else ["nixpkgs_world"];
buildInputs = optional (!lib.versionAtLeast version "4.07") ncurses
++ optionals useX11 [ libX11 xorgproto ];
propagatedBuildInputs = optional spaceTimeSupport libunwind;
Expand Down