Opened 4 years ago

Closed 2 years ago

Last modified 18 months ago

#7452 closed bug (fixed)

[GNU gold] ld: error: cannot find [...]/Types__1.o

Reported by: mrothe Owned by:
Priority: normal Milestone: 7.10.1
Component: Build System Version: 7.6.1
Keywords: Cc: gidyn
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


/usr/bin/ld is gold linker and I am trying to compile GHC 7.6.1 using it. I grabbed GHC 7.6.1 from and edited settings; i.e. removing --hash-size=31 and --reduce-memory-overheads.

While running make the linker cannot find some object files:

$ make
===--- building phase 0
make -r --no-print-directory -f phase=0 phase_0_builds
make[1]: Nothing to be done for `phase_0_builds'.
===--- building phase 1
make -r --no-print-directory -f phase=1 phase_1_builds
make[1]: Nothing to be done for `phase_1_builds'.
===--- building final phase
make -r --no-print-directory -f phase=final all
/usr/bin/xsltproc  docs/man/flags.xsl docs/man/flags.xml > docs/man/ghc.1
  HC [stage 0] utils/hp2ps/dist/build/tmp/hp2ps
Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main.
    Call hs_init_ghc() from your main() function to set these options.
"cp" -p utils/hp2ps/dist/build/tmp/hp2ps inplace/bin/hp2ps
  HC [stage 0] utils/genapply/dist/build/tmp/genapply
"cp" -p utils/genapply/dist/build/tmp/genapply inplace/bin/genapply
  HC [stage 1] libraries/ghc-prim/dist-install/build/GHC/Types.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__1.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__2.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__3.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__4.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__5.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__6.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__7.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__8.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__9.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__10.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__11.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__12.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__13.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__14.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__15.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__16.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__17.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__18.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__19.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__20.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__21.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__22.o
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Types_o_split/Types__23.o
collect2: error: ld returned 1 exit status
make[1]: *** [libraries/ghc-prim/dist-install/build/GHC/Types.o] Error 1
make: *** [all] Error 2

All object files that cannot be found are present and switching /usr/bin/ld to the bfd linker solves the problem.

Attachments (2)

gold-absolute-path.diff (622 bytes) - added by slomo 2 years ago.
0001-Use-absolute-paths-in-GNU-ld-linker-scripts.patch (1.2 KB) - added by slomo 2 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 4 years ago by mrothe

The above description is not quite correct: I'm using the binary from [1] in order to compile the sources from, because the binaries from require an old version of gmp.


comment:2 Changed 4 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1
  • Priority changed from normal to high

Thanks for the report. We'll take a look.

comment:3 Changed 3 years ago by gidyn

  • Cc gideon@… added

I'm being hit by this (using the official 7.6.3 binary distribution to compile the sources), although it used to work. I have no idea what's changed in the meantime.

comment:4 Changed 3 years ago by gidyn

The gold linker doesn't understand relative paths. This also effects building anything with -split-objs, see

comment:6 follow-up: Changed 3 years ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1
  • Priority changed from high to normal
  • Status changed from new to infoneeded

Since this looks like a binutils bug, I'm lowering priority and moving out of 7.8.3 - can we do anything to help?

comment:7 in reply to: ↑ 6 Changed 3 years ago by octoploid

Replying to thoughtpolice:

Since this looks like a binutils bug, I'm lowering priority and moving out of 7.8.3 - can we do anything to help?

Sure. Just don't use relative paths in linker scripts. Use full paths instead.

Changed 2 years ago by slomo

comment:8 Changed 2 years ago by slomo

The attached patch against 7.8.3 works around this by always putting absolute paths to the .o files into the linker script. Works with gold but should also just work fine with bfd (but I didn't test that).

comment:9 Changed 2 years ago by thoughtpolice

  • Status changed from infoneeded to patch

comment:10 Changed 2 years ago by Austin Seipp <austin@…>

In 021b7978d14799bae779907faf7490cfd21b3f46/ghc:

driver: use absolute paths in ld scripts (#7452)

Patch contributed by slowmo.

Signed-off-by: Austin Seipp <>

comment:11 Changed 2 years ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from patch to closed

comment:12 Changed 18 months ago by gidyn

  • Cc gideon@… removed

comment:13 Changed 18 months ago by gidyn

  • Cc gidyn added
Note: See TracTickets for help on using tickets.