summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2021-11-20 12:19:28 +0000
committerDavid Allsopp <david.allsopp@metastack.com>2022-05-05 21:01:11 +0100
commit8722ccd2a1096db3ae415d90c464bd8b254880db (patch)
tree7fd5b27836f830dfd08f68144ebae409eb1ecd14
parentda78cf8698c4c6c60c267ff2030e45554e71e60c (diff)
downloadocaml-8722ccd2a1096db3ae415d90c464bd8b254880db.tar.gz
Use fixed configuration for boot/ocamlc
Use the same configuration for boot/ocamlc regardless of the machine on which the bootstrap is performed. Now set Config.in_boot_compiler to true for boot/ocamlc.
-rw-r--r--.depend14
-rw-r--r--.gitignore1
-rw-r--r--Makefile23
-rw-r--r--Makefile.common2
-rw-r--r--compilerlibs/Makefile.compilerlibs8
-rw-r--r--utils/Makefile12
-rw-r--r--utils/config.common.ml162
-rw-r--r--utils/config.fixed.ml71
-rw-r--r--utils/config.mlp148
9 files changed, 285 insertions, 156 deletions
diff --git a/.depend b/.depend
index 6fdf87ceca..79d4c29b02 100644
--- a/.depend
+++ b/.depend
@@ -45,11 +45,25 @@ utils/clflags.cmx : \
utils/clflags.cmi : \
utils/profile.cmi \
utils/misc.cmi
+utils/config.common.cmo :
+utils/config.common.cmx :
+utils/config.fixed.cmo :
+utils/config.fixed.cmx :
utils/config.cmo : \
utils/config.cmi
utils/config.cmx : \
utils/config.cmi
utils/config.cmi :
+utils/config_boot.cmo : \
+ utils/config_boot.cmi
+utils/config_boot.cmx : \
+ utils/config_boot.cmi
+utils/config_boot.cmi :
+utils/config_main.cmo : \
+ utils/config_main.cmi
+utils/config_main.cmx : \
+ utils/config_main.cmi
+utils/config_main.cmi :
utils/consistbl.cmo : \
utils/misc.cmi \
utils/consistbl.cmi
diff --git a/.gitignore b/.gitignore
index de7472e741..c34c9daf05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -244,6 +244,7 @@ _build
/toplevel/native/trace.mli
/toplevel/native/topmain.mli
+/utils/config_*.ml*
/utils/config.ml
/utils/domainstate.ml
/utils/domainstate.mli
diff --git a/Makefile b/Makefile
index 25859059c7..46cb8f739d 100644
--- a/Makefile
+++ b/Makefile
@@ -97,9 +97,18 @@ include compilerlibs/Makefile.compilerlibs
# The configuration file
-utils/config.ml: utils/config.mlp Makefile.config utils/Makefile
+CONFIG_MODULE_DEPENDENCIES = \
+ utils/config.common.ml Makefile.config utils/Makefile
+
+utils/config.ml: utils/config_main.ml utils/config_boot.ml
$(MAKE) -C utils config.ml
+utils/config_main.ml: utils/config.mlp $(CONFIG_MODULE_DEPENDENCIES)
+ $(MAKE) -C utils config_main.ml
+
+utils/config_boot.ml: utils/config.fixed.ml $(CONFIG_MODULE_DEPENDENCIES)
+ $(MAKE) -C utils config_boot.ml
+
.PHONY: reconfigure
reconfigure:
ac_read_git_config=true ./configure $(CONFIGURE_ARGS)
@@ -115,7 +124,9 @@ configure: configure.ac aclocal.m4 build-aux/ocaml_version.m4 tools/autogen
.PHONY: partialclean
partialclean::
- rm -f utils/config.ml utils/domainstate.ml utils/domainstate.mli
+ rm -f utils/config.ml utils/config_main.ml utils/config_main.mli \
+ utils/config_boot.ml utils/config_boot.mli \
+ utils/domainstate.ml utils/domainstate.mli
.PHONY: beforedepend
beforedepend:: utils/config.ml utils/domainstate.ml utils/domainstate.mli
@@ -268,15 +279,17 @@ coreboot:
# runtime/ocamlrun
$(MAKE) promote-cross
# Rebuild ocamlc and ocamllex (run on runtime/ocamlrun)
+# utils/config.ml will have the fixed bootstrap configuration
$(MAKE) partialclean
- $(MAKE) ocamlc ocamllex ocamltools
+ $(MAKE) IN_COREBOOT_CYCLE=true ocamlc ocamllex ocamltools
# Rebuild the library (using runtime/ocamlrun ./ocamlc)
$(MAKE) library-cross
# Promote the new compiler and the new runtime
$(MAKE) OCAMLRUN=runtime/ocamlrun$(EXE) promote
# Rebuild the core system
+# utils/config.ml must still have the fixed bootstrap configuration
$(MAKE) partialclean
- $(MAKE) core
+ $(MAKE) IN_COREBOOT_CYCLE=true core
# Check if fixpoint reached
$(MAKE) compare
else
@@ -301,6 +314,8 @@ endif
# Never mind, just do make bootstrap to reach fixpoint again.
.PHONY: bootstrap
bootstrap: coreboot
+# utils/config.ml must be restored to config.status's configuration
+ rm -f utils/config.ml
$(MAKE) all
# Compile everything the first time
diff --git a/Makefile.common b/Makefile.common
index 61fb3e9f18..89f3e5795c 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -39,6 +39,8 @@ INSTALL_DOCDIR := $(DESTDIR)$(DOCDIR)
FLEXDLL_SUBMODULE_PRESENT := $(wildcard $(ROOTDIR)/flexdll/Makefile)
+IN_COREBOOT_CYCLE ?= false
+
# Variables used to represent the OCaml runtime system
# Most of the time, boot/ocamlrun and runtime/ocamlrun are the same.
# However, under some circumstances it is important to be able to
diff --git a/compilerlibs/Makefile.compilerlibs b/compilerlibs/Makefile.compilerlibs
index f6618999fc..4eb49ca60d 100644
--- a/compilerlibs/Makefile.compilerlibs
+++ b/compilerlibs/Makefile.compilerlibs
@@ -406,8 +406,14 @@ partialclean::
$(COMMON:.cmo=.cmx) $(BYTECOMP:.cmo=.cmx) $(OPTCOMP:.cmo=.cmx): ocamlopt$(EXE)
$(OPTTOPLEVEL:.cmo=.cmx): ocamlopt$(EXE)
+ALL_CONFIG_CMO = utils/config_main.cmo utils/config_boot.cmo
-compilerlibs/ocamlcommon.cma: $(COMMON_CMI) $(COMMON)
+utils/config_%.mli: utils/config.mli
+ cp $^ $@
+
+beforedepend:: utils/config_main.mli utils/config_boot.mli
+
+compilerlibs/ocamlcommon.cma: $(COMMON_CMI) $(ALL_CONFIG_CMO) $(COMMON)
$(CAMLC) -a -linkall -o $@ $(COMMON)
partialclean::
rm -f compilerlibs/ocamlcommon.cma
diff --git a/utils/Makefile b/utils/Makefile
index 7ccc9cf413..9c26fddba1 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -37,9 +37,7 @@ SUBST_QUOTE=$(call SUBST_QUOTE2,$1,$($1))
FLEXLINK_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
FLEXLINK_DLL_LDFLAGS=$(if $(OC_DLL_LDFLAGS), -link "$(OC_DLL_LDFLAGS)")
-IN_COREBOOT_CYCLE?=false
-
-config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile
+config_main.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile config.common.ml
sed $(call SUBST,AFL_INSTRUMENT) \
$(call SUBST,ARCH) \
$(call SUBST_STRING,ARCMD) \
@@ -89,8 +87,14 @@ config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile
$(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \
$(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \
$(call SUBST,FORCE_INSTRUMENTED_RUNTIME) \
- $(call SUBST,IN_COREBOOT_CYCLE) \
$< > $@
+ cat config.common.ml >> $@
+
+config_boot.ml: config.fixed.ml config.common.ml Makefile
+ cat config.fixed.ml config.common.ml > $@
+
+config.ml: config_$(if $(filter true,$(IN_COREBOOT_CYCLE)),boot,main).ml
+ cp $^ $@
# Test for the substitution functions above
diff --git a/utils/config.common.ml b/utils/config.common.ml
new file mode 100644
index 0000000000..13eb6392b8
--- /dev/null
+++ b/utils/config.common.ml
@@ -0,0 +1,162 @@
+#2 "utils/config.common.ml"
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 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. *)
+(* *)
+(**************************************************************************)
+
+(* Portions of the Config module common to both the boot and main compiler. *)
+
+(* The main OCaml version string has moved to ../build-aux/ocaml_version.m4 *)
+let version = Sys.ocaml_version
+
+let standard_library =
+ try
+ Sys.getenv "OCAMLLIB"
+ with Not_found ->
+ try
+ Sys.getenv "CAMLLIB"
+ with Not_found ->
+ standard_library_default
+
+let exec_magic_number = "Caml1999X031"
+ (* exec_magic_number is duplicated in runtime/caml/exec.h *)
+and cmi_magic_number = "Caml1999I031"
+and cmo_magic_number = "Caml1999O031"
+and cma_magic_number = "Caml1999A031"
+and cmx_magic_number =
+ if flambda then
+ "Caml1999y031"
+ else
+ "Caml1999Y031"
+and cmxa_magic_number =
+ if flambda then
+ "Caml1999z031"
+ else
+ "Caml1999Z031"
+and ast_impl_magic_number = "Caml1999M031"
+and ast_intf_magic_number = "Caml1999N031"
+and cmxs_magic_number = "Caml1999D031"
+and cmt_magic_number = "Caml1999T031"
+and linear_magic_number = "Caml1999L031"
+
+let safe_string = true
+let default_safe_string = true
+let naked_pointers = false
+
+let interface_suffix = ref ".mli"
+
+let max_tag = 243
+(* This is normally the same as in obj.ml, but we have to define it
+ separately because it can differ when we're in the middle of a
+ bootstrapping phase. *)
+let lazy_tag = 246
+
+let max_young_wosize = 256
+let stack_threshold = 32 (* see runtime/caml/config.h *)
+let stack_safety_margin = 6
+let default_executable_name =
+ match Sys.os_type with
+ "Unix" -> "a.out"
+ | "Win32" | "Cygwin" -> "camlprog.exe"
+ | _ -> "camlprog"
+type configuration_value =
+ | String of string
+ | Int of int
+ | Bool of bool
+
+let configuration_variables =
+ let p x v = (x, String v) in
+ let p_int x v = (x, Int v) in
+ let p_bool x v = (x, Bool v) in
+[
+ p "version" version;
+ p "standard_library_default" standard_library_default;
+ p "standard_library" standard_library;
+ p "ccomp_type" ccomp_type;
+ p "c_compiler" c_compiler;
+ p "ocamlc_cflags" ocamlc_cflags;
+ p "ocamlc_cppflags" ocamlc_cppflags;
+ p "ocamlopt_cflags" ocamlopt_cflags;
+ p "ocamlopt_cppflags" ocamlopt_cppflags;
+ p "bytecomp_c_compiler" bytecomp_c_compiler;
+ p "native_c_compiler" native_c_compiler;
+ p "bytecomp_c_libraries" bytecomp_c_libraries;
+ p "native_c_libraries" native_c_libraries;
+ p "native_pack_linker" native_pack_linker;
+ p "architecture" architecture;
+ p "model" model;
+ p_int "int_size" Sys.int_size;
+ p_int "word_size" Sys.word_size;
+ p "system" system;
+ p "asm" asm;
+ p_bool "asm_cfi_supported" asm_cfi_supported;
+ p_bool "with_frame_pointers" with_frame_pointers;
+ p "ext_exe" ext_exe;
+ p "ext_obj" ext_obj;
+ p "ext_asm" ext_asm;
+ p "ext_lib" ext_lib;
+ p "ext_dll" ext_dll;
+ p "os_type" Sys.os_type;
+ p "default_executable_name" default_executable_name;
+ p_bool "systhread_supported" systhread_supported;
+ p "host" host;
+ p "target" target;
+ p_bool "flambda" flambda;
+ p_bool "safe_string" safe_string;
+ p_bool "default_safe_string" default_safe_string;
+ p_bool "flat_float_array" flat_float_array;
+ p_bool "function_sections" function_sections;
+ p_bool "afl_instrument" afl_instrument;
+ p_bool "windows_unicode" windows_unicode;
+ p_bool "supports_shared_libraries" supports_shared_libraries;
+ p_bool "naked_pointers" naked_pointers;
+
+ p "exec_magic_number" exec_magic_number;
+ p "cmi_magic_number" cmi_magic_number;
+ p "cmo_magic_number" cmo_magic_number;
+ p "cma_magic_number" cma_magic_number;
+ p "cmx_magic_number" cmx_magic_number;
+ p "cmxa_magic_number" cmxa_magic_number;
+ p "ast_impl_magic_number" ast_impl_magic_number;
+ p "ast_intf_magic_number" ast_intf_magic_number;
+ p "cmxs_magic_number" cmxs_magic_number;
+ p "cmt_magic_number" cmt_magic_number;
+ p "linear_magic_number" linear_magic_number;
+]
+
+let print_config_value oc = function
+ | String s ->
+ Printf.fprintf oc "%s" s
+ | Int n ->
+ Printf.fprintf oc "%d" n
+ | Bool p ->
+ Printf.fprintf oc "%B" p
+
+let print_config oc =
+ let print (x, v) =
+ Printf.fprintf oc "%s: %a\n" x print_config_value v in
+ List.iter print configuration_variables;
+ flush oc
+
+let config_var x =
+ match List.assoc_opt x configuration_variables with
+ | None -> None
+ | Some v ->
+ let s = match v with
+ | String s -> s
+ | Int n -> Int.to_string n
+ | Bool b -> string_of_bool b
+ in
+ Some s
+
+let merlin = false
diff --git a/utils/config.fixed.ml b/utils/config.fixed.ml
new file mode 100644
index 0000000000..fce7c4621a
--- /dev/null
+++ b/utils/config.fixed.ml
@@ -0,0 +1,71 @@
+#2 "utils/config.fixed.ml"
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* David Allsopp, Tarides UK. *)
+(* *)
+(* Copyright 2022 David Allsopp Ltd. *)
+(* *)
+(* 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. *)
+(* *)
+(**************************************************************************)
+
+(* Configuration for the boot compiler. The compiler should refuse to bootstrap
+ if configured with values which would contradict the configuration below.
+ Config.in_boot_compiler is used throughout the compiler to prevent accidental
+ use of "<boot compiler>" values, but should not be used to control
+ compilation decisions (i.e. if Config.in_boot_compiler is found to be true,
+ the result of the code path should be a fatal error) *)
+
+let bindir = "<boot compiler>"
+let standard_library_default = "<boot compiler>"
+let in_boot_compiler = true
+let ccomp_type = "<boot compiler>"
+let c_compiler = "<boot compiler>"
+let c_output_obj = "<boot compiler>"
+let c_has_debug_prefix_map = false
+let as_has_debug_prefix_map = false
+let ocamlc_cflags = "<boot compiler>"
+let ocamlc_cppflags = "<boot compiler>"
+let ocamlopt_cflags = "<boot compiler>"
+let ocamlopt_cppflags = "<boot compiler>"
+let bytecomp_c_libraries = "<boot compiler>"
+let bytecomp_c_compiler = "<boot compiler>"
+let native_c_compiler = "<boot compiler>"
+let native_c_libraries = "<boot compiler>"
+let native_pack_linker = "<boot compiler>"
+let default_rpath = "<boot compiler>"
+let mksharedlibrpath = "<boot compiler>"
+let ar = "<boot compiler>"
+let supports_shared_libraries = false
+let mkdll = "<boot compiler>"
+let mkexe = "<boot compiler>"
+let mkmaindll = "<boot compiler>"
+let flambda = false
+let with_flambda_invariants = false
+let with_cmm_invariants = false
+let windows_unicode = false
+let force_instrumented_runtime = false
+let flat_float_array = true
+let function_sections = false
+let afl_instrument = false
+let architecture = "none"
+let model = "default"
+let system = "unknown"
+let asm = "<boot compiler>"
+let asm_cfi_supported = false
+let with_frame_pointers = false
+let profinfo = false
+let profinfo_width = 0
+let ext_exe = "<boot compiler>"
+let ext_obj = "<boot compiler>"
+let ext_asm = "<boot compiler>"
+let ext_lib = "<boot compiler>"
+let ext_dll = "<boot compiler>"
+let host = "<boot compiler>"
+let target = "<boot compiler>"
+let systhread_supported = false
+let flexdll_dirs = []
diff --git a/utils/config.mlp b/utils/config.mlp
index 92261b6321..fd25cec69b 100644
--- a/utils/config.mlp
+++ b/utils/config.mlp
@@ -14,23 +14,11 @@
(* *)
(**************************************************************************)
-(* The main OCaml version string has moved to ../build-aux/ocaml_version.m4 *)
-let version = Sys.ocaml_version
-
let bindir = "%%BINDIR%%"
let standard_library_default = "%%LIBDIR%%"
-let standard_library =
- try
- Sys.getenv "OCAMLLIB"
- with Not_found ->
- try
- Sys.getenv "CAMLLIB"
- with Not_found ->
- standard_library_default
-
-let in_boot_compiler = %%IN_COREBOOT_CYCLE%%
+let in_boot_compiler = false
let ccomp_type = "%%CCOMPTYPE%%"
let c_compiler = "%%CC%%"
@@ -82,10 +70,7 @@ let mkdll, mkexe, mkmaindll =
let flambda = %%FLAMBDA%%
let with_flambda_invariants = %%WITH_FLAMBDA_INVARIANTS%%
let with_cmm_invariants = %%WITH_CMM_INVARIANTS%%
-let safe_string = true
-let default_safe_string = true
let windows_unicode = %%WINDOWS_UNICODE%% != 0
-let naked_pointers = false
let force_instrumented_runtime = %%FORCE_INSTRUMENTED_RUNTIME%%
let flat_float_array = %%FLAT_FLOAT_ARRAY%%
@@ -93,39 +78,6 @@ let flat_float_array = %%FLAT_FLOAT_ARRAY%%
let function_sections = %%FUNCTION_SECTIONS%%
let afl_instrument = %%AFL_INSTRUMENT%%
-let exec_magic_number = "Caml1999X031"
- (* exec_magic_number is duplicated in runtime/caml/exec.h *)
-and cmi_magic_number = "Caml1999I031"
-and cmo_magic_number = "Caml1999O031"
-and cma_magic_number = "Caml1999A031"
-and cmx_magic_number =
- if flambda then
- "Caml1999y031"
- else
- "Caml1999Y031"
-and cmxa_magic_number =
- if flambda then
- "Caml1999z031"
- else
- "Caml1999Z031"
-and ast_impl_magic_number = "Caml1999M031"
-and ast_intf_magic_number = "Caml1999N031"
-and cmxs_magic_number = "Caml1999D031"
-and cmt_magic_number = "Caml1999T031"
-and linear_magic_number = "Caml1999L031"
-
-let interface_suffix = ref ".mli"
-
-let max_tag = 243
-(* This is normally the same as in obj.ml, but we have to define it
- separately because it can differ when we're in the middle of a
- bootstrapping phase. *)
-let lazy_tag = 246
-
-let max_young_wosize = 256
-let stack_threshold = 32 (* see runtime/caml/config.h *)
-let stack_safety_margin = 6
-
let architecture = "%%ARCH%%"
let model = "%%MODEL%%"
let system = "%%SYSTEM%%"
@@ -145,104 +97,6 @@ let ext_dll = "%%EXT_DLL%%"
let host = "%%HOST%%"
let target = "%%TARGET%%"
-let default_executable_name =
- match Sys.os_type with
- "Unix" -> "a.out"
- | "Win32" | "Cygwin" -> "camlprog.exe"
- | _ -> "camlprog"
-
let systhread_supported = %%SYSTHREAD_SUPPORT%%
let flexdll_dirs = [%%FLEXDLL_DIR%%]
-
-type configuration_value =
- | String of string
- | Int of int
- | Bool of bool
-
-let configuration_variables =
- let p x v = (x, String v) in
- let p_int x v = (x, Int v) in
- let p_bool x v = (x, Bool v) in
-[
- p "version" version;
- p "standard_library_default" standard_library_default;
- p "standard_library" standard_library;
- p "ccomp_type" ccomp_type;
- p "c_compiler" c_compiler;
- p "ocamlc_cflags" ocamlc_cflags;
- p "ocamlc_cppflags" ocamlc_cppflags;
- p "ocamlopt_cflags" ocamlopt_cflags;
- p "ocamlopt_cppflags" ocamlopt_cppflags;
- p "bytecomp_c_compiler" bytecomp_c_compiler;
- p "native_c_compiler" native_c_compiler;
- p "bytecomp_c_libraries" bytecomp_c_libraries;
- p "native_c_libraries" native_c_libraries;
- p "native_pack_linker" native_pack_linker;
- p "architecture" architecture;
- p "model" model;
- p_int "int_size" Sys.int_size;
- p_int "word_size" Sys.word_size;
- p "system" system;
- p "asm" asm;
- p_bool "asm_cfi_supported" asm_cfi_supported;
- p_bool "with_frame_pointers" with_frame_pointers;
- p "ext_exe" ext_exe;
- p "ext_obj" ext_obj;
- p "ext_asm" ext_asm;
- p "ext_lib" ext_lib;
- p "ext_dll" ext_dll;
- p "os_type" Sys.os_type;
- p "default_executable_name" default_executable_name;
- p_bool "systhread_supported" systhread_supported;
- p "host" host;
- p "target" target;
- p_bool "flambda" flambda;
- p_bool "safe_string" safe_string;
- p_bool "default_safe_string" default_safe_string;
- p_bool "flat_float_array" flat_float_array;
- p_bool "function_sections" function_sections;
- p_bool "afl_instrument" afl_instrument;
- p_bool "windows_unicode" windows_unicode;
- p_bool "supports_shared_libraries" supports_shared_libraries;
- p_bool "naked_pointers" naked_pointers;
-
- p "exec_magic_number" exec_magic_number;
- p "cmi_magic_number" cmi_magic_number;
- p "cmo_magic_number" cmo_magic_number;
- p "cma_magic_number" cma_magic_number;
- p "cmx_magic_number" cmx_magic_number;
- p "cmxa_magic_number" cmxa_magic_number;
- p "ast_impl_magic_number" ast_impl_magic_number;
- p "ast_intf_magic_number" ast_intf_magic_number;
- p "cmxs_magic_number" cmxs_magic_number;
- p "cmt_magic_number" cmt_magic_number;
- p "linear_magic_number" linear_magic_number;
-]
-
-let print_config_value oc = function
- | String s ->
- Printf.fprintf oc "%s" s
- | Int n ->
- Printf.fprintf oc "%d" n
- | Bool p ->
- Printf.fprintf oc "%B" p
-
-let print_config oc =
- let print (x, v) =
- Printf.fprintf oc "%s: %a\n" x print_config_value v in
- List.iter print configuration_variables;
- flush oc
-
-let config_var x =
- match List.assoc_opt x configuration_variables with
- | None -> None
- | Some v ->
- let s = match v with
- | String s -> s
- | Int n -> Int.to_string n
- | Bool b -> string_of_bool b
- in
- Some s
-
-let merlin = false