Linking error from TypeData and StrictData on GHC 9.6.4 on Linux
Summary
Compiling a program containing a type constructor defined via TypeData
with arity >= 1 results in a linker failure when the StrictData
extension is enabled on GHC 9.6.4, on Linux.
The environment reported below is for a NixOS machine, though the issue also reproduces on Ubuntu 20.04 LTS.
Steps to reproduce
-- Main.hs
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeData #-}
module Main where
type data Nat = Zero | Succ Nat
main :: IO ()
main = pure ()
> ghc Main.hs
[1 of 2] Compiling Main ( Main.hs, Main.o )
[2 of 2] Linking Main
Main.o:function Main_zdWSucc_info:(.text+0x5a): error: undefined reference to 'Main_Succ_con_info'
collect2: error: ld returned 1 exit status
ghc-9.6.4: `cc' failed in phase `Linker'. (Exit code: 1)
Expected behavior
The program builds without linking errors.
Environment
- GHC version used: 9.6.4
Optional:
-
Operating System: NixOS (and also Ubuntu 20.04 LTS, details not reported)
-
System Architecture:
> uname -m
x86_64
- Linker:
> ld -v
GNU ld (GNU Binutils) 2.40
- C compiler:
> cc -v
Using built-in specs.
COLLECT_GCC=/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/bin/gcc
COLLECT_LTO_WRAPPER=/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-12.3.0/configure --prefix=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gcc-12.3.0 --with-gmp-include=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gmp-6.3.0-dev/include --with-gmp-lib=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gmp-6.3.0/lib --with-mpfr-include=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-mpfr-4.2.1-dev/include --with-mpfr-lib=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-mpfr-4.2.1/lib --with-mpc=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-libmpc-1.3.1 --with-native-system-header-dir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.38-44-dev/include --with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch --without-included-gettext --with-system-zlib --enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin --disable-libcc1 --with-isl=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-isl-0.20 --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.3.0 (GCC)