summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/hygiene.yml11
-rw-r--r--Changes3
-rw-r--r--Makefile7
-rw-r--r--Makefile.common24
-rw-r--r--Makefile.tools2
-rw-r--r--debugger/Makefile7
-rw-r--r--lex/Makefile10
-rw-r--r--ocamldoc/Makefile42
-rw-r--r--ocamltest/Makefile10
-rw-r--r--runtime/major_gc.c2
-rw-r--r--stdlib/int32.ml4
-rw-r--r--tools/Makefile5
-rwxr-xr-xtools/ci/actions/deepen-fetch.sh5
-rw-r--r--tools/ci/actions/runner.sh22
14 files changed, 74 insertions, 80 deletions
diff --git a/.github/workflows/hygiene.yml b/.github/workflows/hygiene.yml
index 43399e12b0..0253301d31 100644
--- a/.github/workflows/hygiene.yml
+++ b/.github/workflows/hygiene.yml
@@ -73,19 +73,20 @@ jobs:
run: tools/ci/actions/check-labelled-interfaces.sh
if: always()
- # If this step fails, it leaves behind the file compiler-failed-to-build
- # the presence of which can be felt by the last two steps, allowing them
- # to skip, rather than go beserk with a faulty compiler.
+ # This step records the build success in the variable build-status,
+ # allowing the last two steps to skip, rather than go beserk with a
+ # faulty compiler.
- name: Build a minimal compiler for alldepend
+ id: compiler
run: tools/ci/actions/runner.sh basic-compiler
if: always()
- name: Check that dependency info is up-to-date
run: tools/ci/actions/check-alldepend.sh
- if: hashFiles('compiler-failed-to-build') == '' && always()
+ if: steps.compiler.outputs.build-status == 'success' && always()
- name: Check global structure of the reference manual
run: |
# Required configuration info is left-over from the previous step
make -C manual/tests check-stdlib check-case-collision
- if: hashFiles('compiler-failed-to-build') == '' && always()
+ if: steps.compiler.outputs.build-status == 'success' && always()
diff --git a/Changes b/Changes
index 22c32f9fcd..1bb07e81d0 100644
--- a/Changes
+++ b/Changes
@@ -82,6 +82,9 @@ Working version
- #10228: Better code-generation for inlined comparisons
(Stephen Dolan, review by Alain Frisch and Xavier Leroy)
+- #10244: Optimise Int32.unsigned_to_int
+ (Fabian Hemmer, review by Stephen Dolan and Xavier Leroy)
+
### Standard library:
- #9533: Added String.starts_with and String.ends_with.
diff --git a/Makefile b/Makefile
index 02d6a32afa..360e109e4e 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ else
OCAML_NATDYNLINKOPTS = -ccopt "$(NATDYNLINKOPTS)"
endif
-CAMLLEX=$(CAMLRUN) boot/ocamllex
+OCAMLLEX ?= $(BOOT_OCAMLLEX)
CAMLDEP=$(CAMLRUN) boot/ocamlc -depend
DEPFLAGS=-slash
DEPINCLUDES=$(INCLUDES)
@@ -650,10 +650,7 @@ natruntop:
otherlibs/dynlink/dynlink.cmxa: otherlibs/dynlink/native/dynlink.ml
$(MAKE) -C otherlibs/dynlink allopt
-# The lexer
-
-parsing/lexer.ml: parsing/lexer.mll
- $(CAMLLEX) $(OCAMLLEX_FLAGS) $<
+# Cleanup the lexer
partialclean::
rm -f parsing/lexer.ml
diff --git a/Makefile.common b/Makefile.common
index f3e428a1ae..1e0486615f 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -66,8 +66,6 @@ OPTCOMPFLAGS=
ifeq "$(FUNCTION_SECTIONS)" "true"
OPTCOMPFLAGS += -function-sections
endif
-# By default, request ocamllex to be quiet
-OCAMLLEX_FLAGS ?= -q
# Escape special characters in the argument string.
# There are four characters that need escaping:
@@ -120,3 +118,25 @@ ifneq ($(EXE),)
$(1): $(1)$(EXE)
endif
endef # PROGRAM_SYNONYM
+
+# Lexer generation
+
+BOOT_OCAMLLEX ?= $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
+# The OCAMLLEX command used in the recipe below is defined in the individual
+# makefiles, because its default value is directory-specific.
+# By default, some directories use BOOT_OCAMLLEX while others use the
+# freshly compiled lexer generator.
+
+OCAMLLEXFLAGS ?= -q
+
+%.ml: %.mll
+ $(OCAMLLEX) $(OCAMLLEXFLAGS) $<
+
+# Parser generation
+
+OCAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)
+
+OCAMLYACCFLAGS ?=
+
+%.ml %.mli: %.mly
+ $(OCAMLYACC) $(OCAMLYACCFLAGS) $<
diff --git a/Makefile.tools b/Makefile.tools
index 9febde51a7..7c94a8bffc 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -94,7 +94,7 @@ OCAMLC=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlc$(EXE) \
OCAMLOPT=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlopt$(EXE) $(OCFLAGS) \
$(RUNTIME_VARIANT)
OCAMLDOC=$(OCAMLRUN) $(OTOPDIR)/ocamldoc/ocamldoc$(EXE)
-OCAMLLEX=$(OCAMLRUN) $(OTOPDIR)/lex/ocamllex$(EXE)
+OCAMLLEX ?= $(OCAMLRUN) $(OTOPDIR)/lex/ocamllex$(EXE)
OCAMLMKLIB=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/tools/ocamlmklib$(EXE) \
-ocamlc "$(OTOPDIR)/runtime/ocamlrun$(USE_RUNTIME)$(EXE) \
$(OTOPDIR)/ocamlc$(EXE) $(OCFLAGS) $(RUNTIME_VARIANT)" \
diff --git a/debugger/Makefile b/debugger/Makefile
index 4dda8fe6ba..50695f2b05 100644
--- a/debugger/Makefile
+++ b/debugger/Makefile
@@ -20,13 +20,12 @@ include $(ROOTDIR)/Makefile.best_binaries
DYNLINKDIR=$(ROOTDIR)/otherlibs/dynlink
UNIXDIR=$(ROOTDIR)/otherlibs/$(UNIXLIB)
-CAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)
CAMLC=$(BEST_OCAMLC) -g -nostdlib -I $(ROOTDIR)/stdlib
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -warn-error A \
-safe-string -strict-sequence -strict-formats
LINKFLAGS=-linkall -I $(UNIXDIR) -I $(DYNLINKDIR)
-CAMLLEX=$(BEST_OCAMLLEX)
+OCAMLLEX ?= $(BEST_OCAMLLEX)
CAMLDEP=$(BEST_OCAMLDEP)
DEPFLAGS=-slash
DEPINCLUDES=$(INCLUDES)
@@ -77,14 +76,10 @@ depend: beforedepend
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mli *.ml \
| sed -e 's,$(UNIXDIR)/,$$(UNIXDIR)/,' > .depend
-debugger_lexer.ml: debugger_lexer.mll
- $(CAMLLEX) $(OCAMLLEX_FLAGS) $<
clean::
rm -f debugger_lexer.ml
beforedepend:: debugger_lexer.ml
-debugger_parser.ml debugger_parser.mli: debugger_parser.mly
- $(CAMLYACC) debugger_parser.mly
clean::
rm -f debugger_parser.ml debugger_parser.mli
beforedepend:: debugger_parser.ml debugger_parser.mli
diff --git a/lex/Makefile b/lex/Makefile
index 9e0c675126..a510347a64 100644
--- a/lex/Makefile
+++ b/lex/Makefile
@@ -19,7 +19,7 @@ ROOTDIR = ..
include $(ROOTDIR)/Makefile.common
-CAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)
+OCAMLYACCFLAGS = -v
CAMLC = $(BOOT_OCAMLC) -strict-sequence -nostdlib \
-I $(ROOTDIR)/boot -use-prims $(ROOTDIR)/runtime/primitives
@@ -28,7 +28,7 @@ CAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt$(EXE) -nostdlib -I $(ROOTDIR)/stdlib \
COMPFLAGS = -absname -w +a-4-9-41-42-44-45-48 -warn-error A \
-safe-string -strict-sequence -strict-formats -bin-annot
LINKFLAGS =
-CAMLLEX = $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
+OCAMLLEX ?= $(BOOT_OCAMLLEX)
CAMLDEP = $(BOOT_OCAMLC) -depend
DEPFLAGS = -slash
DEPINCLUDES =
@@ -55,17 +55,11 @@ clean::
rm -f $(programs) $(programs:=.exe)
rm -f *.cmo *.cmi *.cmx *.cmt *.cmti *.o *.obj
-parser.ml parser.mli: parser.mly
- $(CAMLYACC) -v parser.mly
-
clean::
rm -f parser.ml parser.mli parser.output
beforedepend:: parser.ml parser.mli
-lexer.ml: lexer.mll
- $(CAMLLEX) $(OCAMLLEX_FLAGS) $<
-
clean::
rm -f lexer.ml
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index 70897e63c6..e209bedecd 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -18,14 +18,14 @@ ROOTDIR = ..
include $(ROOTDIR)/Makefile.common
include $(ROOTDIR)/Makefile.best_binaries
-OCAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)
+OCAMLYACCFLAGS = --strict -v
STDLIBFLAGS = -nostdlib -I $(ROOTDIR)/stdlib
OCAMLC = $(BEST_OCAMLC) $(STDLIBFLAGS)
OCAMLOPT = $(BEST_OCAMLOPT) $(STDLIBFLAGS) -I $(ROOTDIR)/runtime
OCAMLDEP = $(BEST_OCAMLDEP)
DEPFLAGS = -slash
-OCAMLLEX = $(BEST_OCAMLLEX)
+OCAMLLEX ?= $(BEST_OCAMLLEX)
# For installation
##############
@@ -194,27 +194,20 @@ dot: ocamldoc.dot
ocamldoc.dot: $(EXECMOFILES)
$(OCAMLDOC_RUN) -dot -dot-reduce -o $@ $(INCLUDES) odoc*.ml
-# Parsers and lexers dependencies :
-###################################
-odoc_text_parser.ml: odoc_text_parser.mly
-odoc_text_parser.mli: odoc_text_parser.mly
+# Lexers and parsers
-odoc_parser.ml: odoc_parser.mly
-odoc_parser.mli:odoc_parser.mly
+LEXERS = $(addsuffix .mll,\
+ odoc_text_lexer odoc_lexer odoc_ocamlhtml odoc_see_lexer)
-odoc_text_lexer.ml: odoc_text_lexer.mll
-
-odoc_lexer.ml:odoc_lexer.mll
-
-odoc_ocamlhtml.ml: odoc_ocamlhtml.mll
-
-odoc_see_lexer.ml: odoc_see_lexer.mll
+PARSERS = $(addsuffix .mly,odoc_parser odoc_text_parser)
+DEPEND_PREREQS = $(LEXERS:.mll=.ml) \
+ $(PARSERS:.mly=.mli) $(PARSERS:.mly=.ml)
# generic rules :
#################
-.SUFFIXES: .mll .mly .ml .mli .cmo .cmi .cmx .cmxs
+.SUFFIXES: .ml .mli .cmo .cmi .cmx .cmxs
.ml.cmo:
$(OCAMLC) $(COMPFLAGS) -c $<
@@ -228,15 +221,6 @@ odoc_see_lexer.ml: odoc_see_lexer.mll
.ml.cmxs:
$(OCAMLOPT_CMD) -shared -o $@ $(COMPFLAGS) $<
-.mll.ml:
- $(OCAMLLEX) $(OCAMLLEX_FLAGS) $<
-
-.mly.ml:
- $(OCAMLYACC) --strict -v $<
-
-.mly.mli:
- $(OCAMLYACC) --strict -v $<
-
# Installation targets
######################
@@ -406,13 +390,7 @@ clean:
generators/*.cmx[as]
.PHONY: depend
-depend:
- $(OCAMLYACC) odoc_text_parser.mly
- $(OCAMLYACC) odoc_parser.mly
- $(OCAMLLEX) $(OCAMLLEX_FLAGS) odoc_text_lexer.mll
- $(OCAMLLEX) $(OCAMLLEX_FLAGS) odoc_lexer.mll
- $(OCAMLLEX) $(OCAMLLEX_FLAGS) odoc_ocamlhtml.mll
- $(OCAMLLEX) $(OCAMLLEX_FLAGS) odoc_see_lexer.mll
+depend: $(DEPEND_PREREQS)
$(OCAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mll *.mly *.ml *.mli > .depend
$(OCAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -shared generators/*.ml >> .depend
diff --git a/ocamltest/Makefile b/ocamltest/Makefile
index 1eb8a47964..eb0f10ccc6 100644
--- a/ocamltest/Makefile
+++ b/ocamltest/Makefile
@@ -200,9 +200,7 @@ ocamldep := $(BEST_OCAMLDEP)
depflags := -slash
depincludes :=
-ocamllex := $(BEST_OCAMLLEX)
-
-ocamlyacc := $(ROOTDIR)/yacc/ocamlyacc$(EXE)
+OCAMLLEX ?= $(BEST_OCAMLLEX)
.SECONDARY: $(lexers:.mll=.ml) $(parsers:.mly=.mli) $(parsers:.mly=.ml)
@@ -238,12 +236,6 @@ ocamltest.opt$(EXE): $(deps_opt) $(native_modules)
%.cmi: %.mli $(deps_byte)
$(ocamlc) -c $<
-%.ml %.mli: %.mly
- $(ocamlyacc) $<
-
-%.ml: %.mll
- $(ocamllex) $(OCAMLLEX_FLAGS) $<
-
ocamltest_unix.ml: ocamltest_unix_$(ocamltest_unix).ml
echo '# 1 "$^"' > $@
cat $^ >> $@
diff --git a/runtime/major_gc.c b/runtime/major_gc.c
index e463fef2e0..cce192adb3 100644
--- a/runtime/major_gc.c
+++ b/runtime/major_gc.c
@@ -626,7 +626,7 @@ void caml_shrink_mark_stack () {
caml_gc_log ("Shrinking mark stack to %"
ARCH_INTNAT_PRINTF_FORMAT "uk bytes\n",
- init_stack_bsize);
+ init_stack_bsize / 1024);
shrunk_stack = (mark_entry*) caml_stat_resize_noexc ((char*) stk->stack,
init_stack_bsize);
diff --git a/stdlib/int32.ml b/stdlib/int32.ml
index e159851e5a..79864d6d3d 100644
--- a/stdlib/int32.ml
+++ b/stdlib/int32.ml
@@ -63,8 +63,8 @@ let unsigned_to_int =
None
| 64 ->
(* So that it compiles in 32-bit *)
- let move = int_of_string "0x1_0000_0000" in
- fun n -> let i = to_int n in Some (if i < 0 then i + move else i)
+ let mask = 0xFFFF lsl 16 lor 0xFFFF in
+ fun n -> Some (to_int n land mask)
| _ ->
assert false
diff --git a/tools/Makefile b/tools/Makefile
index eb746a9fd5..3af4c2a1e1 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -71,7 +71,7 @@ endef
CAMLC = $(BOOT_OCAMLC) -g -nostdlib -I $(ROOTDIR)/boot \
-use-prims $(ROOTDIR)/runtime/primitives -I $(ROOTDIR)
CAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt$(EXE) -g -nostdlib -I $(ROOTDIR)/stdlib
-CAMLLEX = $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
+OCAMLLEX ?= $(BOOT_OCAMLLEX)
INCLUDES = $(addprefix -I $(ROOTDIR)/,utils parsing typing bytecomp \
middle_end middle_end/closure middle_end/flambda \
middle_end/flambda/base_types driver toplevel \
@@ -331,9 +331,6 @@ clean::
# Common stuff
-%.ml: %.mll
- $(CAMLLEX) $(OCAMLLEX_FLAGS) $<
-
%.cmo: %.ml
$(CAMLC) -c $(COMPFLAGS) - $<
diff --git a/tools/ci/actions/deepen-fetch.sh b/tools/ci/actions/deepen-fetch.sh
index bf6dcec6e9..6cb8e291d7 100755
--- a/tools/ci/actions/deepen-fetch.sh
+++ b/tools/ci/actions/deepen-fetch.sh
@@ -41,7 +41,10 @@ else
shift 5
fi
-FETCH_HEAD=$(git rev-parse FETCH_HEAD)
+# Record FETCH_HEAD (if it hasn't been by a previous step)
+git branch fetch_head FETCH_HEAD &> /dev/null || true
+
+FETCH_HEAD=$(git rev-parse fetch_head)
UPSTREAM_BRANCH="$1"
UPSTREAM_HEAD="$2"
PR_BRANCH="$3"
diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh
index 32d9270de9..47727aa405 100644
--- a/tools/ci/actions/runner.sh
+++ b/tools/ci/actions/runner.sh
@@ -126,10 +126,23 @@ EOF
}
+# ReportBuildStatus accepts an exit code as a parameter (defaults to 1) and also
+# instructs GitHub Actions to set build-status to 'failed' on non-zero exit or
+# 'success' otherwise.
+ReportBuildStatus () {
+ CODE=${1:-1}
+ if ((CODE)); then
+ STATUS='failed'
+ else
+ STATUS='success'
+ fi
+ echo "::set-output name=build-status::$STATUS"
+ exit $CODE
+}
+
BasicCompiler () {
- # The presence of this file can be detected by later steps which
- # can choose to skip, rather than run (and presumably error).
- touch compiler-failed-to-build
+ trap ReportBuildStatus ERR
+
./configure --disable-dependency-generation \
--disable-debug-runtime \
--disable-instrumented-runtime
@@ -138,7 +151,8 @@ BasicCompiler () {
make -j coldstart
# And generated files (ocamllex compiles ocamlyacc)
make -j ocamllex
- rm -f compiler-failed-to-build
+
+ ReportBuildStatus 0
}
case $1 in