[Git][ghc/ghc][wip/simpler-ghcversion.h] 2 commits: `ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`

John Ericson (@Ericson2314) gitlab at gitlab.haskell.org
Fri Oct 13 23:35:29 UTC 2023



John Ericson pushed to branch wip/simpler-ghcversion.h at Glasgow Haskell Compiler / GHC


Commits:
8fa5a02e by John Ericson at 2023-10-13T19:35:13-04:00
`ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`

Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
be defined. (Guaranteed including a test in the testsuite.)

- - - - -
91171158 by John Ericson at 2023-10-13T19:35:23-04:00
Generate `ghcversion.h` from a `.in` file

Now that there are no conditional sections (see the previous commit), we
can just a do simple substitution rather than pasting it together line
by line.

- - - - -


6 changed files:

- configure.ac
- rts/.gitignore
- rts/configure.ac
- rts/ghcversion.h.bottom → rts/ghcversion.h.in
- − rts/ghcversion.h.top
- rts/rts.cabal


Changes:

=====================================
configure.ac
=====================================
@@ -68,23 +68,6 @@ FP_PROG_SORT
 dnl ----------------------------------------------------------
 FP_SETUP_PROJECT_VERSION
 
-dnl Don't use AC_DEFINE because it will make C-style comments invalid for
-dnl Haskell.
-
-> rts/include/ghcversion.h
-
-cat rts/ghcversion.h.top                                                >> rts/include/ghcversion.h
-
-echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}"                 >> rts/include/ghcversion.h
-echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\""   >> rts/include/ghcversion.h
-echo                                                                    >> rts/include/ghcversion.h
-AS_IF([test x"${ProjectPatchLevel1}" != x],
-  [echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h])
-AS_IF([test x"${ProjectPatchLevel2}" != x],
-  [echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h])
-
-cat rts/ghcversion.h.bottom                                             >> rts/include/ghcversion.h
-
 # Hmmm, we fix the RPM release number to 1 here... Is this convenient?
 AC_SUBST([release], [1])
 
@@ -105,8 +88,12 @@ AC_PREREQ([2.69])
 AC_CONFIG_HEADER(mk/config.h)
 # This one is manually maintained.
 AC_CONFIG_HEADER(compiler/ghc-llvm-version.h)
-dnl manually outputted above, for reasons described there.
-dnl AC_CONFIG_HEADER(rts/include/ghcversion.h)
+dnl Don't use `AC_CONFIG_HEADER` because it will make C-style comments
+dnl invalid for Haskell.
+dnl
+dnl RTS configure will copy resulting file into place, so `.in` file
+dnl doesn't pollute the build.
+AC_CONFIG_FILES(rts/ghcversion.h)
 
 # No, semi-sadly, we don't do `--srcdir'...
 if test x"$srcdir" != 'x.' ; then


=====================================
rts/.gitignore
=====================================
@@ -2,6 +2,7 @@
 /dist/
 /dist-*/
 
+/ghcversion.h
 /include/ghcversion.h
 
 /package.conf.inplace


=====================================
rts/configure.ac
=====================================
@@ -243,6 +243,16 @@ cat $srcdir/../mk/config.h ghcautoconf.h.autoconf | sed \
 echo "#endif /* __GHCAUTOCONF_H__ */" >> include/ghcautoconf.h
 ]
 
+dnl ######################################################################
+dnl Generate ghcversion.h
+dnl ######################################################################
+
+[
+# Copy the file the top-level configure script created into place. We
+# don't have the right version information to generate it ourselves.
+cp $srcdir/ghcversion.h include/ghcversion.h
+]
+
 dnl ######################################################################
 dnl Generate external symbol flags (-Wl,-u...)
 dnl ######################################################################


=====================================
rts/ghcversion.h.bottom → rts/ghcversion.h.in
=====================================
@@ -1,3 +1,11 @@
+#if !defined(__GHCVERSION_H__)
+#define __GHCVERSION_H__
+
+#define __GLASGOW_HASKELL__ @ProjectVersionInt@
+#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@"
+
+#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@
+#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@
 
 #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \
    ((ma)*100+(mi)) <  __GLASGOW_HASKELL__ || \


=====================================
rts/ghcversion.h.top deleted
=====================================
@@ -1,3 +0,0 @@
-#if !defined(__GHCVERSION_H__)
-#define __GHCVERSION_H__
-


=====================================
rts/rts.cabal
=====================================
@@ -240,7 +240,7 @@ library
 
       include-dirs: include
       includes: Rts.h
-      autogen-includes: ghcautoconf.h
+      autogen-includes: ghcautoconf.h ghcversion.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/-/compare/7a859daa2ec12ef3a3505a4d03789cd2810bfd01...91171158ecbd9429e803bb0af1760cad518f267d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a859daa2ec12ef3a3505a4d03789cd2810bfd01...91171158ecbd9429e803bb0af1760cad518f267d
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/20231013/64bd77bf/attachment-0001.html>


More information about the ghc-commits mailing list