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

pkgsStatic.buildPackages.haskell.compiler.ghc96 fail to build #208959

Closed
sternenseemann opened this issue Jan 4, 2023 · 20 comments
Closed

pkgsStatic.buildPackages.haskell.compiler.ghc96 fail to build #208959

sternenseemann opened this issue Jan 4, 2023 · 20 comments
Labels
0.kind: regression Something that worked before working no longer 6.topic: haskell 6.topic: static

Comments

@sternenseemann
Copy link
Member

@nix { "action": "setPhase", "phase": "buildPhase" }
building
hadrianFlags: --flavour=release+fully_static+no_dynamic_ghc+split_sections --bignum=gmp --docs=no-sphinx -j4
�]0;Starting...��[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "binary", pkgPath = "libraries/binary"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "bytestring", pkgPath = "libraries/bytestring"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "Cabal-syntax", pkgPath = "libraries/Cabal/Cabal-syntax"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "Cabal", pkgPath = "libraries/Cabal/Cabal"})))�[0m
�[34m�[0m| Successfully generated compiler/ghc.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc", pkgPath = "compiler"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "containers", pkgPath = "libraries/containers/containers"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "directory", pkgPath = "libraries/directory"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "process", pkgPath = "libraries/process"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "exceptions", pkgPath = "libraries/exceptions"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "filepath", pkgPath = "libraries/filepath"})))�[0m
�[34m�[0m| Successfully generated libraries/ghc-boot/ghc-boot.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-boot", pkgPath = "libraries/ghc-boot"})))�[0m
�[34m�[0m| Successfully generated libraries/ghc-boot-th/ghc-boot-th.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-boot-th", pkgPath = "libraries/ghc-boot-th"})))�[0m
�[34m�[0m| Successfully generated libraries/ghc-heap/ghc-heap.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-heap", pkgPath = "libraries/ghc-heap"})))�[0m
�[34m�[0m| Successfully generated libraries/ghci/ghci.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghci", pkgPath = "libraries/ghci"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "hpc", pkgPath = "libraries/hpc"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "mtl", pkgPath = "libraries/mtl"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "parsec", pkgPath = "libraries/parsec"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "time", pkgPath = "libraries/time"})))�[0m
�[34m�[0m| Successfully generated libraries/template-haskell/template-haskell.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "template-haskell", pkgPath = "libraries/template-haskell"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "text", pkgPath = "libraries/text"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "transformers", pkgPath = "libraries/transformers"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "unix", pkgPath = "libraries/unix"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "array", pkgPath = "libraries/array"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "base", pkgPath = "libraries/base"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "deepseq", pkgPath = "libraries/deepseq"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-bignum", pkgPath = "libraries/ghc-bignum"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-compact", pkgPath = "libraries/ghc-compact"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "ghc-prim", pkgPath = "libraries/ghc-prim"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "haskeline", pkgPath = "libraries/haskeline"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "integer-gmp", pkgPath = "libraries/integer-gmp"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "pretty", pkgPath = "libraries/pretty"})))�[0m
�[34m�[0m| Successfully generated rts/rts.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "rts", pkgPath = "rts"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "stm", pkgPath = "libraries/stm"})))�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Library, pkgName = "xhtml", pkgPath = "libraries/xhtml"})))�[0m
�[34m�[0m| Configure package 'bytestring'�[0m�[0m
�[34m�[0m| Configure package 'ghc-prim'�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Program, pkgName = "hp2ps", pkgPath = "utils/hp2ps"})))�[0m
�[34m�[0m| Configure package 'ghc-heap'�[0m�[0m
�[34m�[0m| Configure package 'parsec'�[0m�[0m
�[34m�[0m| Configure package 'hpc'�[0m�[0m
�[34m�[0m| Configure package 'deepseq'�[0m�[0m
�[34m�[0m| Configure package 'ghc-boot-th'�[0m�[0m
�[34m�[0m| Configure package 'rts'�[0m�[0m
�[34m�[0m| Configure package 'process'�[0m�[0m
�[34m�[0m| Configure package 'integer-gmp'�[0m�[0m
�[34m�[0m| Configure package 'array'�[0m�[0m
�[34m�[0m| Configure package 'time'�[0m�[0m
�[34m�[0m| Configure package 'unix'�[0m�[0m
�[34m�[0m| Configure package 'mtl'�[0m�[0m
�[34m�[0m| Configure package 'transformers'�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Program, pkgName = "unlit", pkgPath = "utils/unlit"})))�[0m
�[34m�[0m| Configure package 'stm'�[0m�[0m
�[34m�[0m| Configure package 'ghci'�[0m�[0m
�[34m�[0m| Configure package 'directory'�[0m�[0m
�[34m�[0m| Copy file: driver/ghc-usage.txt => _build/stage1/lib/ghc-usage.txt�[0m�[0m
�[34m�[0m| Configure package 'containers'�[0m�[0m
�[34m�[0m| Configure package 'binary'�[0m�[0m
�[34m�[0m| Configure package 'Cabal'�[0m�[0m
�[34m�[0m| Configure package 'ghc-compact'�[0m�[0m
�[34m�[0m| Configure package 'text'�[0m�[0m
�[34m�[0m| Configure package 'Cabal-syntax'�[0m�[0m
�[34m�[0m| Configure package 'pretty'�[0m�[0m
�[34m�[0m| Configure package 'hp2ps'�[0m�[0m
�[34m�[0m| Configure package 'xhtml'�[0m�[0m
�[34m�[0m| System GMP library/framework will be used�[0m�[0m
�[34m�[0m| Configure package 'filepath'�[0m�[0m
�[34m�[0m| Configure package 'base'�[0m�[0m
�[34m�[0m| Copy file: driver/ghci-usage.txt => _build/stage1/lib/ghci-usage.txt�[0m�[0m
�[34m�[0m| Successfully generated ghc/ghc-bin.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Program, pkgName = "ghc-bin", pkgPath = "ghc"})))�[0m
�[34m�[0m| Configure package 'exceptions'�[0m�[0m
�[34m�[0m| Configure package 'unlit'�[0m�[0m
�[34m�[0m| Successfully generated utils/ghc-pkg/ghc-pkg.cabal from its template�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Program, pkgName = "ghc-pkg", pkgPath = "utils/ghc-pkg"})))�[0m
�[34m�[0m| Configure package 'haskeline'�[0m�[0m
�[34m�[0m| Run GhcPkg Recache (Stage0 InTreeLibs): none => none�[0m�[0m
�[34m�[0m| Copy file: mk/system-cxx-std-lib-1.0.conf => _build/stage1/lib/package.conf.d/system-cxx-std-lib-1.0.conf�[0m�[0m
�[34m�[0m| Copy file: llvm-passes => _build/stage1/lib/llvm-passes�[0m�[0m
�[34m�[0m| Copy file: llvm-targets => _build/stage1/lib/llvm-targets�[0m�[0m
�[34m�[0m| Configure package 'template-haskell'�[0m�[0m
�[34m# cabal-read (for OracleQ (PackageDataKey (Package {pkgType = Program, pkgName = "hsc2hs", pkgPath = "utils/hsc2hs"})))�[0m
�[34m�[0m| Copy file: libraries/ghc-bignum/gmp/ghc-gmp.h => _build/stage1/libraries/ghc-bignum/build/include/ghc-gmp.h�[0m�[0m
�[34m�[0m| Configure package 'ghc-bignum'�[0m�[0m
�[34m�[0m| Configure package 'ghc-boot'�[0m�[0m
�[34m�[0m| Copy file: utils/hsc2hs/data/template-hsc.h => _build/stage1/lib/template-hsc.h�[0m�[0m
�[34m�[0m| Successfully generated _build/stage1/lib/settings.�[0m�[0m
�[34m# cabal-configure (for _build/stage0/utils/unlit/setup-config)�[0m
�[34m�[0m| Configure package 'ghc'�[0m�[0m
�[34m�[0m| Configure package 'ghc-boot'�[0m�[0m
�[34m�[0m| Configure package 'exceptions'�[0m�[0m
�[34m�[0m| Configure package 'bytestring'�[0m�[0m
�[34m�[0m| Configure package 'mtl'�[0m�[0m
�[34m�[0m| Configure package 'unlit'�[0m�[0m
�[34m�[0m| Run GhcPkg Recache (Stage0 GlobalLibs): none => none�[0m�[0m
�[34m�[0m| Configure package 'transformers'�[0m�[0m
�[34m�[0m| Configure package 'unix'�[0m�[0m
�[34m�[0m| Configure package 'ghc-boot-th'�[0m�[0m
�[34m�[0m| Configure package 'time'�[0m�[0m
�[34m# cabal-configure (for _build/stage0/libraries/ghc-boot-th/setup-config)�[0m
�[34m�[0m| Copy file: driver/ghc-usage.txt => _build/stage0/lib/ghc-usage.txt�[0m�[0m
�[34m�[0m| Copy file: driver/ghci-usage.txt => _build/stage0/lib/ghci-usage.txt�[0m�[0m
�[34m�[0m| Configure package 'Cabal-syntax'�[0m�[0m
�[34m�[0m| Configure package 'ghc-heap'�[0m�[0m
�[34m# cabal-configure (for _build/stage0/libraries/time/setup-config)�[0m
�[34m# cabal-configure (for _build/stageBoot/utils/unlit/setup-config)�[0m
�[34m�[0m| Configure package 'containers'�[0m�[0m
�[34m�[0m| Configure package 'template-haskell'�[0m�[0m
�[34m# cabal-autogen (for _build/stage0/libraries/ghc-boot-th/build/autogen/cabal_macros.h)�[0m
�[34m�[0m| Configure package 'binary'�[0m�[0m
�[34m�[0m| Run Cc (FindCDependencies CDep) (Stage0 InTreeLibs): utils/unlit/unlit.c => _build/stage0/utils/unlit/build/c/unlit.o.d�[0m�[0m
�[34m�[0m| Copy file: mk/system-cxx-std-lib-1.0.conf => _build/stage0/lib/package.conf.d/system-cxx-std-lib-1.0.conf�[0m�[0m
�[34m�[0m| Copy file: llvm-targets => _build/stage0/lib/llvm-targets�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): base�[0m�[0m
�[34m�[0m| Copy file: llvm-passes => _build/stage0/lib/llvm-passes�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): base�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): ghc-prim�[0m�[0m
�[34m# cabal-autogen (for _build/stage0/utils/unlit/build/unlit/autogen/cabal_macros.h)�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): ghc-bignum�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): ghc-prim�[0m�[0m
�[34m�[0m| Run Cc (FindCDependencies CDep) (Stage0 InTreeLibs): utils/unlit/fs.c => _build/stage0/utils/unlit/build/c/fs.o.d�[0m�[0m
�[34m�[0m| Run Ghc CompileCWithGhc (Stage0 InTreeLibs): utils/unlit/unlit.c => _build/stage0/utils/unlit/build/c/unlit.o�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): ghc-bignum�[0m�[0m
�[34m�[0m| Run Ghc CompileCWithGhc (Stage0 InTreeLibs): utils/unlit/fs.c => _build/stage0/utils/unlit/build/c/fs.o�[0m�[0m
�[34m�[0m| Configure package 'parsec'�[0m�[0m
�[34m�[0m| Successfully generated _build/stage0/lib/settings.�[0m�[0m
�[34m�[0m| Configure package 'ghc'�[0m�[0m
�[34m�[0m| Configure package 'hpc'�[0m�[0m
�[34m�[0m| Configure package 'ghci'�[0m�[0m
�[34m�[0m| Configure package 'Cabal'�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): rts�[0m�[0m
�[34m�[0m| Run GhcPkg Unregister (Stage0 InTreeLibs): rts => none�[0m�[0m
�[34m# cabal-configure (for _build/stage0/libraries/transformers/setup-config)�[0m
�[34m�[0m| Run Cc (FindCDependencies CDep) (Stage0 GlobalLibs): utils/unlit/unlit.c => _build/stageBoot/utils/unlit/build/c/unlit.o.d�[0m�[0m
�[34m# cabal-autogen (for _build/stageBoot/utils/unlit/build/unlit/autogen/cabal_macros.h)�[0m
�[34m�[0m| Run Ghc CompileCWithGhc (Stage0 GlobalLibs): utils/unlit/unlit.c => _build/stageBoot/utils/unlit/build/c/unlit.o�[0m�[0m
�[34m�[0m| Run GhcPkg Recache (Stage0 InTreeLibs): none => none�[0m�[0m
�[34m�[0m| Run GhcPkg Dependencies (Stage0 InTreeLibs): rts�[0m�[0m
�[34m�[0m| Run GhcPkg Unregister (Stage0 InTreeLibs): rts => none�[0m�[0m
�[34m�[0m| Configure package 'process'�[0m�[0m
�[34m�[0m| Configure package 'directory'�[0m�[0m
�[34m# cabal-configure (for _build/stage0/utils/hp2ps/setup-config)�[0m
�[34m�[0m| Run GhcPkg Copy (Stage0 InTreeLibs): rts => _build/stage0/lib/package.conf.d/rts.conf�[0m�[0m
�[34m�[0m| Run Ghc LinkHs (Stage0 InTreeLibs): _build/stage0/utils/unlit/build/c/fs.o (and 1 more) => _build/stage0/bin/x86_64-unknown-linux-musl-unlit�[0m�[0m
�[31mCommand line: /nix/store/4gqivrz4j75995gpf2qr930sgscp9yz6-ghc-binary-9.2.4/bin/ghc -Wall -Wcompat -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/lib/package.conf.d' '-this-unit-id unlit-0.1' -i -i/build/ghc-a5bd0eb/_build/stage0/utils/unlit/build -i/build/ghc-a5bd0eb/_build/stage0/utils/unlit/build/unlit/autogen -i/build/ghc-a5bd0eb/utils/unlit -I_build/stage0/utils/unlit/build -optP-include -optP_build/stage0/utils/unlit/build/unlit/autogen/cabal_macros.h -outputdir _build/stage0/utils/unlit/build -fdiagnostics-color=always -no-auto-link-packages -no-hs-main -optc-Wno-error=inline -optP-Wno-nonportable-include-path _build/stage0/utils/unlit/build/c/fs.o _build/stage0/utils/unlit/build/c/unlit.o -o _build/stage0/bin/x86_64-unknown-linux-musl-unlit -O -H64m -XHaskell2010 -optl -static�[0m
�[31m===> Command failed with error code: 1�[0m
/nix/store/frh9l9nrdysasdi2gs7i241s241ngjw2-binutils-2.39/bin/ld: cannot find -lc: No such file or directory
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
�]0;Finished in 2.34s�Command failed
�[31mBuild failed.�[0m

Full log:
static-ghc-head-log.txt

@sternenseemann sternenseemann added 6.topic: haskell 0.kind: regression Something that worked before working no longer labels Jan 4, 2023
@sternenseemann sternenseemann changed the title pkgsStatic.buildPackages.haskell.compiler.ghcHEAD fails to build pkgsStatic.buildPackages.haskell.compiler.{ghc96,ghcHEAD} fail to build Apr 3, 2023
@Artturin
Copy link
Member

Artturin commented Jul 21, 2023

pkgsStatic.buildPackages.haskell.compiler.gc96 now fails with

x86_64-unknown-linux-musl-ghc> # cabal-copy (for _build/stage1/lib/package.conf.d/haskeline-0.8.2.1.conf)
x86_64-unknown-linux-musl-ghc> | Run GhcPkg Recache Stage1: none => none
x86_64-unknown-linux-musl-ghc> 0;Finished in 25m21sError, rule finished running but did not produce file:
x86_64-unknown-linux-musl-ghc>   _build/stage1/lib/x86_64-linux-ghc-9.6.2/libHSrts-1.0.2_thr_debug-ghc9.6.2.so
x86_64-unknown-linux-musl-ghc> Build failed.

@sternenseemann sternenseemann changed the title pkgsStatic.buildPackages.haskell.compiler.{ghc96,ghcHEAD} fail to build pkgsStatic.buildPackages.haskell.compiler.ghc96 fail to build Jan 8, 2024
sternenseemann added a commit that referenced this issue Jan 10, 2024
GHC 9.6 doesn't build with static rts etc. with hadrian:
#208959

Using GHC 9.4 is a bit safer than 9.8, since packages are generally more
likely to build with the older GHC.
@domenkozar
Copy link
Member

We probably need to use a newer ghc for bootstrapping.

@sternenseemann
Copy link
Member Author

Your welcome to try that, I believe it's probably a bug in hadrian for 9.6.

@alt-romes
Copy link

alt-romes commented Jan 11, 2024

How could I reproduce this locally? I'm not very familiar with nix.

@sternenseemann
Copy link
Member Author

Build pkgsStatic.buildPackages.haskell.compiler.ghc96.

@sternenseemann
Copy link
Member Author

Reproducing this outside of nixpkgs may be difficult if that's what you are asking, since you won't have cc-wrapper (a shell wrapper around gcc/clang which does a couple of things for us), so things will probably work out differently.

My currently inclination is that the bug would show itself like this:

  • You have built hadrian with finalStage = Stage1 in UserSettings.hs
  • You pass --flavour=release+fully_static+no_dynamic_ghc+split_sections --bignum=gmp
  • Hadrian still builds/tries to build shared objects for libraries like rts.

This issue is somehow solved in 9.8, so maybe looking at the commit history for hadrian may also have some hints. If there are no plans for a 9.6.5, I don't think it is worth investigating though.

@NorfairKing
Copy link
Contributor

NorfairKing commented Jun 3, 2024

@sternenseemann this is the default ghc for nixos-24.05, so I'd really like this to be fixed.
I like my static builds :D

@sternenseemann
Copy link
Member Author

Static builds via the intended interface (pkgsStatic) use GHC 9.4.8 on unstable and 24.05 which works fine.

@NorfairKing
Copy link
Contributor

NorfairKing commented Jun 3, 2024

@sternenseemann that would require me to support two different ghc versions depending on whether I want to statically link.
Can we get static linking work with the same default ghc version?

@NorfairKing
Copy link
Contributor

NorfairKing commented Jun 3, 2024

I found that this works and does what I want, but I have no idea why:

pkgsMusl.ghc.override
                  {
                    # To make sure that executables that need template
                    # haskell can be linked statically.
                    enableRelocatedStaticLibs = true;
                    # We can't turn this to false because this build is broken for ghc 9.6.5.
                    # You can turn this to false, as is supposed to, once this issue is fixed:
                    # https://github.com/NixOS/nixpkgs/issues/316850#issuecomment-2144824536
                    # or once ghc is upgraded
                    enableShared = true;
                    # In order to not get undefined references to elf_strptr, elf_rawdata etc,
                    # as a result of the above we need to turn this to false:
                    enableDwarf = false;
                  }

Edit: Actually that doesn't work when using template haskell so I still need a real fix.

@sternenseemann
Copy link
Member Author

Edit: Actually that doesn't work when using template haskell so I still need a real fix.

The magic/hacky solution for static TemplateHaskell no longer works with GHC >= 9.6, probably due to Hadrian as well. Hence, we are using GHC 9.4 by default which has none of these problems.

We have some leads (#275304), but no solution has presented itself so far.

@NorfairKing
Copy link
Contributor

@sternenseemann are you sure it's not > 9.6 instead of >= 9.6 because I still saw the old error described here: https://cs-syd.eu/posts/2024-04-20-static-linking-haskell-nix

@sternenseemann
Copy link
Member Author

I don't know. It seems likely though that were it possible to build 9.6 without dynamic libs, the same sort of problem would crop up as with 9.8.

@ParetoOptimalDev
Copy link

I wasn't going to say anything, but there is a small chance it's relevant. I have a devenv (not pure nix) project I was trying to build with ghc 9.8 today and despite having postgresql in the dependencies I get:

`cc' failed in phase `Linker'. (Exit code: 1) /nix/store/v71nlgkf8g6d36gac9r44pmlx54mdql3-binutils-2.41/bin/ld.gold: error: cannot find -lpq

It seems possible this is related to dynamic/static libs, but I haven't tried reproducing with vanilla nix to verify.

@NorfairKing
Copy link
Contributor

@sternenseemann are you sure it's not > 9.6 instead of >= 9.6 because I still saw the old error described here: https://cs-syd.eu/posts/2024-04-20-static-linking-haskell-nix

I just got it working with 9.6.5 in #316850 (comment)

Can we backport this fix?

@sternenseemann
Copy link
Member Author

That patch seems like a no-brainer build system bug fix, so it would be acceptable to backport.

@NorfairKing
Copy link
Contributor

@sternenseemann How would I go about applying that ? I've only had terrible experiences with nixpkgs contributions and I don't have commit access. Could you apply it?

@NorfairKing
Copy link
Contributor

While we're working on fixing this in #317175, you can work around this problem like this:

                  ghc.override {
                    # To make sure that executables that need template
                    # haskell can be linked statically.
                    enableRelocatedStaticLibs = true;
                    enableShared = false;
                    enableDwarf = false;
                    # Until https://github.com/NixOS/nixpkgs/pull/317175
                    srcOnly = args: pkgs.srcOnly (args // {
                      patches = (args.patches or [ ]) ++ [
                        (final.fetchpatch {
                          url = "https://gitlab.haskell.org/ghc/ghc/-/commit/1bb24432ff77e11a0340a7d8586e151e15bba2a1.diff";
                          hash = "sha256-MpvTmFFsNiPDoOp9BhZyWeapeibQ77zgEV+xzZ1UAXs=";
                        })
                      ];
                    });
                  }

@nh2
Copy link
Contributor

nh2 commented Jun 15, 2024

Should this be closed by the merged #317175 ?

@sternenseemann
Copy link
Member Author

#275304 remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: regression Something that worked before working no longer 6.topic: haskell 6.topic: static
Development

No branches or pull requests

8 participants