Skip to content

Commit

Permalink
Merge pull request #8537 from damiendoligez/runtime-variant-fixes
Browse files Browse the repository at this point in the history
fix the -runtime-variant option for bytecode

(cherry picked from commit 8153041)
  • Loading branch information
dra27 committed Jun 11, 2019
1 parent 405cff3 commit 617153c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -49,6 +49,9 @@ OCaml 4.09.0
- #3819, #8546 more explanations and tests for illegal permutation
(Florian Angeletti, review by Gabriel Scherer)

- #8537: fix the -runtime-variant option for bytecode
(Damien Doligez, review by David Allsopp)

- #8541: Correctly print multi-lines locations
(Louis Roché, review by Gabriel Scherer)

Expand Down
13 changes: 7 additions & 6 deletions Makefile
Expand Up @@ -496,11 +496,12 @@ flexdll: flexdll/Makefile flexlink
flexlink: flexdll/Makefile
$(MAKE) -C runtime BOOTSTRAPPING_FLEXLINK=yes ocamlrun$(EXE)
cp runtime/ocamlrun$(EXE) boot/ocamlrun$(EXE)
$(MAKE) -C stdlib COMPILER=../boot/ocamlc stdlib.cma std_exit.cmo
cd stdlib && cp stdlib.cma std_exit.cmo *.cmi ../boot
$(MAKE) -C stdlib COMPILER=../boot/ocamlc \
$(filter-out *.cmi,$(LIBFILES))
cd stdlib && cp $(LIBFILES) ../boot/
$(MAKE) -C flexdll MSVC_DETECT=0 OCAML_CONFIG_FILE=../Makefile.config \
CHAINS=$(FLEXDLL_CHAIN) NATDYNLINK=false \
OCAMLOPT="../boot/ocamlrun ../boot/ocamlc -I ../boot" \
OCAMLOPT="../boot/ocamlrun ../boot/ocamlc -nostdlib -I ../boot" \
flexlink.exe
$(MAKE) -C runtime clean
$(MAKE) partialclean
Expand All @@ -511,7 +512,8 @@ flexlink.opt:
mv flexlink.exe flexlink && \
($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun ./flexlink" MSVC_DETECT=0 \
OCAML_CONFIG_FILE=../Makefile.config \
OCAMLOPT="../ocamlopt.opt -I ../stdlib" flexlink.exe || \
OCAMLOPT="../ocamlopt.opt -nostdlib -I ../stdlib" \
flexlink.exe || \
(mv flexlink flexlink.exe && false)) && \
mv flexlink.exe flexlink.opt && \
mv flexlink flexlink.exe
Expand All @@ -521,8 +523,7 @@ INSTALL_FLEXDLLDIR=$(INSTALL_LIBDIR)/flexdll

.PHONY: install-flexdll
install-flexdll:
cat stdlib/camlheader flexdll/flexlink.exe > \
"$(INSTALL_BINDIR)/flexlink.exe"
$(INSTALL_PROG) flexdll/flexlink.exe "$(INSTALL_BINDIR)/flexlink$(EXE)"
ifneq "$(filter-out mingw,$(TOOLCHAIN))" ""
$(INSTALL_DATA) flexdll/default$(filter-out _i386,_$(ARCH)).manifest \
"$(INSTALL_BINDIR)/"
Expand Down
15 changes: 10 additions & 5 deletions bytecomp/bytelink.ml
Expand Up @@ -29,6 +29,7 @@ type error =
| File_exists of filepath
| Cannot_open_dll of filepath
| Required_module_unavailable of modname
| Camlheader of string * filepath

exception Error of error

Expand Down Expand Up @@ -312,15 +313,17 @@ let link_bytecode ?final_name tolink exec_name standalone =
(fun () ->
if standalone then begin
(* Copy the header *)
let header =
if String.length !Clflags.use_runtime > 0
then "camlheader_ur" else "camlheader" ^ !Clflags.runtime_variant
in
try
let header =
if String.length !Clflags.use_runtime > 0
then "camlheader_ur" else "camlheader" ^ !Clflags.runtime_variant
in
let inchan = open_in_bin (Load_path.find header) in
copy_file inchan outchan;
close_in inchan
with Not_found | Sys_error _ -> ()
with
| Not_found -> raise (Error (File_not_found header))
| Sys_error msg -> raise (Error (Camlheader (header, msg)))
end;
Bytesections.init_record outchan;
(* The path to the bytecode interpreter (in use_runtime mode) *)
Expand Down Expand Up @@ -696,6 +699,8 @@ let report_error ppf = function
Location.print_filename file
| Required_module_unavailable s ->
fprintf ppf "Required module `%s' is unavailable" s
| Camlheader (msg, header) ->
fprintf ppf "System error while copying file %s: %s" header msg

let () =
Location.register_error_of_exn
Expand Down
1 change: 1 addition & 0 deletions bytecomp/bytelink.mli
Expand Up @@ -34,6 +34,7 @@ type error =
| File_exists of filepath
| Cannot_open_dll of filepath
| Required_module_unavailable of modname
| Camlheader of string * filepath

exception Error of error

Expand Down
4 changes: 2 additions & 2 deletions stdlib/Makefile
Expand Up @@ -101,12 +101,12 @@ endif

ifeq "$(RUNTIMED)" "true"
install::
$(INSTALL_DATA) target_camlheaderd "$(INSTALL_LIBDIR)"
$(INSTALL_DATA) target_camlheaderd "$(INSTALL_LIBDIR)/camlheaderd"
endif

ifeq "$(RUNTIMEI)" "true"
install::
$(INSTALL_DATA) target_camlheaderi "$(INSTALL_LIBDIR)"
$(INSTALL_DATA) target_camlheaderi "$(INSTALL_LIBDIR)/camlheaderi"
endif

.PHONY: installopt
Expand Down

0 comments on commit 617153c

Please sign in to comment.