Merge pull request #311671 from onemoresuza/hare-fix-makeflags

hare: fix makeflags

authored by Aleksana and committed by GitHub c68fb0f3 5903ac45

+85 -64
+85 -64
pkgs/by-name/ha/hare/package.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchFromSourcehut 4 - , binutils-unwrapped 5 - , harec 6 - , makeWrapper 7 - , qbe 8 - , gitUpdater 9 - , scdoc 10 - , tzdata 11 - , substituteAll 12 - , fetchpatch 13 - , callPackage 14 - , enableCrossCompilation ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.is64bit) 15 - , pkgsCross 16 - , x86_64PkgsCrossToolchain ? pkgsCross.gnu64 17 - , aarch64PkgsCrossToolchain ? pkgsCross.aarch64-multiplatform 18 - , riscv64PkgsCrossToolchain ? pkgsCross.riscv64 19 }: 20 21 # There's no support for `aarch64` or `riscv64` for freebsd nor for openbsd on nix. 22 # See `lib.systems.doubles.aarch64` and `lib.systems.doubles.riscv64`. 23 - assert let 24 - inherit (stdenv.hostPlatform) isLinux is64bit; 25 - inherit (lib) intersectLists platforms concatStringsSep; 26 - workingPlatforms = intersectLists platforms.linux (with platforms; x86_64 ++ aarch64 ++ riscv64); 27 - in 28 - (enableCrossCompilation -> !(isLinux && is64bit)) 29 -> builtins.throw '' 30 - The cross-compilation toolchains may only be enabled on the following platforms: 31 - ${concatStringsSep "\n" workingPlatforms} 32 - ''; 33 34 let 35 arch = stdenv.hostPlatform.uname.processor; 36 - qbePlatform = { 37 - x86_64 = "amd64_sysv"; 38 - aarch64 = "arm64"; 39 - riscv64 = "rv64"; 40 - }.${arch}; 41 platform = lib.toLower stdenv.hostPlatform.uname.system; 42 embeddedOnBinaryTools = 43 let 44 - genToolsFromToolchain = toolchain: 45 let 46 crossTargetPrefix = toolchain.stdenv.cc.targetPrefix; 47 toolchainArch = toolchain.stdenv.hostPlatform.uname.processor; 48 - absOrRelPath = toolDrv: toolBasename: 49 - if arch == toolchainArch then toolBasename 50 - else lib.getExe' toolDrv "${crossTargetPrefix}${toolBasename}"; 51 in 52 { 53 "ld" = absOrRelPath toolchain.buildPackages.binutils "ld"; ··· 65 pname = "hare"; 66 version = "0.24.0"; 67 68 - outputs = [ "out" "man" ]; 69 70 src = fetchFromSourcehut { 71 owner = "~sircmpwn"; ··· 88 # Don't build haredoc since it uses the build `hare` bin, which breaks 89 # cross-compilation. 90 ./002-dont-build-haredoc.patch 91 ]; 92 93 nativeBuildInputs = [ ··· 104 tzdata 105 ]; 106 107 - makeFlags = [ 108 - "HARECACHE=.harecache" 109 - "PREFIX=${builtins.placeholder "out"}" 110 - "ARCH=${arch}" 111 - "VERSION=${finalAttrs.version}-nixpkgs" 112 - "QBEFLAGS=-t${qbePlatform}" 113 - "CC=${stdenv.cc.targetPrefix}cc" 114 - "AS=${stdenv.cc.targetPrefix}as" 115 - "LD=${stdenv.cc.targetPrefix}ld" 116 - # Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does 117 - # not follow the FHS. 118 - "HAREPATH=$(SRCDIR)/hare/stdlib" 119 - ] ++ lib.optionals enableCrossCompilation [ 120 - "RISCV64_AS=${embeddedOnBinaryTools.riscv64.as}" 121 - "RISCV64_CC=${embeddedOnBinaryTools.riscv64.cc}" 122 - "RISCV64_LD=${embeddedOnBinaryTools.riscv64.ld}" 123 - "AARCH64_AS=${embeddedOnBinaryTools.aarch64.as}" 124 - "AARCH64_CC=${embeddedOnBinaryTools.aarch64.cc}" 125 - "AARCH64_LD=${embeddedOnBinaryTools.aarch64.ld}" 126 - "x86_64_AS=${embeddedOnBinaryTools.x86_64.as}" 127 - "x86_64_CC=${embeddedOnBinaryTools.x86_64.cc}" 128 - "x86_64_LD=${embeddedOnBinaryTools.x86_64.ld}" 129 - ]; 130 131 enableParallelBuilding = true; 132 ··· 143 144 postFixup = '' 145 wrapProgram $out/bin/hare \ 146 - --prefix PATH : ${lib.makeBinPath [binutils-unwrapped harec qbe]} 147 ''; 148 149 setupHook = ./setup-hook.sh; ··· 151 passthru = { 152 updateScript = gitUpdater { }; 153 tests = lib.optionalAttrs enableCrossCompilation { 154 - crossCompilation = callPackage ./cross-compilation-tests.nix { 155 - hare = finalAttrs.finalPackage; 156 - }; 157 }; 158 }; 159
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromSourcehut, 5 + binutils-unwrapped, 6 + harec, 7 + makeWrapper, 8 + qbe, 9 + gitUpdater, 10 + scdoc, 11 + tzdata, 12 + substituteAll, 13 + fetchpatch, 14 + callPackage, 15 + enableCrossCompilation ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.is64bit), 16 + pkgsCross, 17 + x86_64PkgsCrossToolchain ? pkgsCross.gnu64, 18 + aarch64PkgsCrossToolchain ? pkgsCross.aarch64-multiplatform, 19 + riscv64PkgsCrossToolchain ? pkgsCross.riscv64, 20 }: 21 22 # There's no support for `aarch64` or `riscv64` for freebsd nor for openbsd on nix. 23 # See `lib.systems.doubles.aarch64` and `lib.systems.doubles.riscv64`. 24 + assert 25 + let 26 + inherit (stdenv.hostPlatform) isLinux is64bit; 27 + inherit (lib) intersectLists platforms concatStringsSep; 28 + workingPlatforms = intersectLists platforms.linux (with platforms; x86_64 ++ aarch64 ++ riscv64); 29 + in 30 + (enableCrossCompilation -> !(isLinux && is64bit)) 31 -> builtins.throw '' 32 + The cross-compilation toolchains may only be enabled on the following platforms: 33 + ${concatStringsSep "\n" workingPlatforms} 34 + ''; 35 36 let 37 arch = stdenv.hostPlatform.uname.processor; 38 + qbePlatform = 39 + { 40 + x86_64 = "amd64_sysv"; 41 + aarch64 = "arm64"; 42 + riscv64 = "rv64"; 43 + } 44 + .${arch}; 45 platform = lib.toLower stdenv.hostPlatform.uname.system; 46 embeddedOnBinaryTools = 47 let 48 + genToolsFromToolchain = 49 + toolchain: 50 let 51 crossTargetPrefix = toolchain.stdenv.cc.targetPrefix; 52 toolchainArch = toolchain.stdenv.hostPlatform.uname.processor; 53 + absOrRelPath = 54 + toolDrv: toolBasename: 55 + if arch == toolchainArch then 56 + toolBasename 57 + else 58 + lib.getExe' toolDrv "${crossTargetPrefix}${toolBasename}"; 59 in 60 { 61 "ld" = absOrRelPath toolchain.buildPackages.binutils "ld"; ··· 73 pname = "hare"; 74 version = "0.24.0"; 75 76 + outputs = [ 77 + "out" 78 + "man" 79 + ]; 80 81 src = fetchFromSourcehut { 82 owner = "~sircmpwn"; ··· 99 # Don't build haredoc since it uses the build `hare` bin, which breaks 100 # cross-compilation. 101 ./002-dont-build-haredoc.patch 102 + # Display toolchains when using `hare version -v`. 103 + (fetchpatch { 104 + url = "https://git.sr.ht/~sircmpwn/hare/commit/e35f2284774436f422e06f0e8d290b173ced1677.patch"; 105 + hash = "sha256-A59bGO/9tOghV8/MomTxd8xRExkHVdoMom2d+HTfQGg="; 106 + }) 107 ]; 108 109 nativeBuildInputs = [ ··· 120 tzdata 121 ]; 122 123 + makeFlags = 124 + [ 125 + "HARECACHE=.harecache" 126 + "PREFIX=${builtins.placeholder "out"}" 127 + "ARCH=${arch}" 128 + "VERSION=${finalAttrs.version}-nixpkgs" 129 + "QBEFLAGS=-t${qbePlatform}" 130 + "AS=${stdenv.cc.targetPrefix}as" 131 + "LD=${stdenv.cc.targetPrefix}ld" 132 + # Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does 133 + # not follow the FHS. 134 + "HAREPATH=$(SRCDIR)/hare/stdlib" 135 + ] 136 + ++ lib.optionals enableCrossCompilation [ 137 + "RISCV64_AS=${embeddedOnBinaryTools.riscv64.as}" 138 + "RISCV64_CC=${embeddedOnBinaryTools.riscv64.cc}" 139 + "RISCV64_LD=${embeddedOnBinaryTools.riscv64.ld}" 140 + "AARCH64_AS=${embeddedOnBinaryTools.aarch64.as}" 141 + "AARCH64_CC=${embeddedOnBinaryTools.aarch64.cc}" 142 + "AARCH64_LD=${embeddedOnBinaryTools.aarch64.ld}" 143 + "X86_64_AS=${embeddedOnBinaryTools.x86_64.as}" 144 + "X86_64_CC=${embeddedOnBinaryTools.x86_64.cc}" 145 + "X86_64_LD=${embeddedOnBinaryTools.x86_64.ld}" 146 + ]; 147 148 enableParallelBuilding = true; 149 ··· 160 161 postFixup = '' 162 wrapProgram $out/bin/hare \ 163 + --prefix PATH : ${ 164 + lib.makeBinPath [ 165 + binutils-unwrapped 166 + harec 167 + qbe 168 + ] 169 + } 170 ''; 171 172 setupHook = ./setup-hook.sh; ··· 174 passthru = { 175 updateScript = gitUpdater { }; 176 tests = lib.optionalAttrs enableCrossCompilation { 177 + crossCompilation = callPackage ./cross-compilation-tests.nix { hare = finalAttrs.finalPackage; }; 178 }; 179 }; 180