Opened 3 years ago

Last modified 9 months ago

#12913 new task

Port SplitSections to Windows

Reported by: olsner Owned by:
Priority: normal Milestone: 8.10.1
Component: Compiler (Linking) Version: 8.0.1
Keywords: Cc: Phyx-, awson
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #8405 #13939 Differential Rev(s): Phab:D3382 Phab:D3383 Phab:D3523
Wiki Page:

Description

Seems we never made bug for this (that I can find) so the windows-related issues and discussion ended up in #11445. Let's move over here instead.

Attachments (2)

latest.patch (3.8 KB) - added by awson 3 years ago.
lscripts.tar.gz (2.8 KB) - added by awson 3 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 Changed 3 years ago by awson

Blocking: 11445 removed

comment:2 Changed 3 years ago by Phyx-

@Awson.

I have -Wa,-mbig-objs setup in every call, and I'm using binutils 2.28 which should have your patched included and I'm using a linker script to merge the sections back together. But I'm still getting an invalid exec format error from Windows when I try to run the exe.

My assumption is that -gc-sections is removing a section it shouldn't be. Before I dive too much into this, did I miss a step? Since you seem to have a working version.

Changed 3 years ago by awson

Attachment: latest.patch added

comment:3 Changed 3 years ago by awson

  1. Binutils 2.28 includes only non-essential part of my patch, the part that is important wasn't put there, so you need the whole patch;
  2. Recent GHC string literals handling changes had required yet another tweak to binutils which I didn't bother to publish because of apparent lack of interest.

Nonetheless, I attach the patch which, I believe, should do the thing for you. It is made against the current HEAD, but I think it works against 2.28 too.

Changed 3 years ago by awson

Attachment: lscripts.tar.gz added

comment:4 Changed 3 years ago by awson

Ah, and if you want already processed linker scripts here they are.

comment:5 Changed 3 years ago by Phyx-

Thanks! I thought based on the timing that 2.28 contained them :) thought they were checked in, but probably after the branch?

ABout the string literals I assume you mean string merging? GHC now generates a lot more string literals that are identical and should be merged.

comment:6 Changed 3 years ago by awson

Nope, they were only partially checked in. If you follow the commit link in the last post of the discussion you will understand that only 32-bit bugfix (no new features at all) was landed. The essential part was abandoned because of Simon Brenner's idea that we should fix things on the GHC side making section name generation scheme more "windowsish" which binutils already has support for.

And yes, I meant string merging when writing about string literals handling. At least my patch solves sections merging problem here. To make proper string merging we should, I believe, go entirely different way. AFAIR Walter Bright had met exactly the same problem when developing his D compiler and he used COMDAT to solve it. He blogged about this a couple of months ago.

comment:7 Changed 3 years ago by Phyx-

Ah, great thanks for the info, this saves me a lot of time! Yes I see now what you mean. I can certainly change GHC to output the right section names, that at least lessens the maintenance burden a bit.

both it and string merging are on my list for 8.4 (along with dynamic linking). I'll take a look at his blog post and see!

comment:8 Changed 2 years ago by Phyx-

Differential Rev(s): Phab:D3382 Phab:D3383
Status: newpatch

comment:9 Changed 2 years ago by Tamar Christina <tamar@…>

In f446f6a/ghc:

First update mingw-w64 packages for 8.4

Summary: Updating to get latest binutils etc.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, snowleopard

GHC Trac Issues: #12913

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

comment:10 Changed 2 years ago by Phyx-

Differential Rev(s): Phab:D3382 Phab:D3383Phab:D3382 Phab:D3383 Phab:D3523
Owner: set to Phyx-

comment:11 Changed 2 years ago by Phyx-

Owner: Phyx- deleted

comment:12 Changed 2 years ago by Tamar Christina <tamar@…>

In bd4fdc6/ghc:

Implement split-sections support for windows.

Summary:
Initial implementation of split-section on Windows.

This also corrects section namings and uses the platform
convention of `$` instead of `.` to separate sections.

Implementation is based on @awson's patches to binutils.

Binutils requires some extra help when compiling the libraries
for GHCi usage. We drop the `-T` and use implicit scripts to amend
the linker scripts instead of replacing it.

Because of these very large GHCi object files, we need big-obj support,
which will be added by another patch.

Test Plan: ./validate

Reviewers: awson, austin, bgamari

Subscribers: dfeuer, rwbarton, thomie, snowleopard, #ghc_windows_task_force

GHC Trac Issues: #12913

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

comment:13 Changed 2 years ago by bgamari

Milestone: 8.4.1
Resolution: fixed
Status: patchclosed

comment:14 Changed 2 years ago by Phyx-

Created a separate issue for the 32bit binutils problems #13939

comment:15 Changed 2 years ago by Tamar Christina <tamar@…>

In f656fba1/ghc:

[skip ci] Temporarily disable split-sections on Windows.

Summary:
This temporarily disabled split-sections again on Windows because
of the overhead in linking it introduces. Unfortunately because BFD
is so slow a testsuite run gets almost 2x slower. Simply linking
Hello World takes an unacceptable long time.

So for now, it'll be disabled as we look into different linkers such
as LLD.

Test Plan: ./validate

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12913

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

comment:16 Changed 2 years ago by Phyx-

Resolution: fixed
Status: closednew

Need to investigate using lld instead.

comment:17 Changed 20 months ago by bgamari

Milestone: 8.4.18.6.1

This ticket won't be resolved in 8.4; remilestoning for 8.6. Do holler if you are affected by this or would otherwise like to work on it.

comment:18 Changed 15 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be fixed for 8.6, bumping to 8.8.

comment:19 Changed 9 months ago by bgamari

I have opened #16084 to track the issue of link speed on Windows.

comment:20 Changed 9 months ago by osa1

Milestone: 8.8.18.10.1

Bumping milestones of low-priority tickets.

Note: See TracTickets for help on using tickets.