Bug#1125305: ghc: DSO DT_NEEDED ordering issues reproducibility problem
Jochen Sprickerhof
jspricke at debian.org
Mon Jan 12 10:55:41 GMT 2026
Package: ghc
Version: 9.10.3-1
Severity: normal
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org
User: reproducible-builds at lists.alioth.debian.org
Usertags: randomness
Hi,
we see a number of reproducibility regressions of Haskell packages on
reproduce.debian.net where the linked shared libraries are in a
different order. For example:
│ │ ├── ./usr/lib/haskell-packages/ghc/lib/aarch64-linux-ghc-9.10.3-98d9/libHSfast-logger-3.2.6-LyYTgPSYEd64scJh7XG7qd-ghc9.10.3.so
│ │ │┄ File has been modified after NT_GNU_BUILD_ID has been applied.
│ │ │ ├── readelf --wide --dynamic {}
│ │ │ │ @@ -1,34 +1,34 @@
│ │ │ │
│ │ │ │ Dynamic section at offset 0x4f9b8 contains 58 entries:
│ │ │ │ Tag Type Name/Value
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHStext-2.1.3-54f8-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSauto-update-0.2.6-1k2gXzjv1IO47cMPEOTACz-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSeasy-file-0.2.5-IgVZCl11gbNHDIWZv87z6o-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSdirectory-1.3.8.5-8546-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSunix-time-0.4.17-BEvWzcSeWkGB8GkMahqg2p-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSold-time-1.1.0.4-KiWCneuM5JdGrQ6yBG4I8D-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSold-locale-1.0.0.7-6rxVRR51oKCJikTZOJLRQt-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSbinary-0.8.9.3-acc1-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHScontainers-0.7-15ad-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSunix-compat-0.7.4.1-86RO4YoLR3DL7aJ8cPb6Xn-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSdirectory-1.3.8.5-8546-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSunix-2.8.7.0-8dad-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHStime-1.12.2-5137-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSfilepath-1.5.4.0-c84d-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSos-string-2.0.7-e950-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSexceptions-0.10.9-b548-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSstm-2.5.3.1-8d78-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSmtl-2.3.1-f904-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHStransformers-0.6.1.1-86ae-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSunix-time-0.4.17-BEvWzcSeWkGB8GkMahqg2p-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSold-time-1.1.0.4-KiWCneuM5JdGrQ6yBG4I8D-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSold-locale-1.0.0.7-6rxVRR51oKCJikTZOJLRQt-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHSbinary-0.8.9.3-acc1-ghc9.10.3.so]
│ │ │ │ - 0x0000000000000001 (NEEDED) Shared library: [libHScontainers-0.7-15ad-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSbytestring-0.12.2.0-a0a4-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHStemplate-haskell-2.22.0.0-7589-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSpretty-1.1.3.6-ab72-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSghc-boot-th-9.10.3-c0cf-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSdeepseq-1.5.0.0-9baa-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSauto-update-0.2.6-1k2gXzjv1IO47cMPEOTACz-ghc9.10.3.so]
│ │ │ │ + 0x0000000000000001 (NEEDED) Shared library: [libHSstm-2.5.3.1-8d78-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSarray-0.5.8.0-c618-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSbase-4.20.2.0-6a67-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSghc-internal-9.1003.0-30ff-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSghc-bignum-1.3-4172-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libHSghc-prim-0.12.0-90d3-ghc9.10.3.so]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libgmp.so.10]
│ │ │ │ 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
https://reproduce.debian.net/arm64/api/v1/builds/97592/artifacts/206086/diffoscope
I was able to reproduce this with:
$ sbuild --chroot-mode=unshare --dist=unstable haskell-fast-logger
$ debrebuild --buildresult=out --builder=sbuild+unshare --cache=cache \
haskell-fast-logger_3.2.6-1_amd64.buildinfo
But this works only sometimes.
I found that reproducibility depends on the content of
/var/lib/ghc/package.conf.d/package.cache. From my understanding the
content of the package.cache depends on the install order of the Debian
packages as ghc.postinst has a dpkg-trigger and does ghc-pkg recache
--global. Specifically I captured a chroot.tar as generated from
debrebuild/debootsnap where the package was not reproducible and
exchanged the package.cache from one where it was reproducible and it
fixed the issue.
Next I tested calling ghc -lfoo -lbar and ghc -lbar -lfoo directly and
found that the command line order is preserved in the DT_NEEDED but that
is already the case in stable so my conclusion was that this is not the
regression with the new ghc version in unstable we see.
So I created a minimal example with cabal:
$ mkdir -p haskell/{foo,bar,baz}
$ cd haskell/foo/
$ cabal init --non-interactive --lib --dependency=base --package-name=foo
$ cd ../bar/
$ cabal init --non-interactive --lib --dependency=base --package-name=bar
$ cd ../baz/
$ cabal init --non-interactive --lib --dependency=base,foo,bar --package-name=baz
$ cd ..
$ echo 'packages: */*.cabal */' > cabal.project
$ cabal build foo
$ cabal build baz
$ ldd dist-newstyle/build/x86_64-linux/ghc-*/baz-0.1.0.0/build/libHSbaz-0.1.0.0-inplace-*.so
[..]
libHSfoo-0.1.0.0-inplace-ghc9.10.3.so => /home/jspricke/haskell/dist-newstyle/build/x86_64-linux/ghc-9.10.3/foo-0.1.0.0/build/libHSfoo-0.1.0.0-inplace-ghc9.10.3.so (0x00007f787a138000)
libHSbar-0.1.0.0-inplace-ghc9.10.3.so => /home/jspricke/haskell/dist-newstyle/build/x86_64-linux/ghc-9.10.3/bar-0.1.0.0/build/libHSbar-0.1.0.0-inplace-ghc9.10.3.so (0x00007f787a133000)
$ rm -r dist-newstyle/
$ cabal build bar
$ cabal build baz
$ ldd dist-newstyle/build/x86_64-linux/ghc-*/baz-0.1.0.0/build/libHSbaz-0.1.0.0-inplace-*.so
[..]
libHSbar-0.1.0.0-inplace-ghc9.10.3.so => /home/jspricke/haskell/dist-newstyle/build/x86_64-linux/ghc-9.10.3/bar-0.1.0.0/build/libHSbar-0.1.0.0-inplace-ghc9.10.3.so (0x00007fc869fb4000)
libHSfoo-0.1.0.0-inplace-ghc9.10.3.so => /home/jspricke/haskell/dist-newstyle/build/x86_64-linux/ghc-9.10.3/foo-0.1.0.0/build/libHSfoo-0.1.0.0-inplace-ghc9.10.3.so (0x00007fc869faf000)
Whereas on Debian stable the output is the same both times. I assume
that this is again due to the package.cache in dist-newstyle/packagedb/.
I used the container images from [1] to bisect the problem and found
that it is reproducible with the latest available version (9.12.2) as
well as with 9.8.4 but not with 9.6.7, so I assume the change happened
between those versions. Also note that the cabal-install version is the
same (3.14.1.1) in both containers so I assume it is not the cause of
the bug.
Filling this on the Debian side for the tracking, can you please forward
it upstream in case?
Thanks!
Jochen
P.S.: This issue is to fix the Debian package reproducibility, if you
could make the package.cache reproducible, that would be awesome as
well.
[1] https://hub.docker.com/_/haskell/
-- System Information:
Debian Release: forky/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.18.3+deb14-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages ghc depends on:
ii dpkg 1.23.3
ii gcc 4:15.2.0-4
ii libbsd-dev 0.12.2-2
ii libc6 2.42-7
ii libc6-dev 2.42-7
ii libffi-dev 3.5.2-3
ii libffi8 3.5.2-3
ii libgmp-dev 2:6.3.0+dfsg-5
ii libgmp10 2:6.3.0+dfsg-5
ii libncurses-dev 6.6+20251231-1
ii libnuma-dev 2.0.19-1
ii libnuma1 2.0.19-1
ii libtinfo6 6.6+20251231-1
Versions of packages ghc recommends:
ii libstdc++-15-dev 15.2.0-12
Versions of packages ghc suggests:
ii clang-21 1:21.1.8-1+b1
pn ghc-doc <none>
pn ghc-prof <none>
pn llvm-21 <none>
ii perl 5.40.1-7
-- no debconf information
More information about the Reproducible-bugs
mailing list