rts/Printer.c: always define the findPtr symbol
Concern Raised900c47f88784

Authored by alpmestan on Sep 12 2018, 5:06 PM.


rts/Printer.c: always define the findPtr symbol

It was previously only defined (and therefore shipped) when DEBUG is
defined. This patch defines it regardless of DEBUG. This will help fix
hadrian on OS X [1].

[1]: https://github.com/snowleopard/hadrian/issues/614

Test Plan: The error from hadrian#614 is gone

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5138

Phyx raised a concern with this commit.Sep 23 2018, 10:05 AM
Phyx added a subscriber: Phyx.

This change doesn't play well with our habit of exporting all symbols into shared libraries. --export-all-symbols combined with the -Wl,-u will end up making the linker a) always export the symbol and always pull it in.
This means compiling a library with -shared on Windows will result in a library that can't be used to link against others.

Harbormaster did show the breakage https://phabricator.haskell.org/harbormaster/build/52925/1/?l=0

Stderr ( T10955dyn ):

C:\msys64\var\drydock\workingcopy-121280\repo\glasgow-haskell-compiler\bindisttest\install   dir\lib/rts/libHSrts_thr.a(Printer.thr_o): In function `findPtr':

C:\msys64\var\drydock\workingcopy-121280\repo\glasgow-haskell-compiler/rts/Printer.c:880: multiple definition of `findPtr'

./bin_dyn/libA.dll.a(d020781.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

This wouldn't have been a problem before as your library wouldn't have been compiled with -debug usually.

I'm missing something here, why couldn't we have fixed the Mac OSX with a cabal flag? This looks to me like it has the same semantics as leading-underscore. The build system can just pass along the cabal flag depending on which flavor it's building.

This commit now has outstanding concerns.Sep 23 2018, 10:05 AM

Hmm, this solution does seem inferior to the one you suggest, I was not aware of:

This means compiling a library with -shared on Windows will result in a library that can't be used to link against others.

I can give a shot at implementing your suggestion soon (quite likely next week) if that's not taken care of by then.

Phyx added a comment.Sep 28 2018, 1:18 PM

Thanks @alpmestan that's fine. I made a ticket for it on trac in the mean