From 987b0814d721d583a96b362762760508f4d07a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= Date: Mon, 30 Sep 2019 16:01:29 +0200 Subject: [PATCH] Let make's default target build the compiler This commit makes it possible to build the OCaml compiler according to its configuration by simply runnning make. There is no need to specify neither world nor world.opt explicitly, although the two targets remain available. This commit also introduces (and starts making use of) the NATIVE_COMPILER build variable whosse value is true when the native compiler is enabled and false otherwise. --- Changes | 3 +++ HACKING.adoc | 2 +- INSTALL.adoc | 15 ++++----------- Makefile | 25 +++++++++++++++---------- Makefile.config.in | 3 +++ README.win32.adoc | 10 +++++----- configure | 2 ++ configure.ac | 1 + ocaml-variants.opam | 3 +-- stdlib/HACKING.adoc | 4 ++-- testsuite/lib/Makefile | 2 +- testsuite/tools/Makefile | 2 +- tools/ci/inria/main | 4 ++-- tools/release-checklist | 4 ++-- 14 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Changes b/Changes index d2b4543df504..61a573c0983f 100644 --- a/Changes +++ b/Changes @@ -237,6 +237,9 @@ Working version - #8947: fix/improve support for the BFD library (Sébastien Hinderer, review by Damien Doligez) +- #8951: let make's default target build the compiler + (Sébastien Hinderer, review by ) + - #8985, #8986: fix generation of the primitives when the locale collation is incompatible with C. (David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen) diff --git a/HACKING.adoc b/HACKING.adoc index 2958e85146df..8eb4b53be51b 100644 --- a/HACKING.adoc +++ b/HACKING.adoc @@ -20,7 +20,7 @@ git checkout -b my-modification + ---- ./configure -make world.opt +make ---- 3. Try the newly built compiler binaries `ocamlc`, `ocamlopt` or their diff --git a/INSTALL.adoc b/INSTALL.adoc index b77d2e5ecf03..9d63aaf5654f 100644 --- a/INSTALL.adoc +++ b/INSTALL.adoc @@ -70,20 +70,13 @@ for guidance on how to edit the generated files by hand. From the top directory, do: - make world.opt -+ -if your platform is supported by the native-code compiler (as reported during - the auto-configuration), or - - make world -+ -if not. + make -This builds the OCaml bytecode compiler for the first time. This phase is +This builds the OCaml compiler for the first time. This phase is fairly verbose; consider redirecting the output to a file: - make world > log.world 2>&1 # in sh - make world >& log.world # in csh + make > make.log 2>&1 # in sh + make >& make.log # in csh == (Optional) Running the testsuite diff --git a/Makefile b/Makefile index 37bfc27f8ea8..59aa1b9deeb4 100644 --- a/Makefile +++ b/Makefile @@ -20,18 +20,11 @@ ROOTDIR = . include Makefile.config include Makefile.common -# For users who don't read the INSTALL file .PHONY: defaultentry -defaultentry: -ifeq "$(UNIX_OR_WIN32)" "unix" - @echo "Please refer to the installation instructions in file INSTALL." - @echo "If you've just unpacked the distribution, something like" - @echo " ./configure" - @echo " make world.opt" - @echo " make install" - @echo "should work. But see the file INSTALL for more details." +ifeq "$(NATIVE_COMPILER)" "true" +defaultentry: world.opt else - @echo "Please refer to the instructions in file README.win32.adoc." +defaultentry: world endif MKDIR=mkdir -p @@ -1341,3 +1334,15 @@ distclean: clean rm -f testsuite/_log* include .depend + +Makefile.config Makefile.common: + @echo "Please refer to the installation instructions:" + @echo "- In file INSTALL for Unix systems." + @echo "- In file README.win32.adoc for Windows systems." + @echo "On Unix systems, if you've just unpacked the distribution," + @echo "something like" + @echo " ./configure" + @echo " make" + @echo " make install" + @echo "should work." + @false diff --git a/Makefile.config.in b/Makefile.config.in index d7ccb5be0f26..d9b4250912f1 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -113,6 +113,9 @@ RPATH=@rpath@ ############# Configuration for the native-code compiler +### Whether the native compiler has been enabled or not +NATIVE_COMPILER=@native_compiler@ + ### Name of architecture for the native-code compiler ### Currently supported: ### diff --git a/README.win32.adoc b/README.win32.adoc index c8ab81c43621..0c70d51821ff 100644 --- a/README.win32.adoc +++ b/README.win32.adoc @@ -191,7 +191,7 @@ the top-level of the OCaml distribution by running: eval $(tools/msvs-promote-path) -If you forget to do this, `make world.opt` will fail relatively +If you forget to do this, `make` will fail relatively quickly as it will be unable to link `ocamlrun`. Now run: @@ -208,7 +208,7 @@ which indicates where to install everything. Finally, use `make` to build the system, e.g. - make world.opt + make make install After installing, it is not necessary to keep the Cygwin installation (although @@ -275,7 +275,7 @@ which indicates where to install everything. Finally, use `make` to build the system, e.g. - make world.opt + make make install After installing, you will need to ensure that `ocamlopt` (or `ocamlc -custom`) @@ -314,10 +314,10 @@ done in one of three ways: git submodule update --init OCaml is then compiled as normal for the port you require, except that before -compiling `world`, you must compile `flexdll`, i.e.: +building the compiler itself, you must compile `flexdll`, i.e.: make flexdll - make world.opt + make make flexlink.opt make install diff --git a/configure b/configure index c1613bd51499..3e45e09ff342 100755 --- a/configure +++ b/configure @@ -782,6 +782,7 @@ ac_tool_prefix DIRECT_CPP CC VERSION +native_compiler CONFIGURE_ARGS target_alias host_alias @@ -2735,6 +2736,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ## Output variables + VERSION=4.10.0+dev0-2019-04-23 diff --git a/configure.ac b/configure.ac index 0934a91f78a0..d0b4f4275a41 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,7 @@ AC_CONFIG_AUX_DIR([build-aux]) ## Output variables AC_SUBST([CONFIGURE_ARGS]) +AC_SUBST([native_compiler]) AC_SUBST([VERSION], [AC_PACKAGE_VERSION]) AC_SUBST([CC]) # Note: This is present for the flexdll bootstrap where it exposed as the old diff --git a/ocaml-variants.opam b/ocaml-variants.opam index d4f0aee70fc9..9916c862defa 100644 --- a/ocaml-variants.opam +++ b/ocaml-variants.opam @@ -12,8 +12,7 @@ flags: compiler setenv: CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs" build: [ ["./configure" "--prefix=%{prefix}%"] - [make "-j%{jobs}%" "world"] - [make "-j%{jobs}%" "world.opt"] + [make "-j%{jobs}%"] ] install: [make "install"] maintainer: "caml-list@inria.fr" diff --git a/stdlib/HACKING.adoc b/stdlib/HACKING.adoc index 407d079e3424..02b8505597fb 100644 --- a/stdlib/HACKING.adoc +++ b/stdlib/HACKING.adoc @@ -5,7 +5,7 @@ link:../CONTRIBUTING.md#contributing-to-the-standard-library[]. Note: All paths are given relative to the root of the repository. -First, build the compiler. Run `./configure`, then `make world.opt`. See +First, build the compiler. Run `./configure`, then `make`. See link:../HACKING.adoc[]. To add a new module, you must: @@ -30,7 +30,7 @@ To add a new module, you must: * Run `make alldepend` to update all the `.depend` files. These files are not edited by hand. -* Run `make clean` or `make partialclean`, then `make world.opt`. +* Run `make clean` or `make partialclean`, then `make`. If you are adding multiple modules, follow the steps above and rebuild the compiler after adding each module. If you add multiple modules before diff --git a/testsuite/lib/Makefile b/testsuite/lib/Makefile index aa27995a094e..982d021f6e10 100644 --- a/testsuite/lib/Makefile +++ b/testsuite/lib/Makefile @@ -22,7 +22,7 @@ include $(TOPDIR)/Makefile.tools libraries := testing.cmi testing.cma lib.cmo # If the native compiler is enabled, then also compile testing.cmxa -ifneq "$(ARCH)" "none" +ifeq "$(NATIVE_COMPILER)" "true" libraries += testing.cmxa endif diff --git a/testsuite/tools/Makefile b/testsuite/tools/Makefile index b75febf4bee2..7166c2dc9c03 100644 --- a/testsuite/tools/Makefile +++ b/testsuite/tools/Makefile @@ -40,7 +40,7 @@ codegen_OBJECTS = $(addsuffix .cmo,\ tools := $(expect_PROG) -ifneq "$(ARCH)" "none" +ifeq "$(NATIVE_COMPILER)" "true" tools += $(codegen_PROG) ifneq "$(CCOMPTYPE)-$(ARCH)" "msvc-amd64" # The asmgen tests are not ported to MSVC64 yet diff --git a/tools/ci/inria/main b/tools/ci/inria/main index ee72f56e3913..428575f3d233 100755 --- a/tools/ci/inria/main +++ b/tools/ci/inria/main @@ -229,10 +229,10 @@ fi eval ./configure "$CCOMP" $build $host --prefix='$instdir' $confoptions if $make_native; then - $make $jobs --warn-undefined-variables world.opt + $make $jobs --warn-undefined-variables if $check_make_alldepend; then $make --warn-undefined-variables alldepend; fi else - $make $jobs --warn-undefined-variables world + $make $jobs --warn-undefined-variables fi if $dorebase; then # temporary solution to the cygwin fork problem diff --git a/tools/release-checklist b/tools/release-checklist index 392106f88add..4da54b40bed9 100644 --- a/tools/release-checklist +++ b/tools/release-checklist @@ -78,7 +78,7 @@ INSTDIR=/tmp/ocaml-${VERSION} rm -rf ${INSTDIR} ./configure -prefix ${INSTDIR} -make world.opt -j5 +make -j5 make alldepend # check that .depend files have no absolute path in them @@ -228,7 +228,7 @@ it was a release candidate. ``` cd $WORKTREE -make world.opt +make make install export PATH="$INSTDIR/bin:$PATH" cd manual