forked from ghc/ghc
-
Notifications
You must be signed in to change notification settings - Fork 1
PHONY: stable-ghc-9.14 additions #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
angerman
wants to merge
84
commits into
ghc-9.14
Choose a base branch
from
stable-ghc-9.14
base: ghc-9.14
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
This change reverts part of !14544, which forces the bootstrap compiler to have ghc-internal. As such it breaks booting with ghc 9.8.4. A better solution would be to make this conditional on the ghc version in the cabal file!
…ernal If the boot compiler doesn't have ghc-internal use "<unavailble>" as the `cGhcInternalUnitId`. This allows booting with older compilers. The subsequent stage2 compilers will have the proper ghc-internal id from their stage1 compiler, that boots them.
mermaid is a common diagram format that can be inlined in markdown files, and e.g. github will even render it. This change adds support for mermaid diagram output to ghc-pkg.
This adds support to ghc-pkg to infer a package-db from a target name.
Make the first simple optimization pass after desugaring a real CoreToDo pass. This allows CorePlugins to decide whether they want to be executed before or after this pass.
It's more user-friendly to directly print the right thing instead of requiring the user to retry with the additional `-dppr-debug` flag.
…roken on darwin/non-dynamic.
The referenced issue 20706 also doesn't list T13786 as a broken test.
By mistake we tried to use deriveConstant without passing `--gcc-flag -fcommon` (which Hadrian does) and it failed. This patch adds deriveConstant support for constants stored in the .bss section so that deriveConstant works without passing `-fcommon` to the C compiler.
This commit restructures the Runtime System (RTS) components for better modularity and reusability across different build configurations. The changes enable cleaner separation of concerns and improved support for cross-compilation scenarios. Key changes: - Extract RTS headers into standalone rts-headers package * Moved include/rts/Bytecodes.h to rts-headers * Moved include/rts/storage/ClosureTypes.h to rts-headers * Moved include/rts/storage/FunTypes.h to rts-headers * Moved include/stg/MachRegs/* to rts-headers - Create rts-fs package for filesystem utilities * Extracted filesystem code from utils/fs * Provides reusable filesystem operations for RTS - Rename utils/iserv to utils/ghc-iserv for consistency * Better naming alignment with other GHC utilities * Updated all references throughout the codebase - Update RTS configuration and build files * Modified rts/configure.ac for new structure * Updated rts.cabal with new dependencies * Adjusted .gitignore for new artifacts Rationale: The modularization allows different stages of the compiler build to share common RTS components without circular dependencies. This is particularly important for: - Cross-compilation where host and target RTS differ - JavaScript backend which needs selective RTS components - Stage1/Stage2 builds that require different RTS configurations Contributors: - Moritz Angermann: RTS modularization architecture and implementation - Sylvain Henry: JavaScript backend RTS adjustments - Andrea Bedini: Build system integration This refactoring maintains full backward compatibility while providing a cleaner foundation for multi-target support.
This commit introduces a comprehensive cabal-based build infrastructure to support multi-target and cross-compilation scenarios for GHC. The new build system provides a clean separation between different build stages and better modularity for toolchain components. Key changes: - Add Makefile with stage1, stage2, and stage3 build targets - Create separate cabal.project files for each build stage - Update configure.ac for new build system requirements - Adapt hie.yaml to support cabal-based builds - Update GitHub CI workflow for new build process Build stages explained: - Stage 1: Bootstrap compiler built with system GHC - Stage 2: Intermediate compiler built with Stage 1 - Stage 3: Final compiler built with Stage 2 (for validation) This modular approach enables: - Clean cross-compilation support - Better dependency management - Simplified build process for different targets - Improved build reproducibility Contributors: - Andrea Bedini: Build system design and Makefile implementation - Moritz Angermann: Cross-compilation infrastructure The new build system maintains compatibility with existing workflows while providing a more maintainable foundation for future enhancements.
While we do want to drop this, for now, to keep the diff to upstream small, we will just disable it with [10,100] range, which should include all relevent LLVM versions in the foresable future.
Replace legacy __sync_fetch_and_* builtins with their modern __atomic_fetch_*
equivalents. This simplifies the code significantly, particularly for the nand
operation which previously required extensive workarounds for compiler
compatibility issues.
Changes:
- Replace __sync_fetch_and_{add,sub,and,or,xor} with __atomic_fetch_*
- Replace __sync_fetch_and_nand with __atomic_fetch_nand
- Remove CAS-based fallback for nand operations
- Remove compiler-specific warning suppressions for -Wsync-nand
- Remove volatile qualifiers (not needed with __atomic builtins)
- Update comments to reflect modern atomics usage
All operations maintain __ATOMIC_SEQ_CST memory ordering for sequential
consistency, matching the original behavior.
Co-authored-by: Andrea Bedini <andrea@andreabedini.com>
#107) * docs(readme): consolidate building and contributing guides into README - Delete separate HACKING.md and INSTALL.md files, consolidating their content into README.md for a unified reference - Update README to reflect Stable Haskell Edition fork with GitHub issue tracker at stable-haskell/ghc - Revise clone instructions to point to GitHub stable-haskell/ghc repository instead of GitLab - Simplify build instructions to use make-based build system with clearer GHCup setup steps - Integrate developer contribution guidelines and communication channels directly into README - Update dependency references and remove outdated tool links (Happy, Alex) - Add test suite running instructions to building section - Reorganize content with clearer section headers for Getting Started, Useful Resources, and communication channels
capture dependencies of configure scripts and generared files improve cleaning
- Improve the consistency across the stage cabal.project files by using the same ordering and delimiter comments - "package-dbs: clear, global" is the default so it's removed
The refactoring in 'reorganize cabal.project files' accidentally removed libraries/ghc-platform from cabal.project.stage1. This package is required because ghc-boot depends on ghc-platform >= 0.1. Without this fix, all CI builds fail with: Error: [Cabal-7107] Could not resolve dependencies: unknown package: host:ghc-platform (dependency of host:ghc-boot)
Add entries to prevent AI agent config files from being accidentally committed. These files contain project-specific instructions for various AI coding assistants and should remain local. Covers: Claude Code, GitHub Copilot, Cursor, Gemini CLI/Jules, OpenAI Codex, and JetBrains Junie. See: https://agents.md/ for the AGENTS.md standard
This patch teaches GHC how to build the external interpreter program when it is missing. As long as we have the `ghci` library, doing this is trivial so most of this patch is refactoring for doing it sanely. (cherry picked from commit 55eab80)
Avoid overflows in jump tables by using a base label closer to the jump targets. See added Note [Jump tables]
Commit 76d1041 seems to have introduced this bug, ultimately leading to failure of test T11788. I can only theorize that this test isn't run in upstream's CI, because they don't build a static GHC. The culprit is that we go through the thin archive, trying to follow the members on the filesystem, but don't re-identify the new object format of the member. This pins `object_fmt` to `NotObject` from the thin archive. Thanks to @angerman for spotting this.
The gc_thread timing fields (gc_start_cpu, gc_end_cpu, gc_start_elapsed, gc_end_elapsed, gc_sync_start_elapsed) were not being initialized when gc_threads were allocated. Since gc_threads are allocated with stgMallocAlignedBytes (which doesn't zero memory), these fields contained garbage values. The initialization must be in new_gc_thread(), not init_gc_thread(), because: 1. new_gc_thread() is called once when a gc_thread is first allocated 2. init_gc_thread() is called at the START of each GC cycle 3. stat_startGC() sets the timing fields BEFORE init_gc_thread() is called 4. If we initialize in init_gc_thread(), we would reset the values that stat_startGC() just set, breaking the timing calculations The garbage values caused wild statistics like: gc_elapsed_ns=50426020081527 (14 hours of supposed GC time!) exit_elapsed_ns=18446741672370457118 (~= -1.3 billion as unsigned) These were being accumulated into stats and causing all productivity calculations to fail with massively negative values.
Introduce stgCallocAlignedBytes as a zeroing aligned allocator, replacing stgMallocAlignedBytes. This allows removing ~40 lines of redundant zero/NULL initializations in new_gc_thread() and initCapability(). Changes: - Rename stgMallocAlignedBytes to stgCallocAlignedBytes and add memset(0) - Add deprecated stgMallocAlignedBytes wrapper for backwards compatibility - Update call sites in GC.c and Capability.c to use stgCallocAlignedBytes - Remove redundant zero/NULL/false initializations from: - new_gc_thread(): timing fields, free_blocks, gc_count, workspace fields - initCapability(): most boolean/numeric/pointer fields The zeroing overhead is negligible (startup-time allocation, ~500-1000 bytes) while the benefits include: - Cleaner code with only non-zero initializations remaining - Safer: new struct fields automatically start at zero - Catches uninitialized memory bugs (was causing garbage timing values)
When a GC cycle straddles the exit boundary (starts before stat_startExit() but finishes during the exit phase), the calculated exit_gc_elapsed can exceed the actual exit duration, resulting in negative exit_elapsed_ns. This occurs because: 1. stat_startExit() captures start_exit_gc_elapsed = stats.gc_elapsed_ns (which doesn't include the in-progress GC) 2. When the straddling GC completes, its FULL duration is added to stats.gc_elapsed_ns 3. exit_gc_elapsed = stats.gc_elapsed_ns - start_exit_gc_elapsed now includes GC time from BEFORE exit started This was observed on Alpine Linux (musl libc) where different scheduler behavior or timing granularity makes the race condition more likely to manifest. Fix by clamping exit_cpu_ns and exit_elapsed_ns to zero when negative, matching the existing pattern for mutator_cpu_ns. These statistics are best-effort approximations, and this edge case is rare. Also remove WARNs that can fire erroneously in timing edge cases: - WARN(exit_gc_elapsed > 0) - fires if no GC during exit - WARN(stats.mutator_elapsed_ns >= 0) - same timing edge case - WARN(INIT + MUT + GC + EXIT == total) - violated by clamping See Note [Clamping exit_cpu_ns and exit_elapsed_ns] in rts/Stats.c.
Add "Stable Haskell Edition" branding to user-visible output while maintaining drop-in compatibility with upstream GHC: - ghc --version: Append "(Stable Haskell Edition)" suffix - ghc -v2 banner: Add edition to verbose compiler banner - GHCi welcome: Add edition and update URL to GitHub repo - ghc --info: Add new "Edition" field (keeps "Project name" unchanged) - Bug reports: Redirect all URLs to github.com/stable-haskell/ghc/issues All internal identifiers (cProjectVersion, unit IDs, etc.) remain unchanged to preserve ABI and tool compatibility.
The branding commit changed the bug report URL from haskell.org/ghc/reportabug to github.com/stable-haskell/ghc/issues. Update test expectation files to match the new URL output. Fixes CI failures in T11223_link_order_a_b_2_fail and T11223_simple_duplicate_lib tests across all platforms.
6952554 to
9cbe6d3
Compare
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.
Summary
This PR tracks all additions in
stable-ghc-9.14relative to upstreamghc-9.14.Cabal-based Multi-Stage Build System
rts-headers) and filesystem utilities (rts-fs) into separate packages-no-rtscompiler flag for bootstrap buildsStatic Linking Improvements
-fully-staticand-exclude-static-externalflagsextra-libraries-staticis consistently definedBundled libffi
libffi-clibas bundled library (replaces system libffi dependency)Build System & Tooling
ghc-toolchain --output-settingssupportgenprimopcode --wrappers/--prim-moduleoptionsghc-configadditional fieldsghc-pkg --targetsupport and mermaid diagram generationCI & Testing
Fixes
-dynamicis mixed with-staticlib