diff --git a/pkgs/development/compilers/ocaml/Makefile.nixpkgs b/pkgs/development/compilers/ocaml/Makefile.nixpkgs new file mode 100644 index 000000000000..2d6457852fc9 --- /dev/null +++ b/pkgs/development/compilers/ocaml/Makefile.nixpkgs @@ -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 diff --git a/pkgs/development/compilers/ocaml/generic.nix b/pkgs/development/compilers/ocaml/generic.nix index cd1bccd1800f..51c45616d395 100644 --- a/pkgs/development/compilers/ocaml/generic.nix +++ b/pkgs/development/compilers/ocaml/generic.nix @@ -78,7 +78,18 @@ stdenv.mkDerivation (args // { hardeningDisable = lib.optional (lib.versionAtLeast version "4.09" && stdenv.hostPlatform.isMusl) "pie" ++ lib.optionals (args ? hardeningDisable) args.hardeningDisable; - 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.08"; + + # 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;