Skip to content

Conversation

@angerman
Copy link

@angerman angerman commented Dec 5, 2025

Summary

  • Remove the fragile HADRIAN_SETTINGS environment variable mechanism
  • Version and platform info is now generated directly by ./configure into template files

Changes

File Change
configure.ac Added platform detection (auto-detect from uname), added --with-target-arch, --with-target-os, --with-project-git-commit-id arguments
libraries/ghc-boot/GHC/Version.hs.in New - Template for version info
libraries/ghc-boot/GHC/Platform/Host.hs.in New - Template for platform types
Makefile Removed HADRIAN_SETTINGS definition and all usages, updated CONFIGURED_FILES list
libraries/ghc-boot/Setup.hs Simplified to just defaultMain (130 → 11 lines)
libraries/ghc-boot/ghc-boot.cabal.in Changed build-type: CustomSimple, removed custom-setup and autogen-modules

How It Works Now

  1. Configure auto-detects platform using uname -m and uname -s, with override options:

    ./configure --with-target-arch=x86_64 --with-target-os=linux
    
  2. Configure generates the modules directly from templates:

    • libraries/ghc-boot/GHC/Version.hs - version strings, git commit
    • libraries/ghc-boot/GHC/Platform/Host.hs - platform arch/OS types
  3. No more environment variable passing between Makefile and Cabal

Benefits

  • Simpler, more maintainable build system
  • Single source of truth (configure.ac) for version/platform info
  • Follows established pattern (like ghcversion.h.in)
  • Easier to understand and debug
  • Less fragile than environment variable mechanism

Test plan

  • Run ./configure and verify generated files have correct content
  • Build stage1: make CABAL=$PWD/_build/stage0/bin/cabal stage1
  • Verify _build/stage1/bin/ghc --version shows correct version

Version and platform info is now generated directly by ./configure into:
- libraries/ghc-boot/GHC/Version.hs (from Version.hs.in)
- libraries/ghc-boot/GHC/Platform/Host.hs (from Host.hs.in)

This eliminates the fragile HADRIAN_SETTINGS environment variable
mechanism that passed version/platform info from Makefile to cabal's
custom Setup.hs.

Changes:
- Add platform detection to configure.ac using uname with auto-detect
- Add --with-target-arch and --with-target-os configure arguments
- Add --with-project-git-commit-id configure argument (auto-detects)
- Create Version.hs.in and Host.hs.in templates
- Simplify Setup.hs to use defaultMain (no more custom hooks)
- Change ghc-boot.cabal.in build-type from Custom to Simple
- Remove autogen-modules from ghc-boot.cabal.in
- Remove all HADRIAN_SETTINGS references from Makefile
@angerman angerman changed the base branch from stable-ghc-9.14-rebased to stable-ghc-9.14 December 5, 2025 08:36
Copy link

@hsyl20 hsyl20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If top-level configure does the substitution, how does it work when we build a cross-compiler (i.e. stage1 is non-cross and stage2 is cross)? The specified target should only apply to the stage2 compiler (stage1 is always non-cross).

@angerman
Copy link
Author

angerman commented Dec 5, 2025

If top-level configure does the substitution, how does it work when we build a cross-compiler (i.e. stage1 is non-cross and stage2 is cross)? The specified target should only apply to the stage2 compiler (stage1 is always non-cross).

Yea, I think we need to get rid of the target logic outright. This was just a first stab at nuking the HADRIAN_SETTINGS, as they pollute the Makefile.

Ultimately stage1 is always a native and stage2 is always a multi-target compiler (native + cross) compiler. In that case a single "target" is really not that meaningful. I think the solution is to just kill the target conditionals in a second step. For now this is just trying to do the same, just without

define HADRIAN_SETTINGS
[ ("hostPlatformArch",    "$(TARGET_ARCH)") \
, ("hostPlatformOS",      "$(TARGET_OS)") \
, ("cProjectGitCommitId", "$(GIT_COMMIT_ID)") \
, ("cProjectVersion",     "9.14") \
, ("cProjectVersionInt",  "914") \
, ("cProjectPatchLevel",  "0") \
, ("cProjectPatchLevel1", "0") \
, ("cProjectPatchLevel2", "0") \
]
endef

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.

3 participants