Fix Windows builds after D1242

Authored by olsner on Nov 19 2015, 12:46 PM.



Only use the merge_sections.ld linker script if SplitSections is enabled.

I thought I had a way to make the linker script actually work on Windows
and produce object files instead of image files (by using the "INSERT AFTER"
linker script command to get the default script's output format setting),
but that fix caused ghci to crash with an illegal instruction on startup.

Gave up and made a simpler fix of just disabling this for normal builds,
as it's only really relevant with SplitSections enabled anyway.

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
olsner updated this revision to Diff 5221.Nov 19 2015, 12:46 PM
olsner retitled this revision from to Fix Windows builds after D1242.
olsner updated this object.
olsner edited the test plan for this revision. (Show Details)
olsner set the repository for this revision to rGHC Glasgow Haskell Compiler.
olsner updated the Trac tickets for this revision.
thomie accepted this revision.Nov 20 2015, 7:05 AM
thomie added a reviewer: thomie.

Please rebase, the patch doesn't apply to master currently. Otherwise looks good.

This revision is now accepted and ready to land.Nov 20 2015, 7:05 AM
austin accepted this revision.Nov 20 2015, 7:33 AM
austin edited edge metadata.


olsner updated this revision to Diff 5240.Nov 21 2015, 1:21 AM
olsner edited edge metadata.

Rebased on new master.
(I don't see any other changes to this file that could cause a conflict though. Might have been an issue with copy-pasting patches into the web interface or something, so this time I tried uploading a diff file instead of copy-paste.)

Phyx added a subscriber: Phyx.Nov 21 2015, 2:33 AM

Hmm with no change to the actual linker script, wouldn't this still go wrong when SplitSections is turned on? Or is SplitSections not supported on Windows?

Phyx updated this object.Nov 21 2015, 6:30 AM
Phyx edited edge metadata.
This revision was automatically updated to reflect the committed changes.
awson added a subscriber: awson.Dec 14 2015, 8:09 AM

The culprit is that -T replaces builtin script completely. When I merged i386pep.xr (this is a builtin for ld -r on windows, one can find it in /mingw64/x86_64-w64-mingw32/lib/ldscripts directory under msys2 distribution or by running ld -r --verbose) with merge_sections.ld (see here:

) all went OK, and now a COFF object file with merged sections is generated.

But as far as I can see released mingw-w64 binutils' ld still lacks --gc-sections support . OTOH, current master branch binutils has --gc-sections support for PE-COFF in. I'll try to check if all this works (if and when I have time).