llvm / llvm/llvm-project

[clang][lld] Increase the default segment alignment from 4k to 64k for windows 64bit binaries (at least for -gnu targets first)?

Open
#215,214 4 comments 0 reactions 0 assignees View on GitHub
lld:COFF platform:windows
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I’m working on porting Wine to support running Windows‑on‑ARM binaries on Apple Silicon Macs. One major obstacle is that Apple uses a 16 KB page size, and Android appears to be moving in the same direction. In my experiments, I was able to get binaries running correctly by increasing Clang’s segment alignment from 4 KB to 64 KB. I’ve also successfully ported GCC for Windows‑on‑ARM, though that work hasn’t been merged yet.

Given these trends, it may be time to consider raising the default segment alignment from 4 KB to 64 KB for 64‑bit Windows targets—at least for x86_64‑windows‑gnu and aarch64‑windows‑gnu initially. This would improve forward compatibility for Wine and other environments that may need to support larger page sizes. It would also give Windows itself the flexibility to adopt 16 KB or even 64 KB pages in the future, potentially as a configurable system option.

For MSVC targets, I’ve asked Microsoft developers whether they plan to make a similar change in future versions of the Visual C++ toolchain:
https://developercommunity.visualstudio.com/t/Visual-C-compilers-should-default-segm/11133260

Contributor guide

Open the contributing guide

Research direction

Start by reviewing how Clang and lld currently select segment alignment for x86_64-windows-gnu and aarch64-windows-gnu targets. Determine where the 4 KB default is defined and how existing Windows 64-bit binary tests verify it; done means an agreed implementation and passing coverage for the proposed 64 KB default.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.