Skip to content

Conversation

angerman
Copy link

No description provided.

@angerman angerman changed the base branch from master to tmp/iog-dist-offset August 28, 2025 08:50
@angerman
Copy link
Author

This should now be up to date with the wip/multi-target-support branch. Squashed down a little.

Stable Haskell Team added 3 commits August 28, 2025 20:19
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.
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 completes the multi-target support infrastructure with
comprehensive changes across the compiler, build system, and runtime
components. These changes enable GHC to efficiently target multiple
platforms including native, JavaScript, and cross-compilation scenarios.

Core Compiler Changes:
- GHC.Driver.DynFlags: Multi-target configuration support
- GHC.Driver.Session: Enhanced session management for targets
- GHC.Driver.Make: Updated build orchestration for stages
- GHC.Driver.Downsweep: Improved module dependency handling
- GHC.ByteCode.Asm: Cross-platform bytecode assembly
- GHC.Iface.Load: Added Hooks parameter for interface loading
- GHC.Unit.State: Multi-target package database handling

LLVM Integration:
- GHC.CmmToLlvm.*: Refactored LLVM backend configuration
- Removed Version/Bounds.hs.in template
- Dynamic LLVM version detection
- Improved LLVM toolchain integration

JavaScript Backend:
- GHC.Driver.Config.StgToJS: JavaScript code generation config
- Enhanced JavaScript runtime support
- Integration with multi-stage build system

Linker and Code Generation:
- GHC.Linker.Dynamic: Cross-platform dynamic linking
- GHC.Linker.Static: Static linking improvements
- GHC.Linker.ExtraObj: Object file handling
- GHC.Driver.CodeOutput: Multi-target code emission
- CodeGen.Platform.h: Platform-specific code generation

Build System:
- ghc-pkg: Added --target flag support
- deriveConstants: Cross-compilation aware
- genprimopcode: Target-specific primop generation
- Setup.hs files: Updated for new build infrastructure
- packages: Updated submodule references

Libraries:
- system-cxx-std-lib: New C++ standard library wrapper
- ghc-internal: Updated configuration
- ghc-boot: Build system adjustments
- ghc-prim: Cross-compilation support

Testing Infrastructure:
- Updated test driver for multi-target scenarios
- Fixed platform-specific tests
- Adjusted test expectations for new architecture
- Added T10279h.hs test helper

External Dependencies:
- Removed libffi-tarballs (using system packages)
- Updated Cabal submodule
- Updated hsc2hs for cross-compilation

Utilities:
- unlit: Cross-platform compatibility
- ghc-toolchain: Target detection improvements
- config.guess/config.sub: GNU config files for RTS
- Added .envrc for development environment
- Added configure script for build configuration

Contributors:
- Moritz Angermann: Multi-target architecture and cross-compilation
- Sylvain Henry: JavaScript backend integration
- Andrea Bedini: Build system improvements
- Julian Ospald: Testing infrastructure and utilities

This completes the foundational work for GHC's multi-target support,
enabling efficient compilation for diverse platforms while maintaining
backward compatibility and build reproducibility.
@angerman angerman force-pushed the wip/angerman/multi-target-aggregated branch from 13b69bc to 4223669 Compare August 28, 2025 11:23
@angerman
Copy link
Author

This is now part of #42

@angerman angerman closed this Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant