Add linker pool allocator for aarch64 under qemu (cf GHC #24432)#2493
Merged
hamishmack merged 20 commits intomasterfrom Apr 27, 2026
Merged
Add linker pool allocator for aarch64 under qemu (cf GHC #24432)#2493hamishmack merged 20 commits intomasterfrom
hamishmack merged 20 commits intomasterfrom
Conversation
When running the GHC RTS linker under qemu user-mode emulation, mmap hint addresses are ignored, causing allocations to scatter across the address space. This leads to ADR_GOT_PAGE relocation overflow (±4GB range exceeded) on aarch64. This patch pre-allocates a single contiguous 512MB RWX pool and sub-allocates from it for all linker needs: sections, GOT, BSS, and COMMON symbols. The pool is split into RW (growing down) and RX (growing up) halves, guaranteeing all allocations stay close. Also fixes GOT slot allocation for STB_LOCAL symbols (e.g. approx_tab in Android NDK's libm.a) which have GOT-relative relocations but were not assigned GOT slots. Applied to GHC 9.6.7, 9.8.3+, 9.10.2+ (versions that already use m32 for regular sections but missed BSS, COMMON, and GOT). Enables android and aarch64-cross TH tests (annotations, js-template-haskell, th-dlls) that were previously disabled due to iserv hanging under qemu.
Update nixpkgs-unstable and nixpkgs-2511 pins and fix the resulting evaluation warnings for deprecated package names. Uses backwards-compatible fallback patterns so older nixpkgs still works: - Replace xorg.* references with (pkgs.newName or pkgs.xorg.oldName) - Add xorgCompat set in pkgconf-nixpkgs-map.nix to map deprecated xorg attribute names to their new top-level equivalents - Update renamed packages (enchant2, unixODBC, goocanvas, etc.) using a prefer helper that selects the new name when available
GHC 9.6.x and 9.8.x utils/hp2ps/Utilities.c uses K&R-style extern declarations for malloc/realloc without including <stdlib.h>. GCC 15 treats these as zero-argument functions, causing build failure.
nixpkgs 26.05 removed 'pie' from the hardening system entirely -- PIE is now enabled by default in compilers. Any mention of 'pie' in either hardeningEnable or hardeningDisable triggers a deprecation warning: "The 'pie' hardening flag has been removed in favor of enabling PIE by default in compilers and should no longer be used." This causes ~68 warnings per evaluation for projects with musl cross-compilation, which is every haskell.nix project using crossPlatforms with musl64 or aarch64-multiplatform-musl. Remove the two places where 'pie' was added to hardeningDisable: - builder/comp-builder.nix: every Haskell component on musl - compiler/ghc/default.nix: GHC itself on musl targets
Only disable pie for musl when the toolchain still has it as a default hardening flag (nixpkgs <= 25.05). On newer nixpkgs where pie was removed from the hardening system, skip it to avoid the deprecation warning.
Wine 11.0 renamed DOS_PATHNAME_TYPE to RTL_PATH_TYPE and changed the enum values (DEVICE_PATH -> RtlPathTypeLocalDevice). Add a new patch variant for wine >= 11.0 that uses the new API names.
The 'static' parameter was removed from zlib in nixpkgs-unstable. Setting 'shared = false' is sufficient to get a static-only build and works across all nixpkgs versions.
Emscripten 4.0+ moved emnm from share/emscripten/emnm to share/emscripten/tools/emnm.py. Use builtins.pathExists to select the correct path for backwards compatibility.
- libffi, gmp: disable doCheck when cross-compiling since test binaries can't execute on the build host - ncurses: disable broken symlink check when cross-compiling to avoid case-sensitive symlink target mismatch
Hadrian builds terminfo unconditionally for stage0, passing the same --with-curses-libraries to both stage0 (host compiler) and stage1 (target compiler). Before GHC 9.15 (which has MR 13932), this cannot work when the host and target have different ncurses (e.g. glibc vs musl), because the host compiler can't link against target static libs. Matching nixpkgs common-hadrian.nix: - Disable enableTerminfo when platform configs differ (cross builds) for GHC < 9.15 - Gate --with-curses-libraries on enableTerminfo so it's not passed in cross builds (avoiding the stage0 ABI mismatch) - Keep ncurses in libDeps unconditionally (not gated on enableTerminfo) since hadrian builds terminfo for stage0 regardless, and depsTargetTarget needs target ncurses for stage1
The K&R-style extern void* malloc() in utils/hp2ps/Utilities.c is present in all GHC versions from 8.10.7 through 9.12.3. It was fixed with a proper prototype in 9.10.2 and fully fixed with #include <stdlib.h> in 9.10.3 and 9.12.4+.
Wine 11.0 removed the wine64 binary, unifying it into wine. Use wine64Packages.minimal (for 64-bit support) and lib.getExe to pick the correct binary name via meta.mainProgram. Also patch wine64Packages.minimal with the same fixes as winePackages.minimal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running the GHC RTS linker under qemu user-mode emulation, mmap hint addresses are ignored, causing allocations to scatter across the address space. This leads to ADR_GOT_PAGE relocation overflow (±4GB range exceeded) on aarch64.
This patch pre-allocates a single contiguous 512MB RWX pool and sub-allocates from it for all linker needs: sections, GOT, BSS, and COMMON symbols. The pool is split into RW (growing down) and RX (growing up) halves, guaranteeing all allocations stay close.
Also fixes GOT slot allocation for STB_LOCAL symbols (e.g. approx_tab in Android NDK's libm.a) which have GOT-relative relocations but were not assigned GOT slots.
Applied to GHC 9.6.7, 9.8.3+, 9.10.2+ (versions that already use m32 for regular sections but missed BSS, COMMON, and GOT).
Enables android and aarch64-cross TH tests (annotations, js-template-haskell, th-dlls) that were previously disabled due to iserv hanging under qemu.