Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the configure (rather than build) system handle the compiler's version #10658

Merged
merged 14 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# No header for text files (would be too obtrusive).
*.md typo.missing-header
README* typo.missing-header
VERSION typo.missing-header
*.adoc typo.missing-header
api_docgen/*.mld typo.missing-header
api_docgen/alldoc.tex typo.missing-header
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ _build
/lex/parser.output

/manual/src/cmds/warnings-help.etex
/manual/src/html_processing/src/common.ml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed by the distclean target in manual/src/html_processing/Makefile

/manual/src/warnings-help.etex

/api_docgen/build
Expand Down
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Working version
(Nicolás Ojeda Bär, review by Daniel Bünzli, Jérémie Dimino, Damien Doligez
and Xavier Leroy)

- #10658: add detailed information about the current version of OCaml
to the Sys module of the standard library.
(Sébastien Hinderer, review by Damien Doligez, Gabriel Scherer, David
Allsopp, Nicolás Ojeda Bär, Vincent Laviron)

### Other libraries:

- #10192: Add support for Unix domain sockets on Windows and use them
Expand Down
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ utils/domainstate.ml: utils/domainstate.ml.c runtime/caml/domain_state.tbl
utils/domainstate.mli: utils/domainstate.mli.c runtime/caml/domain_state.tbl
$(CPP) -I runtime/caml $< > $@

configure: configure.ac aclocal.m4 VERSION tools/autogen
configure: configure.ac aclocal.m4 build-aux/ocaml_version.m4 tools/autogen
tools/autogen

.PHONY: partialclean
Expand Down Expand Up @@ -625,6 +625,9 @@ clean::
manual-pregen: opt.opt
cd manual; $(MAKE) clean && $(MAKE) pregen-etex

clean::
$(MAKE) -C manual clean

# The clean target
clean:: partialclean
rm -f $(programs) $(programs:=.exe)
Expand Down Expand Up @@ -898,9 +901,16 @@ parsing/camlinternalMenhirLib.mli: boot/menhir/menhirLib.mli

# Copy parsing/parser.ml from boot/

parsing/parser.ml: boot/menhir/parser.ml parsing/parser.mly \
tools/check-parser-uptodate-or-warn.sh
PARSER_DEPS = boot/menhir/parser.ml parsing/parser.mly

ifeq "$(OCAML_DEVELOPMENT_VERSION)" "true"
PARSER_DEPS += tools/check-parser-uptodate-or-warn.sh
endif

parsing/parser.ml: $(PARSER_DEPS)
ifeq "$(OCAML_DEVELOPMENT_VERSION)" "true"
@-tools/check-parser-uptodate-or-warn.sh
endif
sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@
parsing/parser.mli: boot/menhir/parser.mli
sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@
Expand Down Expand Up @@ -1144,19 +1154,20 @@ depend: beforedepend

.PHONY: distclean
distclean: clean
$(MAKE) -C manual distclean
$(MAKE) -C runtime distclean
$(MAKE) -C stdlib distclean
rm -f boot/ocamlrun boot/ocamlrun.exe boot/camlheader \
boot/ocamlruns boot/ocamlruns.exe \
boot/flexlink.byte boot/flexlink.byte.exe \
boot/flexdll_*.o boot/flexdll_*.obj \
boot/*.cm* boot/libcamlrun.a boot/libcamlrun.lib boot/ocamlc.opt
rm -f Makefile.config Makefile.build_config
rm -f runtime/caml/m.h runtime/caml/s.h
rm -rf autom4te.cache flexdll-sources
rm -f config.log config.status libtool
rm -f tools/eventlog_metadata
rm -f tools/*.bak
rm -f testsuite/_log*
$(MAKE) -C stdlib distclean

include .depend

Expand Down
7 changes: 7 additions & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

# The configuration Makefile

## Variables defining the current version of OCaml
OCAML_DEVELOPMENT_VERSION=@OCAML_DEVELOPMENT_VERSION@
OCAML_VERSION_MAJOR=@OCAML_VERSION_MAJOR@
OCAML_VERSION_MINOR=@OCAML_VERSION_MINOR@
OCAML_VERSION_PATCHLEVEL=@OCAML_VERSION_PATCHLEVEL@
OCAML_VERSION_EXTRA=@OCAML_VERSION_EXTRA@

## The EMPTY variable, used in other definitions
EMPTY=

Expand Down
12 changes: 10 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
4.14.0+dev0-2021-06-03

# The version string is the first line of this file.
# It must be in the format described in stdlib/sys.mli
# Starting with OCaml 4.14, although the version string that appears above is
# still correct and this file can thus still be used to figure it out,
# the version itself is actually defined in the build-aux/ocaml_version.m4
# file (See the OCAML__VERSION* macros there.)
# To update the present VERSION file:
# 1. Update build-aux/ocaml_version.m4
# 2. Run tools/autogen.
# 3. If you are in a context where version control matters,
# commit the changes to both build-aux/ocaml_version.m4 and VERSION.
# The version string must be in the format described in stdlib/sys.mli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERSION now has more than 9 lines, so check-typo expects it to have a valid copyright header. typo.missing-header needs to go in .gitattributes, therefore.

3 changes: 3 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ m4_include([build-aux/lt~obsolete.m4])
m4_include([build-aux/ax_func_which_gethostbyname_r.m4])
m4_include([build-aux/ax_pthread.m4])

# OCaml version
m4_include([build-aux/ocaml_version.m4])

# The following macro figures out which C compiler is used.
# It does so by checking for compiler-specific predefined macros.
# A list of such macros can be found at
Expand Down
90 changes: 90 additions & 0 deletions build-aux/ocaml_version.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#**************************************************************************
#* *
#* OCaml *
#* *
#* Sebastien Hinderer, projet Cambium, INRIA Paris *
#* *
#* Copyright 2021 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************

# This file contains all the macros used to describe the current version of
# OCaml. It first defines the basic components and then computes all
# the different variants of the version used across the build system.

# For the M4 macros defined below, we use the OCAML__ (with a double
# underscore) to distinguish them from the C preprocessor macros which
# use a single underscore, since the two families of macros coexist
# in configure.ac.

# The following macro, OCAML__DEVELOPMENT_VERSION, should be either
# [true] of [false].

m4_define([OCAML__DEVELOPMENT_VERSION], [true])

# The three following components (major, minor and patch level) MUST be
# integers. They MUST NOT be left-padded with zeros and all of them,
# including the patchlevel, are mandatory.

m4_define([OCAML__VERSION_MAJOR], [4])
m4_define([OCAML__VERSION_MINOR], [14])
m4_define([OCAML__VERSION_PATCHLEVEL], [0])
# Note that the OCAML__VERSION_EXTRA string defined below is always empty
# for officially-released versions of OCaml.
m4_define([OCAML__VERSION_EXTRA], [dev0-2021-06-03])

# The OCAML__VERSION_EXTRA_PREFIX macro defined below should be a
# single character:
# Either [~] to mean that we are approaching the OCaml public release
# OCAML__VERSION_MAJOR.OCAML__VERSION_MINOR.OCAML__VERSION_PATCHLEVEL
# and with an empty OCAML__VERSION_EXTRA string;
# Or [+] to give more info about this specific version.
# Development releases, for instance, should use a [+] prefix.
m4_define([OCAML__VERSION_EXTRA_PREFIX], [+])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your text above, this + should be a ~

Suggested change
m4_define([OCAML__VERSION_EXTRA_PREFIX], [+])
m4_define([OCAML__VERSION_EXTRA_PREFIX], [~])

m4_define([OCAML__VERSION_SHORT], [OCAML__VERSION_MAJOR.OCAML__VERSION_MINOR])
# The OCAML__VERSION below must be in the format specified in stdlib/sys.mli
m4_define([OCAML__VERSION],
[m4_do(
OCAML__VERSION_SHORT.OCAML__VERSION_PATCHLEVEL,
m4_if(OCAML__VERSION_EXTRA,[],[],
OCAML__VERSION_EXTRA_PREFIX[]OCAML__VERSION_EXTRA))])

# Generate the VERSION file
# The following command is invoked when autoconf is run to generate configure
# from configure.ac, not while configure itself is run.
# In other words, both VERSION and configure are produced by invoking
# autoconf (usually done by calling tools/autogen for this project)
m4_syscmd([cat > VERSION << END_OF_VERSION_FILE
]OCAML__VERSION[

# Starting with OCaml 4.14, although the version string that appears above is
# still correct and this file can thus still be used to figure it out,
# the version itself is actually defined in the build-aux/ocaml_version.m4
# file (See the OCAML__VERSION* macros there.)
# To update the present VERSION file:
# 1. Update build-aux/ocaml_version.m4
# 2. Run tools/autogen.
# 3. If you are in a context where version control matters,
# commit the changes to both build-aux/ocaml_version.m4 and VERSION.
# The version string must be in the format described in stdlib/sys.mli
END_OF_VERSION_FILE
])

# Other variants of the version needed here and there in the compiler

m4_define([OCAML__VERSION_NUMBER],
[m4_format(
[%d%02d%02d],
OCAML__VERSION_MAJOR,
OCAML__VERSION_MINOR,
OCAML__VERSION_PATCHLEVEL)])

m4_define([OCAML__RELEASE_EXTRA],
m4_if(OCAML__VERSION_EXTRA,[],[None],
['Some (]m4_if(OCAML__VERSION_EXTRA_PREFIX,+,[Plus],
[Tilde])[, "]OCAML__VERSION_EXTRA[")']))]))
54 changes: 50 additions & 4 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 25 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Require Autoconf 2.69 for repeatability in CI
AC_PREREQ([2.69])
AC_INIT([OCaml],
m4_esyscmd([head -n1 VERSION | tr -d '\r\n']),
[OCAML__VERSION],
[caml-list@inria.fr],
[ocaml],
[http://www.ocaml.org])
Expand Down Expand Up @@ -78,6 +78,13 @@ AC_CONFIG_AUX_DIR([build-aux])
AC_SUBST([CONFIGURE_ARGS])
AC_SUBST([native_compiler])
AC_SUBST([VERSION], [AC_PACKAGE_VERSION])
AC_SUBST([OCAML_DEVELOPMENT_VERSION], [OCAML__DEVELOPMENT_VERSION])
AC_SUBST([OCAML_RELEASE_EXTRA], [OCAML__RELEASE_EXTRA])
AC_SUBST([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR])
AC_SUBST([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR])
AC_SUBST([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL])
AC_SUBST([OCAML_VERSION_EXTRA], [OCAML__VERSION_EXTRA])
AC_SUBST([OCAML_VERSION_SHORT], [OCAML__VERSION_SHORT])
AC_SUBST([CC])
# Note: This is present for the flexdll bootstrap where it exposed as the old
# TOOLPREF variable. It would be better if flexdll where updated to require
Expand Down Expand Up @@ -176,9 +183,22 @@ AC_SUBST([naked_pointers_checker])
AC_CONFIG_FILES([Makefile.build_config])
AC_CONFIG_FILES([Makefile.config])
AC_CONFIG_FILES([stdlib/sys.ml])
AC_CONFIG_FILES([manual/src/version.tex])
AC_CONFIG_FILES([manual/src/html_processing/src/common.ml])
AC_CONFIG_FILES([tools/eventlog_metadata])
AC_CONFIG_HEADERS([runtime/caml/m.h])
AC_CONFIG_HEADERS([runtime/caml/s.h])
AC_CONFIG_HEADERS([runtime/caml/version.h])

# Definitions related to the version of OCaml
AC_DEFINE([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR])
AC_DEFINE([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR])
AC_DEFINE([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL])
m4_if([OCAML__VERSION_EXTRA],[], [],
[AC_DEFINE([OCAML_VERSION_ADDITIONAL], ["][OCAML__VERSION_EXTRA]["])
AC_DEFINE([OCAML_VERSION_EXTRA], ["][OCAML__VERSION_EXTRA]["])])
AC_DEFINE([OCAML_VERSION], [OCAML__VERSION_NUMBER])
AC_DEFINE([OCAML_VERSION_STRING], ["][OCAML__VERSION]["])

# Checks for system types

Expand Down Expand Up @@ -591,8 +611,8 @@ AS_CASE([$ocaml_cv_cc_vendor],
warn_error_flag='-Werror'
cc_warnings='-Wall -Wdeclaration-after-statement'])

AS_CASE([$enable_warn_error,AC_PACKAGE_VERSION],
[yes,*|,*+dev*],
AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION],
[yes,*|,true],
[cc_warnings="$cc_warnings $warn_error_flag"])

# We select high optimization levels, provided we can turn off:
Expand Down Expand Up @@ -1873,8 +1893,8 @@ AS_IF([test "x$documentation_tool_cmd" = 'x']



AS_CASE([$enable_ocamltest,AC_PACKAGE_VERSION],
[yes,*|,*+dev*],[ocamltest='ocamltest'],
AS_CASE([$enable_ocamltest,OCAML__DEVELOPMENT_VERSION],
[yes,*|,true],[ocamltest='ocamltest'],
[ocamltest=''])

AS_IF([test x"$enable_flambda" = "xyes"],
Expand Down