Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate symbol definition linker error #70

Open
thomasjm opened this issue Feb 28, 2018 · 2 comments
Open

Duplicate symbol definition linker error #70

thomasjm opened this issue Feb 28, 2018 · 2 comments

Comments

@thomasjm
Copy link

I have a Windows project that's organized using the standard template generated by stack new nowadays, with

  1. a library section with the majority of the dependencies and source files
  2. a short executable which depends on the library, and
  3. a test suite which depends on the library.

In the library section, I have a module which uses inline-c to do a simple Windows system call.

The main executable builds successfully if I run stack build. But, when I try to run stack test I get a linker error:

...
[41 of 41] Compiling AppMain          ( app\AppMain.hs, .stack-work\dist\5c8418a7\build\AppMain.o )
Preprocessing test suite 'hite-test' for hite-0.1.0.0..
Building test suite 'hite-test' for hite-0.1.0.0..
[ 1 of 45] Compiling Paths_hite       ( .stack-work\dist\5c8418a7\build\hite-test\autogen\Paths_hite.hs, .stack-work\dist\5c8418a7\build\hite-test\hite-test-tmp\Paths_hite.o )
[ 2 of 45] Compiling Test.CollaborationTests.CursoringTests ( test\Test\CollaborationTests\CursoringTests.hs, .stack-work\dist\5c8418a7\build\hite-test\hite-test-tmp\Test\CollaborationTests\CursoringTests.o )
GHC runtime linker: fatal error: I found a duplicate definition for symbol
   inline_c_OSCompat_Interrupt_0
whilst processing object file
   C:\Users\tom\hite\hite\.stack-work\dist\5c8418a7\build\HShite-0.1.0.0-IDiA7VshXkO53Edvdb5QZc.o
The symbol was previously defined in
   C:\Users\tom\hite\hite\.stack-work\install\2d3db291\lib\x86_64-windows-ghc-8.2.2\hite-0.1.0.0-HQALbSItfMOFfZeOJxQ9T2\HShite-0.1.0.0-HQALbSItfMOFfZeOJxQ9T2.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
ghc.EXE: panic! (the 'impossible' happened)
  (GHC version 8.2.2 for x86_64-unknown-mingw32):
        loadObj "C:\\Users\\tom\\hite\\hite\\.stack-work\\dist\\5c8418a7\\build\\HShite-0.1.0.0-IDiA7VshXkO53Edvdb5QZc.o": failed

I'm guessing that somehow the C file is getting generated/linked twice, once for the main library/executable and once for the test suite. I've tried a NOINLINE pragma but it didn't help. I'm not sure if it's significant that one symbol is in .stack-work\install and one is in .stack-work\dist.

This is also slightly hard to reproduce -- for a little while it disappeared and the test suite ran fine, then it started happening again. I tried to make a minimal repro project but have so far failed to reproduce in a simpler setting. I've tried some combinations of stack clean and re-building but no luck.

Any chance you can shed any light on this? Thanks!

@tolysz
Copy link
Contributor

tolysz commented Mar 1, 2018

Which lts are you using?

if impl(ghc < 8.2)
      c-sources:       src/Network/Mosquitto.c

i.e do not include c-sources for the newer c-inline and ghc-8.2+

@thomasjm
Copy link
Author

thomasjm commented Mar 2, 2018

I'm using lts-10.0, and have not specified any c-sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants