diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-10-22 00:05:54 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-01 12:48:47 -0500 |
commit | d0a146a5914f62414b1b09d88741bf0da7f277d9 (patch) | |
tree | a7d7aade3c7aae97233b8386672d628b2db74b03 | |
parent | a5bd0eb8dd1d03c54e1b0b476ebbc4cc886d6f19 (diff) | |
download | haskell-d0a146a5914f62414b1b09d88741bf0da7f277d9.tar.gz |
Give the RTS it's own configure script
Currently it doesn't do much anything, we are just trying to introduce
it without breaking the build. Later, we will move functionality from
the top-level configure script over to it.
We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to
facilitate and existing hack of skipping some configure checks for the
RTS we now need to skip just *part* not *all* of the "post configure"
hook, as running the configure script (which we definitely want to do)
is also implemented as part of the "post configure" hook. But doing this
requires exposing functionality that wasn't exposed before.
-rwxr-xr-x | boot | 2 | ||||
-rw-r--r-- | hadrian/cabal.project | 2 | ||||
-rw-r--r-- | hadrian/hadrian.cabal | 2 | ||||
-rw-r--r-- | hadrian/src/Base.hs | 8 | ||||
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 31 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 23 | ||||
-rw-r--r-- | hadrian/src/Rules/Lint.hs | 8 | ||||
-rw-r--r-- | hadrian/src/Rules/Register.hs | 6 | ||||
m--------- | libraries/Cabal | 0 | ||||
-rw-r--r-- | libraries/base/.gitignore | 1 | ||||
-rw-r--r-- | m4/fp_find_libdw.m4 | 3 | ||||
-rw-r--r-- | rts/.gitignore | 5 | ||||
-rw-r--r-- | rts/configure.ac | 57 | ||||
-rw-r--r-- | rts/rts.cabal.in | 18 |
14 files changed, 116 insertions, 50 deletions
@@ -63,7 +63,7 @@ def autoreconf(): else: reconf_cmd = 'autoreconf' - for dir_ in ['.'] + glob.glob('libraries/*/'): + for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'): if os.path.isfile(os.path.join(dir_, 'configure.ac')): print("Booting %s" % dir_) # Update config.sub in submodules diff --git a/hadrian/cabal.project b/hadrian/cabal.project index 769b1f0558..b8991ad09e 100644 --- a/hadrian/cabal.project +++ b/hadrian/cabal.project @@ -1,4 +1,6 @@ packages: ./ +-- N.B. This could be removed once Cabal 3.9 is released. +packages: ../libraries/Cabal/Cabal, ../libraries/Cabal/Cabal-syntax -- This essentially freezes the build plan for hadrian index-state: 2022-11-19T22:13:06Z diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal index b220f27462..9e0d177f76 100644 --- a/hadrian/hadrian.cabal +++ b/hadrian/hadrian.cabal @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.9 + build-depends: Cabal >= 3.9 && < 3.10 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 diff --git a/hadrian/src/Base.hs b/hadrian/src/Base.hs index 3fcc3bb3c6..21849af0b2 100644 --- a/hadrian/src/Base.hs +++ b/hadrian/src/Base.hs @@ -20,9 +20,6 @@ module Base ( module Stage, module Way, - -- * Files - configH, - -- * Paths hadrianPath, configPath, configFile, sourcePath, shakeFilesDir, stageBinPath, stageLibPath, templateHscPath, @@ -72,11 +69,6 @@ configFile = configPath -/- "system.config" sourcePath :: FilePath sourcePath = hadrianPath -/- "src" --- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h@. --- | Path to the generated @mk/config.h@ file. -configH :: FilePath -configH = "mk/config.h" - -- | The directory in 'buildRoot' containing the Shake database and other -- auxiliary files generated by Hadrian. shakeFilesDir :: FilePath diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index dfb4924889..f2b5deac1b 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -146,22 +146,31 @@ configurePackage context@Context {..} = do need deps -- Figure out what hooks we need. - hooks <- case C.buildType (C.flattenPackageDescription gpd) of + hooks <- if + -- Not quite right, but good enough for us: + | package == rts -> + -- Don't try to do post configuration validation for 'rts'. This + -- will simply not work, due to the @ld-options@ and @Stg.h@. + -- + -- We used to just mkae the whole 'postConf' a no-op, but now + -- that th RTS has a configure script we do need to at least run + -- it, which is the first part of the stock 'postConf'. + pure $ C.autoconfUserHooks { + C.postConf = \_ flags pd lbi -> do + _ <- C.runConfigureScriptAndReadAndValidateBuildInfo flags pd lbi + pure () + } + | otherwise -> case C.buildType (C.flattenPackageDescription gpd) of C.Configure -> pure C.autoconfUserHooks + C.Simple -> pure C.simpleUserHooks + C.Make -> fail "build-type: Make is not supported" -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also -- 'C.Custom', but doesn't have a configure script. C.Custom -> do - configureExists <- doesFileExist $ - replaceFileName (pkgCabalFile package) "configure" - pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks - -- Not quite right, but good enough for us: - _ | package == rts -> - -- Don't try to do post configuration validation for 'rts'. This - -- will simply not work, due to the @ld-options@ and @Stg.h@. - pure $ C.simpleUserHooks { C.postConf = \_ _ _ _ -> return () } - | otherwise -> pure C.simpleUserHooks - + configureExists <- doesFileExist $ + replaceFileName (pkgCabalFile package) "configure" + pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks -- Compute the list of flags, and the Cabal configuration arguments flavourArgs <- args <$> flavour flagList <- interpret (target context (Cabal Flags stage) [] []) flavourArgs diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 2c02407d31..b156c9dfdf 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -147,7 +147,8 @@ generatePackageCode context@(Context stage pkg _ _) = do root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file -> build $ target context GenApply [] [file] let go gen file = generate file (semiEmptyTarget stage) gen - root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> go generateGhcAutoconfH + root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ -> + need . pure =<< pkgSetupConfigFile context root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines" @@ -486,26 +487,6 @@ generateConfigHs = do stageString (Stage0 GlobalLibs) = error "stageString: StageBoot" --- | Generate @ghcautoconf.h@ header. -generateGhcAutoconfH :: Expr String -generateGhcAutoconfH = do - trackGenerateHs - configHContents <- expr $ mapMaybe undefinePackage <$> readFileLines configH - return . unlines $ - [ "#if !defined(__GHCAUTOCONF_H__)" - , "#define __GHCAUTOCONF_H__" ] - ++ configHContents ++ - [ "#endif /* __GHCAUTOCONF_H__ */" ] - where - undefinePackage s - | "#define PACKAGE_" `isPrefixOf` s - = Just $ "/* #undef " ++ takeWhile (/=' ') (drop 8 s) ++ " */" - | "#define __GLASGOW_HASKELL" `isPrefixOf` s - = Nothing - | "/* REMOVE ME */" == s - = Nothing - | otherwise = Just s - -- | Generate @Version.hs@ files. generateVersionHs :: Expr String generateVersionHs = do diff --git a/hadrian/src/Rules/Lint.hs b/hadrian/src/Rules/Lint.hs index fa279fa836..0928ec02eb 100644 --- a/hadrian/src/Rules/Lint.hs +++ b/hadrian/src/Rules/Lint.hs @@ -11,13 +11,15 @@ lintRules :: Rules () lintRules = do "lint:base" ~> lint base "lint:compiler" ~> lint compiler + + -- Ensure that autoconf scripts, which are usually run by Cabal, are run to + -- avoid depending upon Cabal from the stage0 compiler.. "libraries" -/- "base" -/- "include" -/- "HsBaseConfig.h" %> \_ -> -- ./configure is called here manually because we need to generate -- HsBaseConfig.h, which is created from HsBaseConfig.h.in. ./configure - -- is usually run by Cabal which generates this file but if we do that - -- then hadrian thinks it needs to build the stage0 compiler before - -- attempting to configure. Therefore we just run it directly here. cmd_ (Cwd "libraries/base") "./configure" + "rts" -/- "include" -/- "ghcautoconf.h" %> \_ -> + cmd_ (Cwd "rts") "./configure" lint :: Action () -> Action () lint lintAction = do diff --git a/hadrian/src/Rules/Register.hs b/hadrian/src/Rules/Register.hs index e716204614..8543576215 100644 --- a/hadrian/src/Rules/Register.hs +++ b/hadrian/src/Rules/Register.hs @@ -45,6 +45,12 @@ configurePackageRules = do isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend when isGmp $ need [buildP -/- "include/ghc-gmp.h"] + when (pkg == rts) $ do + -- Rts.h is a header listed in the cabal file, and configuring + -- therefore wants to ensure that the header "works" post-configure. + -- But it (transitively) includes this, so we must ensure it exists + -- for that check to work. + need [buildP -/- "include/ghcplatform.h"] Cabal.configurePackage ctx root -/- "**/autogen/cabal_macros.h" %> \out -> do diff --git a/libraries/Cabal b/libraries/Cabal -Subproject 6cd29789ca866464dc3af89f62c98c41264ce3c +Subproject 5abfa5032cb6f011c9a7e02d14c9f10dcb2d660 diff --git a/libraries/base/.gitignore b/libraries/base/.gitignore index 6a6d524a3f..c7521d6fb0 100644 --- a/libraries/base/.gitignore +++ b/libraries/base/.gitignore @@ -19,4 +19,3 @@ /include/EventConfig.h /include/HsBaseConfig.h /include/HsBaseConfig.h.in - diff --git a/m4/fp_find_libdw.m4 b/m4/fp_find_libdw.m4 index ce830c0fa8..29008408d7 100644 --- a/m4/fp_find_libdw.m4 +++ b/m4/fp_find_libdw.m4 @@ -48,9 +48,6 @@ AC_DEFUN([FP_FIND_LIBDW], AC_SUBST(UseLibdw) if test $UseLibdw = "YES" ; then USE_LIBDW=1 - AC_SUBST([CabalHaveLibdw],[True]) - else - AC_SUBST([CabalHaveLibdw],[False]) fi AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw]) ]) diff --git a/rts/.gitignore b/rts/.gitignore index a0fafa79ab..662c3c974c 100644 --- a/rts/.gitignore +++ b/rts/.gitignore @@ -12,7 +12,12 @@ /package.conf.install.raw /fs.* +/aclocal.m4 /autom4te.cache/ /config.log /config.status /configure + +/ghcautoconf.h.autoconf.in +/ghcautoconf.h.autoconf +/include/ghcautoconf.h diff --git a/rts/configure.ac b/rts/configure.ac new file mode 100644 index 0000000000..fa90a0e114 --- /dev/null +++ b/rts/configure.ac @@ -0,0 +1,57 @@ +# Configure script template for the Run-time System of GHC +# +# Process with 'autoreconf' to get a working configure script. +# +# For the generated configure script, do "./configure --help" to +# see what flags are available. (Better yet, read the documentation!) +# + +AC_INIT([GHC run-time system], [1.0.2], [libraries@haskell.org], [rts]) + +AC_CONFIG_MACRO_DIRS([../m4]) + +# Safety check: Ensure that we are in the correct source directory. +AC_CONFIG_SRCDIR([include/rts/Constants.h]) + +dnl * We require autoconf version 2.69 due to +dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. +dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. +dnl * We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH. +dnl * Using autoconf 2.59 started to give nonsense like this +dnl #define SIZEOF_CHAR 0 +dnl recently. +AC_PREREQ([2.69]) + +AC_CONFIG_HEADERS([ghcautoconf.h.autoconf]) + +# We have to run these unconditionally, but we may discard their +# results in the following code +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +FPTOOLS_SET_PLATFORM_VARS([host], [Host]) +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) + +AC_OUTPUT + +dnl ###################################################################### +dnl Generate ghcautoconf.h +dnl ###################################################################### + +[ +mkdir -p include +touch include/ghcautoconf.h +> include/ghcautoconf.h + +echo "#if !defined(__GHCAUTOCONF_H__)" >> include/ghcautoconf.h +echo "#define __GHCAUTOCONF_H__" >> include/ghcautoconf.h +# Copy the contents of $srcdir/../mk/config.h, turning '#define PACKAGE_FOO +# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes. +cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \ + -e 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$,\1/* #undef \2 */,' \ + -e '/__GLASGOW_HASKELL/d' \ + -e '/REMOVE ME/d' \ + >> include/ghcautoconf.h +echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h +] diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in index 0b76f9b218..5213a0fecd 100644 --- a/rts/rts.cabal.in +++ b/rts/rts.cabal.in @@ -1,9 +1,24 @@ cabal-version: 3.0 name: rts version: 1.0.2 +synopsis: The GHC runtime system +description: + The GHC runtime system. + + Code produced by GHC links this library to provide missing functionality + that cannot be written in Haskell itself. license: BSD-3-Clause maintainer: glasgow-haskell-users@haskell.org -build-type: Simple +build-type: Configure + +extra-source-files: + configure + configure.ac + +extra-tmp-files: + autom4te.cache + config.log + config.status source-repository head type: git @@ -206,6 +221,7 @@ library include-dirs: include includes: Rts.h + autogen-includes: ghcautoconf.h install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h -- ^ from include |