Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,262
    • Issues 5,262
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 566
    • Merge requests 566
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16981
Closed
Open
Issue created Jul 25, 2019 by David Simmons-Duffin@davidsd

StaticPtr related linker error

Summary

I often encounter a difficult-to-localize linker error that occurs in conjunction with the use of StaticPointers. The error can go away or reappear after simple code transformations that should be trivial, like for example replacing \(_,_) -> undefined with \_ -> undefined.

Steps to reproduce

This git repository:

https://github.com/davidsd/static-ptr-linker-error

contains the smallest program I could make that exhibits the error. Tiny changes that shouldn't matter can make the error go away, and for this reason I have been unable to shrink the code further. You should be able to clone and run stack build to see the issue.

Expected behavior

When I run stack build, I see the output

.stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/linker-error-exec/linker-error-exec-tmp/Main.o:ghc_5.c:function hs_spt_init_Main: error: undefined reference to 'rcs4_closure'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building custom Setup.hs for package static-ptr-linker-error-0.1.0.0 using:
      /central/home/dssimmon/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.0.1.0 build exe:linker-error-exec --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

One can make the code compile by making small changes, for example

  • redefining closure = undefined
  • replacing \(_,_) -> undefined with \_ -> undefined in line 83
  • replacing other subexpressions with undefined
  • replacing applyRemoteStatic k a = k 'bindRemoteStatic' a with applyRemoteStatic = bindRemoteStatic in line 47 (those are supposed to be backticks, but I can't figure out how to escape them)
  • turning on -O2
  • many other ways

Environment

  • GHC version used: 8.2.2 (via lts-11.13, listed in stack.yaml)

I have also observed this issue with GHC 8.4.4 (lts-12.18).

Optional:

  • Operating System:
  • System Architecture:
Edited Jul 25, 2019 by David Simmons-Duffin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking