[Git][ghc/ghc][wip/rts-configure-0] Give the RTS it's own configure script

John Ericson (@Ericson2314) gitlab at gitlab.haskell.org
Fri Dec 30 05:38:51 UTC 2022



John Ericson pushed to branch wip/rts-configure-0 at Glasgow Haskell Compiler / GHC


Commits:
eff7bcd3 by John Ericson at 2022-12-30T00:38:32-05:00
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.

- - - - -


11 changed files:

- boot
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Lint.hs
- hadrian/src/Rules/Register.hs
- libraries/base/.gitignore
- m4/fp_find_libdw.m4
- rts/.gitignore
- + rts/ConfigLocal.h.post
- + rts/ConfigLocal.h.pre
- + rts/configure.ac
- rts/rts.cabal.in


Changes:

=====================================
boot
=====================================
@@ -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


=====================================
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


=====================================
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


=====================================
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


=====================================
libraries/base/.gitignore
=====================================
@@ -19,4 +19,3 @@
 /include/EventConfig.h
 /include/HsBaseConfig.h
 /include/HsBaseConfig.h.in
-


=====================================
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])
 ])


=====================================
rts/.gitignore
=====================================
@@ -16,3 +16,6 @@
 /config.log
 /config.status
 /configure
+
+/ghcautoconf.h.autoconf.in
+/ghcautoconf.h.autoconf


=====================================
rts/ConfigLocal.h.post
=====================================
@@ -0,0 +1,3 @@
+/* -----------------------------------------------------------------------------
+   End automatic from autoconf
+   -------------------------------------------------------------------------- */


=====================================
rts/ConfigLocal.h.pre
=====================================
@@ -0,0 +1,19 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 1998-2009
+ *
+ * Rts settings from rts-specific configure.
+ *
+ * NOTE: Over time, this might replace Config.h as everything is migrated
+ * here, but for now we need both.
+ *
+ * To understand the structure of the RTS headers, see the wiki:
+ *   https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes
+ *
+ * ---------------------------------------------------------------------------*/
+
+#pragma once
+
+/* -----------------------------------------------------------------------------
+   Begin automatic from autoconf
+   -------------------------------------------------------------------------- */


=====================================
rts/configure.ac
=====================================
@@ -0,0 +1,53 @@
+# 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 at 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_HEADER([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
+
+[
+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 mk/config.h, turning '#define PACKAGE_FOO
+# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
+sed ghcautoconf.h.autoconf \
+   -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
+]


=====================================
rts/rts.cabal.in
=====================================
@@ -3,13 +3,25 @@ name: rts
 version: 1.0.2
 license: BSD-3-Clause
 maintainer: glasgow-haskell-users at haskell.org
-build-type: Simple
+build-type: Configure
+description:
+    The run-time system for code produced by GHC.
 
 source-repository head
     type:     git
     location: https://gitlab.haskell.org/ghc/ghc.git
     subdir:   rts
 
+extra-source-files:
+  configure
+  configure.ac
+
+extra-tmp-files:
+  autom4te.cache
+  rts.buildinfo
+  config.log
+  config.status
+
 flag libm
   default: @CabalHaveLibm@
 flag librt
@@ -206,6 +218,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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eff7bcd301f35ad4c138f5af6e5d2f91570553e0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eff7bcd301f35ad4c138f5af6e5d2f91570553e0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221230/74186506/attachment-0001.html>


More information about the ghc-commits mailing list