The comment for the line removed by this patch states that "A threaded
perl build needs glibc/libpthread_nonshared.a, which is not included
in bootstrapTools". This is not the reason why it is necessary --
libpthread_nonshared.a part of the bootstrap-files on many platforms.
The reason why this workaround was needed is because nuke-refs erases
the rpath from libpthread.so, and unpack-bootstrap-tools.sh neglects
to undo this using patchelf. Let's apply patchelf to libpthread.so,
so we aren't leaving dangling /nix/store/eeee.... refs in
libpthread.so, and remove the enableThreading=false override since it
is no longer necessary.
Additional background:
The enableThreading=false attribute not only removes the
"-Dusethreads" from the invocation of perl's Configure script, it also
patches the script like this:
# We need to do this because the bootstrap doesn't have a static libpthread
sed -i 's,\(libswanted.*\)pthread,\1,g' Configure
Although this prevents the perl interpreter from linking against
libpthread.so, it does not prevent the libraries bundled with the
interpreter from doing so. Time/HiRes/HiRes.so will still try to link
against libpthread.so, and is only prevented from doing so by the fact
that unpack-bootstrap-tools.sh neglects to patchelf out all of the
nuke-refs'd rpaths. When all of the nuke-refs'd paths are patchelf'ed
out, HiRes.so links against libpthread.so in the bootstrap tools, and
the stdenv bootstrap fails:
Can't load '/nix/store/7ny8kmppjzx6kx4xr5kphjz8fqqrlsll-perl-5.34.1/lib/perl5/5.34.1/x86_64-linux/auto/Time/HiRes/HiRes.so' for module Time::HiRes: libpthread.so.0: cannot open shared object file: No such file or directory at /nix/store/7ny8kmppjzx6kx4xr5kphjz8fqqrlsll-perl-5.34.1/lib/perl5/5.34.1/XSLoader.pm line 93.
at /nix/store/7ny8kmppjzx6kx4xr5kphjz8fqqrlsll-perl-5.34.1/lib/perl5/5.34.1/x86_64-linux/Time/HiRes.pm line 94.
Compilation failed in require at lib/Autom4te/FileUtils.pm line 42.
BEGIN failed--compilation aborted at lib/Autom4te/FileUtils.pm line 42.
Compilation failed in require at bin/autom4te line 46.
BEGIN failed--compilation aborted at bin/autom4te line 46.
make[1]: *** [Makefile:2259: tests/wrapper.in] Error 2
make[1]: *** Waiting for unfinished jobs....
Perl implements its own custom library loading routines for its
modules, which likely do not fully implement rpath searching.
This problem was revealed during the course of writing PR #161925,
which depends on this PR in order to pass CI.