But the problem is NOT with that import.  It's with the OPTIONS_GHC in GHC.Internal.Classes, which is not in the external-modules section.

I did as you suggested but I'm still getting the stuff below


Warning: Specifying an absolute path to the project file is deprecated. Use
--project-dir to set the project's directory.
Configuration is affected by cabal.project at
'/home/simonpj/code/HEAD-19/hadrian'.
Up to date
Warning: Specifying an absolute path to the project file is deprecated. Use
--project-dir to set the project's directory.
Configuration is affected by cabal.project at
'/home/simonpj/code/HEAD-19/hadrian'.
]0;Starting...(/home/simonpj/code/HEAD-19) | Copy file: utils/haddock/haddock-api/resources/html/Classic.theme/plus.gif => _build/stage1/lib/html/Classic.theme/plus.gif
| Run Ghc FindHsDependencies (Stage0 InTreeLibs): libraries/ghc-boot-th/GHC/Boot/TH/Lib.hs (and 14 more) => _build/stage0/libraries/ghc-boot-th-next/.dependencies.mk
/home/simonpj/code/HEAD-19/libraries/ghc-boot-th-next/../ghc-internal/src/GHC/Internal/Classes.hs:10:17: error: [GHC-04924]
    Unknown flag in  {-# OPTIONS_GHC #-} pragma: -fdefines-known-key-names
   |
10 | {-# OPTIONS_GHC -fdefines-known-key-names #-}
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^

]0;Finished in 2.54s(/home/simonpj/code/HEAD-19) Development.Shake.cmd, system command failed
Command line: /home/simonpj/.ghcup/bin/ghc -M -include-cpp-deps -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/inplace/package.conf.d' '-this-unit-id ghc-boot-th-next-9.15-inplace' '-this-package-name ghc-boot-th-next' '-package-id base-4.21.0.0-ae91' '-package-id ghc-prim-0.13.0-e168' '-package-id pretty-1.1.3.6-fe44' -i -i/home/simonpj/code/HEAD-19/_build/stage0/libraries/ghc-boot-th-next/build -i/home/simonpj/code/HEAD-19/_build/stage0/libraries/ghc-boot-th-next/build/autogen -i/home/simonpj/code/HEAD-19/libraries/ghc-boot-th-next/../ghc-boot-th -i/home/simonpj/code/HEAD-19/libraries/ghc-boot-th-next/../ghc-internal/src -I_build/stage0/libraries/ghc-boot-th-next/build -I/home/simonpj/.ghcup/ghc/9.12.2/lib/ghc-9.12.2/lib/x86_64-linux-ghc-9.12.2-a828/ghc-internal-9.1202.0-1465/include -I/home/simonpj/.ghcup/ghc/9.12.2/lib/ghc-9.12.2/lib/x86_64-linux-ghc-9.12.2-a828/ghc-bignum-1.3-6db4/include -I/home/simonpj/.ghcup/ghc/9.12.2/lib/ghc-9.12.2/lib/x86_64-linux-ghc-9.12.2-a828/rts-1.0.2/include -optP-include -optP_build/stage0/libraries/ghc-boot-th-next/build/autogen/cabal_macros.h -optP-DBOOTSTRAP_TH -outputdir _build/stage0/libraries/ghc-boot-th-next/build -fdiagnostics-color=always -XHaskell2010 -XNoImplicitPrelude -optc-Wno-error=inline -include-pkg-deps -dep-makefile _build/stage0/libraries/ghc-boot-th-next/.dependencies.mk -dep-suffix '' -fno-warn-deprecated-flags -O +RTS -O64M -RTS @/tmp/extra-file-89749345684126-2082901-0
Exit code: 1
Stderr:
/home/simonpj/code/HEAD-19/libraries/ghc-boot-th-next/../ghc-internal/src/GHC/Internal/Classes.hs:10:17: error: [GHC-04924]
    Unknown flag in  {-# OPTIONS_GHC #-} pragma: -fdefines-known-key-names
   |
10 | {-# OPTIONS_GHC -fdefines-known-key-names #-}
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^

On Wed, 25 Mar 2026 at 13:17, Teo Camarasu <teofilcamarasu@gmail.com> wrote:
But what business does the bootstrap compiler have with compiling GHC.Internal.Classes? 

Aha! I see the issue.

If you look here: https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/ghc-boot-th/ghc-boot-th.cabal.in#L55
    if flag(bootstrap)
        cpp-options: -DBOOTSTRAP_TH
        build-depends:
            ghc-prim
        hs-source-dirs: @SourceRoot@ ../ghc-internal/src
        exposed-modules:
            GHC.Boot.TH.Lib
            GHC.Boot.TH.Syntax
            GHC.Boot.TH.Monad
        other-modules:
            GHC.Internal.TH.Lib
            GHC.Internal.TH.Syntax
            GHC.Internal.TH.Monad
            GHC.Internal.ForeignSrcLang
            GHC.Internal.LanguageExtensions
            GHC.Internal.Lexeme
You can see the modules that we vendor from `ghc-internal`  under `other-modules.

One of those is `GHC.Internal.ForeignSrcLang` and in your PR you add:
```
import GHC.Internal.Classes( (==) ) -- For known-key names
```
This needs to go inside the `else` branch of the `ifdef BOOTSTRAP_TH` pragma.

I think if you do the same thing for any `ghc-internal` imports in the other modules mentioned above then you should be fine.

I really should add a note explaining this BOOTSTRAP_TH business, especially because it is quite hacky(!).
Note [Bootstrapping Template Haskell] does a good job of explaining the design decisions we made to get here, but we need another note to explain this CPP soup.

Cheers,
Teo