Opened 5 years ago

Closed 4 years ago

#10110 closed bug (fixed)

Compiling unit fails with Loading temp shared object failed

Reported by: trommler Owned by:
Priority: high Milestone: 7.10.2
Component: Template Haskell Version: 7.10.1-rc2
Keywords: Cc: hvr
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: #10058 Differential Rev(s): Phab:D731, Phab:D791, Phab:D895
Wiki Page:


@goldfire reported in #10058 in comment 1 another failure:

[43 of 55] Compiling Tests.Compile.UnitParser ( Tests/Compile/UnitParser.hs, dist/build/main/main-tmp/Tests/Compile/UnitParser.o )

<no location info>:

ghc: panic! (the 'impossible' happened)

(GHC version for x86_64-unknown-linux):

Loading temp shared object failed: /tmp/ghc6444_0/ undefined symbol: DataziMetrologyziSIziUnits_zdfShowHectare_closure

Please report this as a GHC bug:

While on the surface this looks like a duplicate of #10058 it is not. The issue is only on Linux (travis to be precise), not OSX. Looking at the undefined symbol, here we see a symbol from the current module whereas in #10058 the undefined symbol lives in one of the packages.

My theory is that the travis machine is running a modified link editor that defaults to --as-needed being set whereas the binutils default is -no-as-needed.

Change History (17)

comment:1 Changed 5 years ago by trommler

Owner: set to trommler

comment:2 Changed 5 years ago by trommler

Here is the full build log

comment:3 Changed 5 years ago by trommler

Component: GHCiTemplate Haskell

comment:4 Changed 5 years ago by goldfire

Priority: normalhighest

If Travis can't test packages, that's pretty bad for GHC. Bumping priority accordingly. I think this should hold up a release.

comment:5 Changed 5 years ago by hvr

IIRC Travis still runs Ubuntu 12.04LTS

comment:6 Changed 5 years ago by trommler

Differential Rev(s): Phab:D731
Status: newpatch

I have a patch that does what I described in this ticket.

I cannot reproduce the issue though because singletons fails with this

ghc: panic! (the 'impossible' happened)
  (GHC version 7.11.20150313 for x86_64-unknown-linux):
        StgCmmEnv: variable not found
  local binds for:

Please report this as a GHC bug:

I will create a new ticket for this.

comment:7 Changed 5 years ago by Herbert Valerio Riedel <hvr@…>

In 1b7f59769052fd8193c6acc561216e070d0ca335/ghc:

Link temporary shared objects with `--no-as-needed`

Some ELF link editors default to `--as-needed` and record only
those libraries in DT_NEEDED tags that are needed to resolve
undefined symbols in the shared object to be created.

In Template Haskell we rely on all symbols that were defined
in modules compiled so far to be available in the current
temporary shared object. To prevent the link editor from
dropping the DT_NEEDED tag for the previously linked temporary
shared object we need to override the link editors default and
specify `--no-as-needed` on the command line. This is for GNU ld
and GOLD ld.

This addresses #10110

TODO: regression test

Reviewed By: hvr

Differential Revision:

comment:8 in reply to:  7 Changed 5 years ago by hvr

Replying to Herbert Valerio Riedel <hvr@…>:

In changeset:"1b7f59769052fd8193c6acc561216e070d0ca335/ghc"

...merged to ghc-7.10 via 3ea349220c3b72c97530c32c767e278570d497e4

So the only thing missing to close this ticket is a regression-test...

comment:9 Changed 5 years ago by trommler

Removing patch state. Herbert landed the Differential and merged it into 7.10.

Last edited 5 years ago by trommler (previous) (diff)

comment:10 Changed 4 years ago by thoughtpolice


Moving to GHC 7.10.2.

comment:11 Changed 4 years ago by Austin Seipp <austin@…>

In 13a0d5ac95a80e8b3604e084ae189da405a47270/ghc:

clarify --no-as-needed is only needed on ELF

From the code it was not clear that `--no-as-needed` was not necessary
on Windows. Add this fact and describe the fix for #10110 in a separate

See audit for rGHC1b7f59769052fd8193c6acc561216e070d0ca335 raised
by @thomie.

Reviewed By: thomie

Differential Revision:

GHC Trac Issues: #10110

comment:12 Changed 4 years ago by thoughtpolice

Differential Rev(s): Phab:D731Phab:D731, Phab:D791
Owner: trommler deleted
Priority: highesthigh
Status: patchnew

comment:13 Changed 4 years ago by thoughtpolice

Owner: set to trommler

comment:14 Changed 4 years ago by trommler

Differential Rev(s): Phab:D731, Phab:D791Phab:D731, Phab:D791, Phab:D895
Status: newpatch

Added regression test in Phab:D895

comment:15 Changed 4 years ago by trommler

Owner: trommler deleted

comment:16 Changed 4 years ago by Austin Seipp <austin@…>

In 85bf9e49f5ab4e0681eeda2549dbd4b5faf3ef7f/ghc:

Add regression test for #10110.

Module C imports a from Module A and b from module B. B does not
import anything from A. So if ld is configured to drop DT_NEEDED
tags for libraries it does not depend on no DT_NEEDED tag for the
temporary shared object containing module A is recorded in the temp
SO containing module B. This leads to an undefined symbol when
linking the temp SO for module C.

Fixes #10110.

Reviewed By: austin

Differential Revision:

GHC Trac Issues: #10110

comment:17 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: patchclosed

Merged to ghc-7.10!

Note: See TracTickets for help on using tickets.