From eb56edbce050a9b7e74d38a68e125783ad05571c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 28 Jan 2024 10:58:14 +0100 Subject: haskellPackages.mkDerivation: remove version checks for unsupported GHC Most of the version checks for GHC can be removed, because they target versions which are not part of nixpkgs anymore. --- .../haskell-modules/generic-builder.nix | 51 ++++++++-------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'pkgs/development/haskell-modules/generic-builder.nix') diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 1819b29da460..61f39d6ee25b 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -27,10 +27,10 @@ in , buildFlags ? [] , haddockFlags ? [] , description ? null -, doCheck ? !isCross && lib.versionOlder "7.4" ghc.version +, doCheck ? !isCross , doBenchmark ? false , doHoogle ? true -, doHaddockQuickjump ? doHoogle && lib.versionAtLeast ghc.version "8.6" +, doHaddockQuickjump ? doHoogle , doInstallIntermediates ? false , editedCabalFile ? null , enableLibraryProfiling ? !(ghc.isGhcjs or false) @@ -41,7 +41,7 @@ in , enableSharedLibraries ? !stdenv.hostPlatform.isStatic && (ghc.enableShared or false) , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin , enableStaticLibraries ? !(stdenv.hostPlatform.isWindows or stdenv.hostPlatform.isWasm) -, enableHsc2hsViaAsm ? stdenv.hostPlatform.isWindows && lib.versionAtLeast ghc.version "8.4" +, enableHsc2hsViaAsm ? stdenv.hostPlatform.isWindows , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] # On macOS, statically linking against system frameworks is not supported; # see https://developer.apple.com/library/content/qa/qa1118/_index.html @@ -125,23 +125,17 @@ assert stdenv.hostPlatform.isWasm -> enableStaticLibraries == false; let - inherit (lib) optional optionals optionalString versionOlder versionAtLeast + inherit (lib) optional optionals optionalString versionAtLeast concatStringsSep enableFeature optionalAttrs; isGhcjs = ghc.isGhcjs or false; isHaLVM = ghc.isHaLVM or false; - packageDbFlag = if isGhcjs || isHaLVM || versionOlder "7.6" ghc.version - then "package-db" - else "package-conf"; # GHC used for building Setup.hs # # Same as our GHC, unless we're cross, in which case it is native GHC with the # same version, or ghcjs, in which case its the ghc used to build ghcjs. nativeGhc = buildHaskellPackages.ghc; - nativePackageDbFlag = if versionOlder "7.6" nativeGhc.version - then "package-db" - else "package-conf"; # the target dir for haddock documentation docdir = docoutput: docoutput + "/share/doc/" + pname + "-" + version; @@ -233,19 +227,19 @@ let (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names") (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}") (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp") - (enableFeature (enableDeadCodeElimination && !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs") + (enableFeature false "split-objs") (enableFeature enableLibraryProfiling "library-profiling") - (optionalString ((enableExecutableProfiling || enableLibraryProfiling) && versionOlder "8" ghc.version) "--profiling-detail=${profilingDetail}") - (enableFeature enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling")) + (optionalString (enableExecutableProfiling || enableLibraryProfiling) "--profiling-detail=${profilingDetail}") + (enableFeature enableExecutableProfiling "profiling") (enableFeature enableSharedLibraries "shared") - (optionalString (versionAtLeast ghc.version "7.10") (enableFeature doCoverage "coverage")) - (optionalString (versionOlder "8.4" ghc.version) (enableFeature enableStaticLibraries "static")) - (optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic")) - (optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests")) + (enableFeature doCoverage "coverage") + (enableFeature enableStaticLibraries "static") + (enableFeature enableSharedExecutables "executable-dynamic") + (enableFeature doCheck "tests") (enableFeature doBenchmark "benchmarks") "--enable-library-vanilla" # TODO: Should this be configurable? (enableFeature enableLibraryForGhci "library-for-ghci") - ] ++ optionals (enableDeadCodeElimination && (lib.versionOlder "8.0.1" ghc.version)) [ + ] ++ optionals (enableDeadCodeElimination) [ "--ghc-option=-split-sections" ] ++ optionals dontStrip [ "--disable-library-stripping" @@ -264,7 +258,7 @@ let postPhases = optional doInstallIntermediates "installIntermediatesPhase"; setupCompileFlags = [ - (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir") + (optionalString (!coreSetup) "-package-db=$setupPackageConfDir") (optionalString enableParallelBuilding parallelBuildingFlags) "-threaded" # https://github.com/haskell/cabal/issues/2398 "-rtsopts" # allow us to pass RTS flags to the generated Setup executable @@ -433,7 +427,7 @@ stdenv.mkDerivation ({ for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do ${buildPkgDb nativeGhc "$setupPackageConfDir"} done - ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache + ${nativeGhcCommand}-pkg --package-db="$setupPackageConfDir" recache '' # For normal components + '' @@ -445,12 +439,9 @@ stdenv.mkDerivation ({ if [ -d "$p/lib" ]; then configureFlags+=" --extra-lib-dirs=$p/lib" fi - '' - # It is not clear why --extra-framework-dirs does work fine on Linux - + optionalString (!stdenv.buildPlatform.isDarwin || versionAtLeast nativeGhc.version "8.0") '' - if [[ -d "$p/Library/Frameworks" ]]; then - configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" - fi + if [[ -d "$p/Library/Frameworks" ]]; then + configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" + fi '' + '' done '' @@ -490,7 +481,7 @@ stdenv.mkDerivation ({ sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," "$f" done '') + '' - ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache + ${ghcCommand}-pkg --package-db="$packageConfDir" recache runHook postSetupCompilerEnvironment ''; @@ -622,11 +613,7 @@ stdenv.mkDerivation ({ done ''} ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"} - ${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && lib.versionOlder ghc.version "7.10") '' - for exe in "${binDir}/"* ; do - install_name_tool -add_rpath "$out/${ghcLibdir}/${pname}-${version}" "$exe" - done - ''} + ${optionalString enableSeparateDocOutput '' for x in ${docdir "$doc"}"/html/src/"*.html; do -- cgit 1.4.1 From 9d57ec90d67eedff67fcee07acb83e18c94f8d25 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 31 Jan 2024 20:46:05 +0100 Subject: haskellPackages.mkDerivation: remove some empty lines and default arguments --- pkgs/development/haskell-modules/generic-builder.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'pkgs/development/haskell-modules/generic-builder.nix') diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 61f39d6ee25b..a248b5b11b22 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -227,7 +227,6 @@ let (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names") (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}") (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp") - (enableFeature false "split-objs") (enableFeature enableLibraryProfiling "library-profiling") (optionalString (enableExecutableProfiling || enableLibraryProfiling) "--profiling-detail=${profilingDetail}") (enableFeature enableExecutableProfiling "profiling") @@ -439,9 +438,9 @@ stdenv.mkDerivation ({ if [ -d "$p/lib" ]; then configureFlags+=" --extra-lib-dirs=$p/lib" fi - if [[ -d "$p/Library/Frameworks" ]]; then - configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" - fi + if [[ -d "$p/Library/Frameworks" ]]; then + configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" + fi '' + '' done '' @@ -614,7 +613,6 @@ stdenv.mkDerivation ({ ''} ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"} - ${optionalString enableSeparateDocOutput '' for x in ${docdir "$doc"}"/html/src/"*.html; do remove-references-to -t $out $x -- cgit 1.4.1 From 0e182841322f67cef7e03a9b266759d426a9ba4c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 4 Feb 2024 14:26:20 +0100 Subject: haskellPackages.mkDerivation: pass -split-sections when cross-compiling This works around #286285 by passing --enable-split-sections instead of ghc-options. --- pkgs/development/haskell-modules/generic-builder.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pkgs/development/haskell-modules/generic-builder.nix') diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index a248b5b11b22..b772dc434e60 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -238,8 +238,7 @@ let (enableFeature doBenchmark "benchmarks") "--enable-library-vanilla" # TODO: Should this be configurable? (enableFeature enableLibraryForGhci "library-for-ghci") - ] ++ optionals (enableDeadCodeElimination) [ - "--ghc-option=-split-sections" + (enableFeature enableDeadCodeElimination "split-sections") ] ++ optionals dontStrip [ "--disable-library-stripping" "--disable-executable-stripping" -- cgit 1.4.1 From a2083c748faa18d883aca5ebb7aaacd6da1c461d Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 7 Feb 2024 09:11:40 +0100 Subject: haskellPackages.mkDerivation: refactor to use enableFeature for stripping --- pkgs/development/haskell-modules/generic-builder.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pkgs/development/haskell-modules/generic-builder.nix') diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index b772dc434e60..bc77736f6265 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -239,9 +239,8 @@ let "--enable-library-vanilla" # TODO: Should this be configurable? (enableFeature enableLibraryForGhci "library-for-ghci") (enableFeature enableDeadCodeElimination "split-sections") - ] ++ optionals dontStrip [ - "--disable-library-stripping" - "--disable-executable-stripping" + (enableFeature (!dontStrip) "library-stripping") + (enableFeature (!dontStrip) "executable-stripping") ] ++ optionals isGhcjs [ "--ghcjs" ] ++ optionals isCross ([ -- cgit 1.4.1