From 9b067c31fc4a5b9a3a26448bfc98eaa594dba99d Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Fri, 2 Sep 2022 22:04:25 -0700 Subject: [PATCH 1/4] maintainers: add impl --- maintainers/maintainer-list.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 3efd6efcefaa..2a4db2937cac 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -5625,6 +5625,16 @@ githubId = 510202; name = "Ismaƫl Bouya"; }; + impl = { + email = "noah@noahfontes.com"; + matrix = "@impl:matrix.org"; + github = "impl"; + githubId = 41129; + name = "Noah Fontes"; + keys = [{ + fingerprint = "F5B2 BE1B 9AAD 98FE 2916 5597 3665 FFF7 9D38 7BAA"; + }]; + }; imsofi = { email = "sofi+git@mailbox.org"; github = "imsofi"; From 6f8378e6fa60209c733703dd25365687217d2581 Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Thu, 1 Sep 2022 21:26:04 -0700 Subject: [PATCH 2/4] jam: fix cross compilation This change makes sure that the cross-compiler target prefix gets passed to both the Makefile (for bootstrapping) and Jamfile (for the second-phase build). --- .../tools/build-managers/jam/default.nix | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/build-managers/jam/default.nix b/pkgs/development/tools/build-managers/jam/default.nix index c4d73785db49..4d8f82d1a337 100644 --- a/pkgs/development/tools/build-managers/jam/default.nix +++ b/pkgs/development/tools/build-managers/jam/default.nix @@ -11,17 +11,12 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ bison ]; + # Jambase expects ar to have flags. preConfigure = '' - unset AR + export AR="$AR rc" ''; - buildPhase = '' - runHook preBuild - - make jam0 - - runHook postBuild - ''; + makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; installPhase = '' runHook preInstall @@ -39,7 +34,7 @@ stdenv.mkDerivation rec { homepage = "https://www.perforce.com/resources/documentation/jam"; license = licenses.free; description = "Just Another Make"; - maintainers = with maintainers; [ orivej ]; + maintainers = with maintainers; [ impl orivej ]; platforms = platforms.unix; }; } From 3c0eaeb84cf5d2516f152beae399212771bed2ec Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Thu, 1 Sep 2022 22:14:12 -0700 Subject: [PATCH 3/4] ftjam: unify build steps with jam There are only a few minor differences between the way ftjam and jam work from a build perspective, so we can use a common base for them. --- .../tools/build-managers/jam/default.nix | 93 +++++++++++++------ .../tools/build-managers/jam/ftjam.nix | 53 ----------- pkgs/top-level/all-packages.nix | 6 +- 3 files changed, 66 insertions(+), 86 deletions(-) delete mode 100644 pkgs/development/tools/build-managers/jam/ftjam.nix diff --git a/pkgs/development/tools/build-managers/jam/default.nix b/pkgs/development/tools/build-managers/jam/default.nix index 4d8f82d1a337..0156b60660ca 100644 --- a/pkgs/development/tools/build-managers/jam/default.nix +++ b/pkgs/development/tools/build-managers/jam/default.nix @@ -1,40 +1,73 @@ { lib, stdenv, fetchurl, bison }: -stdenv.mkDerivation rec { - pname = "jam"; - version = "2.6.1"; +let + mkJam = { meta ? { }, ... } @ args: stdenv.mkDerivation (args // { + nativeBuildInputs = [ bison ]; - src = fetchurl { - url = "https://swarm.workshop.perforce.com/projects/perforce_software-jam/download/main/${pname}-${version}.tar"; - sha256 = "19xkvkpycxfsncxvin6yqrql3x3z9ypc1j8kzls5k659q4kv5rmc"; + # Jambase expects ar to have flags. + preConfigure = '' + export AR="$AR rc" + ''; + + installPhase = '' + runHook preInstall + + ./jam0 -j$NIX_BUILD_CORES -sBINDIR=$out/bin install + mkdir -p $out/doc/jam + cp *.html $out/doc/jam + + runHook postInstall + ''; + + enableParallelBuilding = true; + + meta = with lib; meta // { + license = licenses.free; + mainProgram = "jam"; + platforms = platforms.unix; + }; + }); +in +{ + jam = let + pname = "jam"; + version = "2.6.1"; + in mkJam { + inherit pname version; + + makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; + + src = fetchurl { + url = "https://swarm.workshop.perforce.com/projects/perforce_software-jam/download/main/${pname}-${version}.tar"; + sha256 = "19xkvkpycxfsncxvin6yqrql3x3z9ypc1j8kzls5k659q4kv5rmc"; + }; + + meta = with lib; { + description = "Just Another Make"; + homepage = "https://www.perforce.com/resources/documentation/jam"; + maintainers = with maintainers; [ impl orivej ]; + }; }; - nativeBuildInputs = [ bison ]; + ftjam = let + pname = "ftjam"; + version = "2.5.2"; + in mkJam { + inherit pname version; - # Jambase expects ar to have flags. - preConfigure = '' - export AR="$AR rc" - ''; + postPatch = '' + substituteInPlace Jamfile --replace strip ${stdenv.cc.targetPrefix}strip + ''; - makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; + src = fetchurl { + url = "https://downloads.sourceforge.net/project/freetype/${pname}/${version}/${pname}-${version}.tar.bz2"; + hash = "sha256-6JdzUAqSkS3pGOn+v/q+S2vOedaa8ZRDX04DK4ptZqM="; + }; - installPhase = '' - runHook preInstall - - ./jam0 -j$NIX_BUILD_CORES -sBINDIR=$out/bin install - mkdir -p $out/doc/jam - cp *.html $out/doc/jam - - runHook postInstall - ''; - - enableParallelBuilding = true; - - meta = with lib; { - homepage = "https://www.perforce.com/resources/documentation/jam"; - license = licenses.free; - description = "Just Another Make"; - maintainers = with maintainers; [ impl orivej ]; - platforms = platforms.unix; + meta = with lib; { + description = "FreeType's enhanced, backwards-compatible Jam clone"; + homepage = "https://freetype.org/jam/"; + maintainers = with maintainers; [ AndersonTorres impl ]; + }; }; } diff --git a/pkgs/development/tools/build-managers/jam/ftjam.nix b/pkgs/development/tools/build-managers/jam/ftjam.nix deleted file mode 100644 index 1f106401c0d1..000000000000 --- a/pkgs/development/tools/build-managers/jam/ftjam.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ lib -, stdenv -, fetchurl -, bison -}: - -stdenv.mkDerivation rec { - pname = "ftjam"; - version = "2.5.2"; - - src = fetchurl { - url = "https://downloads.sourceforge.net/project/freetype/${pname}/${version}/${pname}-${version}.tar.bz2"; - hash = "sha256-6JdzUAqSkS3pGOn+v/q+S2vOedaa8ZRDX04DK4ptZqM="; - }; - - nativeBuildInputs = [ - bison - ]; - - preConfigure = '' - unset AR - ''; - - buildPhase = '' - runHook preBuild - - make jam0 - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - ./jam0 -j$NIX_BUILD_CORES -sBINDIR=$out/bin install - mkdir -p $out/doc/jam - cp *.html $out/doc/jam - - runHook postInstall - ''; - - enableParallelBuilding = true; - - meta = with lib; { - description = "Freetype's enhanced, backwards-compatible Jam clone"; - homepage = "https://freetype.org/jam/"; - license = licenses.free; - maintainers = with maintainers; [ AndersonTorres ]; - mainProgram = "jam"; - platforms = platforms.unix; - }; -} -# TODO: setup hook for Jam diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8ff267fbc334..8f510c26884d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16461,9 +16461,9 @@ with pkgs; itstool = callPackage ../development/tools/misc/itstool { }; - jam = callPackage ../development/tools/build-managers/jam { }; - - ftjam = callPackage ../development/tools/build-managers/jam/ftjam.nix { }; + inherit (callPackage ../development/tools/build-managers/jam { }) + jam + ftjam; javacc = callPackage ../development/tools/parsing/javacc { jdk = jdk8; From 4d4d4587ec31b1d722c8aa8074026144c5927b36 Mon Sep 17 00:00:00 2001 From: Noah Fontes Date: Sun, 4 Sep 2022 21:36:58 -0700 Subject: [PATCH 4/4] {jam,ftjam}: cross-compile without binfmt_misc Jam is bootstrapped and then recompiled, which requires us to customize the build as the upstream doesn't understand cross compilation. We first build the bootstrap under the build platform, then rebuild any source files again using the build platform, and finally build the target binary separately. --- .../tools/build-managers/jam/default.nix | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/pkgs/development/tools/build-managers/jam/default.nix b/pkgs/development/tools/build-managers/jam/default.nix index 0156b60660ca..192c27682ab5 100644 --- a/pkgs/development/tools/build-managers/jam/default.nix +++ b/pkgs/development/tools/build-managers/jam/default.nix @@ -1,7 +1,8 @@ -{ lib, stdenv, fetchurl, bison }: +{ lib, stdenv, fetchurl, bison, buildPackages }: let mkJam = { meta ? { }, ... } @ args: stdenv.mkDerivation (args // { + depsBuildBuild = [ buildPackages.stdenv.cc ]; nativeBuildInputs = [ bison ]; # Jambase expects ar to have flags. @@ -9,13 +10,21 @@ let export AR="$AR rc" ''; + LOCATE_TARGET = "bin.unix"; + + buildPhase = '' + runHook preBuild + make $makeFlags jam0 + ./jam0 -j$NIX_BUILD_CORES -sCC=${buildPackages.stdenv.cc.targetPrefix}cc jambase.c + ./jam0 -j$NIX_BUILD_CORES + runHook postBuild + ''; + installPhase = '' runHook preInstall - - ./jam0 -j$NIX_BUILD_CORES -sBINDIR=$out/bin install - mkdir -p $out/doc/jam + mkdir -p $out/bin $out/doc/jam + cp bin.unix/jam $out/bin/jam cp *.html $out/doc/jam - runHook postInstall ''; @@ -35,8 +44,6 @@ in in mkJam { inherit pname version; - makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; - src = fetchurl { url = "https://swarm.workshop.perforce.com/projects/perforce_software-jam/download/main/${pname}-${version}.tar"; sha256 = "19xkvkpycxfsncxvin6yqrql3x3z9ypc1j8kzls5k659q4kv5rmc"; @@ -55,15 +62,23 @@ in in mkJam { inherit pname version; - postPatch = '' - substituteInPlace Jamfile --replace strip ${stdenv.cc.targetPrefix}strip - ''; - src = fetchurl { url = "https://downloads.sourceforge.net/project/freetype/${pname}/${version}/${pname}-${version}.tar.bz2"; hash = "sha256-6JdzUAqSkS3pGOn+v/q+S2vOedaa8ZRDX04DK4ptZqM="; }; + postPatch = '' + substituteInPlace Jamfile --replace strip ${stdenv.cc.targetPrefix}strip + ''; + + # Doesn't understand how to cross compile once bootstrapped, so we'll just + # use the Makefile for the bootstrapping portion. + configurePlatforms = [ "build" "target" ]; + configureFlags = [ + "CC=${buildPackages.stdenv.cc.targetPrefix}cc" + "--host=${stdenv.buildPlatform.config}" + ]; + meta = with lib; { description = "FreeType's enhanced, backwards-compatible Jam clone"; homepage = "https://freetype.org/jam/";