Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,326
    • Issues 4,326
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 390
    • Merge Requests 390
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12076

Closed
Open
Opened May 16, 2016 by Edward Z. Yang@ezyangDeveloper

"lazy" leads to undefined reference to `stg_ap_0_upd_info'

This is basically the same thing as #11155 (closed) but triggered differently.

-- M.hs
{-# OPTIONS_GHC -O0 #-}
module M(f) where

import GHC.Exts

{-# NOINLINE z #-}
z = ()

f :: () -> ()
f _ = let x = lazy z
      in g x x

{-# NOINLINE g #-}
g :: () -> () -> ()
g _ _ = ()

-- MM.hs
import M
main = f `seq` return ()

On GHC 8.0, I get:

ezyang@sabre:~$ ghc-8.0 --make MM.hs -fforce-recomp
[1 of 2] Compiling M                ( M.hs, M.o )
[2 of 2] Compiling Main             ( MM.hs, MM.o )
Linking MM ...
./M.o: In function `r2aD_info':
(.text+0x4a): undefined reference to `stg_ap_0_upd_info'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

Error goes away when you turn on optimization. My understanding is that removing lazy in CorePrep is too late, because there's no pass afterwards that eliminates the trivial thunk assignment. Here's the STG:

z_r2aC :: ()
[GblId, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] =
    NO_CCS ()! [];

g_r2aD :: () -> () -> ()
[GblId, Arity=2, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] =
    sat-only \r srt:SRT:[] [ds_s2rW ds1_s2rX] () [];

M.f :: () -> ()
[GblId, Arity=1, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] =
    \r srt:SRT:[] [ds_s2rY]
        let {
          x_s2rZ :: ()
          [LclId, Str=DmdType, Unf=OtherCon []] =
              \u srt:SRT:[] [] z_r2aC;
        } in  g_r2aD x_s2rZ x_s2rZ;

so we need, instead, something like x_s2rZ = z_r2aC.

This is blocking D2211, where the insertion of a noinline (which is optimized out similarly to lazy) triggers a stage 2 linker failure when you don't compile with optimization (unfortunately, this is NOT caught validate since we build GHC with optimization... but with this test it will be!)

Perhaps there should be an ASSERT in the codegen so it doesn't create this symbol?

Edited Mar 10, 2019 by Edward Z. Yang
Assignee
Assign to
8.0.2
Milestone
8.0.2 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12076