Skip to content

Commit

Permalink
Generate DerivedConstants.h with a hack
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyl20 committed Dec 10, 2024
1 parent 2ddd93a commit 0d60b8a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
35 changes: 32 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,44 @@ _build/stage1/bin/ghc: _build/stage0/bin/ghc

# Generating headers
# FIXME: deriveConstants requires ghcautoconf.h and ghcplatform.h
# Let's run cabal until it fails so that these files are generated...
HADRIAN_SETTINGS='$(HADRIAN_SETTINGS_STAGE1)' \
$(CABAL) build --project-file=cabal.project-stage1 \
rts \
--with-compiler=`pwd`/_build/stage0/bin/ghc \
--with-hc-pkg=`pwd`/_build/stage0/bin/ghc-pkg \
--ghc-options="-ghcversion-file=`pwd`/_build/stage1/src/libraries/rts/include/ghcversion.h" \
--ghc-options="-I`pwd`/_build/stage1/src/libraries/rts/include/" \
--ghc-options="-I`pwd`/_build/stage1/src/libraries/rts/" \
--ghc-options='"-optc=-DProjectVersion=\"913\""' \
--ghc-options='"-optc=-DRtsWay=\"FIXME\""' \
--ghc-options='"-optc=-DHostPlatform=\"FIXME\""' \
--ghc-options='"-optc=-DHostArch=\"FIXME\""' \
--ghc-options='"-optc=-DHostOS=\"FIXME\""' \
--ghc-options='"-optc=-DHostVendor=\"FIXME\""' \
--ghc-options='"-optc=-DBuildPlatform=\"FIXME\""' \
--ghc-options='"-optc=-DBuildArch=\"FIXME\""' \
--ghc-options='"-optc=-DBuildOS=\"FIXME\""' \
--ghc-options='"-optc=-DBuildVendor=\"FIXME\""' \
--ghc-options='"-optc=-DTargetPlatform=\"FIXME\""' \
--ghc-options='"-optc=-DTargetArch=\"FIXME\""' \
--ghc-options='"-optc=-DTargetOS=\"FIXME\""' \
--ghc-options='"-optc=-DTargetVendor=\"FIXME\""' \
--ghc-options='"-optc=-DGhcUnregisterised=\"FIXME\""' \
--ghc-options='"-optc=-DTablesNextToCode=\"FIXME\""' \
--builddir=_build/stage1/cabal/ >/dev/null 2>&1 || true

# Deriving constants
mkdir -p _build/stage1/temp/derive_constants
_build/stage0/bin/deriveConstants --gen-header -o _build/stage1/src/libraries/rts/include/DerivedConstants.h \
--target-os linux \
--tmpdir _build/stage1/temp/derive_constants \
--gcc-program gcc \
--nm-program nm \
--objdump-program objdump \
--gcc-flag "-I_build/stage1/src/libraries/rts/include"
--gcc-flag "-I_build/stage1/src/libraries/rts/include" \
--gcc-flag "-I_build/stage1/src/libraries/rts" \
--gcc-flag "-I_build/stage1/cabal/build/x86_64-linux/ghc-9.13/rts-1.0.2/build/include"

# Building boot libraries
mkdir -p _build/stage1/cabal/
Expand Down Expand Up @@ -164,8 +194,7 @@ _build/stage1/bin/ghc: _build/stage0/bin/ghc
--ghc-options='"-optc=-DTargetVendor=\"FIXME\""' \
--ghc-options='"-optc=-DGhcUnregisterised=\"FIXME\""' \
--ghc-options='"-optc=-DTablesNextToCode=\"FIXME\""' \
--ghc-options='-v3' \
--builddir=_build/stage1/cabal/ -v3
--builddir=_build/stage1/cabal/

clean:
rm -rf _build
Expand Down
1 change: 1 addition & 0 deletions utils/deriveConstants/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
= case words line of
('_' : n) : "C" : s : _ -> mkP n s
n : "C" : s : _ -> mkP n s
n : "B" : _ : s : _ -> mkP n s
[n, "D", _, s] -> mkP n s
[s, "O", "*COM*", _, n] -> mkP n s
_ -> Nothing
Expand Down

0 comments on commit 0d60b8a

Please sign in to comment.