Build fails because of “multiple definition” linker errors in native dependencies

試著忘記壹切 提交于 2019-12-05 00:09:12
Yuras

It seems to be an issue with gcc-4.9.2. I forked your project, started a build with high verbosity level, connected to the circleci container and run the exact linking command. It fails the same way:

ubuntu@box1305:~$ /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as-needed -nostdlib -Wl,-r -nodefaultlibs '-Wl,--build-id=none' -o Types.o /tmp/ghc17998_0/ghc_15.ldscript
/tmp/ghc17998_0/ghc_14.o: In function `r2vy_closure':
(.data+0x0): multiple definition of `__stginit_OpenGzu8rT20eO9AxEKIONeYf57cS_GraphicsziRenderingziOpenGLziRawziTypes'
/tmp/ghc17998_0/ghc_14.o:(.data+0x0): first defined here
/tmp/ghc17998_0/ghc_14.o: In function `r2vy_closure':
(.data+0x8): multiple definition of `OpenGzu8rT20eO9AxEKIONeYf57cS_GraphicsziRenderingziOpenGLziRawziTypes_makeGLDEBUGPROC_closure'
/tmp/ghc17998_0/ghc_14.o:(.data+0x8): first defined here
/tmp/ghc17998_0/ghc_14.o: In function `c2y7_info':
(.text+0xc0): multiple definition of `OpenGzu8rT20eO9AxEKIONeYf57cS_GraphicsziRenderingziOpenGLziRawziTypes_makeGLDEBUGPROC_info'
/tmp/ghc17998_0/ghc_14.o:(.text+0xc0): first defined here

But with gcc-4.8 it works:

ubuntu@box1305:~$ /usr/bin/gcc-4.8 -fno-stack-protector -DTABLES_NEXT_TO_CODE '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as-needed -nostdlib -Wl,-r -nodefaultlibs '-Wl,--build-id=none' -o Types.o /tmp/ghc17998_0/ghc_15.ldscript
ubuntu@box1305:~$ 

So you should switch to older gcc and probably report a bug to gcc devs.

ADDED: Here is an example how to switch gcc version. And here is a successful build.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!