[OCaml] PR9719, PR14727: Make tests run without ocamlopt.
authorPeter Zotov <whitequark@whitequark.org>
Tue, 28 Oct 2014 22:39:36 +0000 (22:39 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Tue, 28 Oct 2014 22:39:36 +0000 (22:39 +0000)
Previously, tests hardcoded ocamlopt and cmxa, which broke builds on
machines without ocamlopt. Instead, they now fall back to ocamlc.

As a side effect this fixes PR14727, which was caused by a crude hack
that replaced gcc with g++ everywhere in the ocamlopt native compiler
path and passes it back using -cc. Now the tests use the same
technique as META, i.e. -cclib -lstdc++. It might be more fragile
than using g++ explicitly, but it will break when the installed
package will also break, which is good.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220828 91177308-0d34-0410-b5e6-96231b3b80d8

16 files changed:
test/Bindings/Ocaml/analysis.ml
test/Bindings/Ocaml/bitreader.ml
test/Bindings/Ocaml/bitwriter.ml
test/Bindings/Ocaml/executionengine.ml
test/Bindings/Ocaml/ext_exc.ml
test/Bindings/Ocaml/ipo_opts.ml
test/Bindings/Ocaml/irreader.ml
test/Bindings/Ocaml/linker.ml
test/Bindings/Ocaml/passmgr_builder.ml
test/Bindings/Ocaml/scalar_opts.ml
test/Bindings/Ocaml/target.ml
test/Bindings/Ocaml/vectorize_opts.ml
test/Bindings/Ocaml/vmcore.ml
test/Makefile
test/lit.cfg
test/lit.site.cfg.in

index c02645c0bce3ce9b0cb4a9f6df9d4a7251b6a0a2..fe71f6898dd81af577e99d0813830f830eb505a4 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_analysis.cmxa %t.builddir/analysis.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_analysis.%cma %t.builddir/analysis.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
index f1d202ab0490dee6119eeeebdc8985fcdd785eaf..f219550f92fe5c9c5046f18f796cfbd4431b4a62 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_bitreader.cmxa llvm_bitwriter.cmxa %t.builddir/bitreader.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_bitreader.%cma llvm_bitwriter.%cma %t.builddir/bitreader.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
index d4d0417a80e30e9965fb99cf41923d3011e88dc9..ece9a393325212db378836e59cd019ebeb296b1f 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A-3 unix.cmxa llvm.cmxa llvm_bitwriter.cmxa %t.builddir/bitwriter.ml -o %t
+ * RUN: %ocamlcomp -warn-error A-3 unix.%cma llvm.%cma llvm_bitwriter.%cma %t.builddir/bitwriter.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
index 3109081a71edfbcd31dbad2ef1f8f9e02f42a1f8..fa325ebc1df4c3d14f5369622a10c995a96fd2ec 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa llvm_executionengine.cmxa %t.builddir/executionengine.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_target.%cma llvm_executionengine.%cma %t.builddir/executionengine.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak hexagon
  *)
index 9afc3c3ab4b243ef724f0a1395b4135493aee19c..80924387110b06733c591848f8c8be7506a9bca9 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_bitreader.cmxa llvm_executionengine.cmxa %t.builddir/ext_exc.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_bitreader.%cma llvm_executionengine.%cma %t.builddir/ext_exc.ml -o %t
  * RUN: %t </dev/null
  * XFAIL: vg_leak
  *)
index e0bcbe5f561e445650215459e4e814dfa2d12190..50fc303a358470df0d20adbb11cf0845f80936a8 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_ipo.cmxa llvm_target.cmxa %t.builddir/ipo_opts.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_ipo.%cma llvm_target.%cma %t.builddir/ipo_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
index 3511c2b23646113fb0efdc42569dbd2f730faf4c..efe9df6d59301979b7e6ecd3a8ac7387309c9d5a 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -g -warn-error A llvm.cmxa llvm_irreader.cmxa %t.builddir/irreader.ml -o %t
+ * RUN: %ocamlcomp -g -warn-error A llvm.%cma llvm_irreader.%cma %t.builddir/irreader.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
index 9359ae9f2c48893011c5484307b992f27f0072f4..c187afa49afe6f66a31f3f4641c279953fb3f4f1 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_linker.cmxa %t.builddir/linker.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_linker.%cma %t.builddir/linker.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
index 1a3102f70a345fa54c886cd3f148131083211171..cd431fa5580c859fd46faeaff53ab283ea03063d 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_passmgr_builder.cmxa %t.builddir/passmgr_builder.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_passmgr_builder.%cma %t.builddir/passmgr_builder.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
index 39913e43119d25de3be98008eb0c5e6be0783714..a4bc47f713785aa2ca66b8108e49bc4258e914de 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_scalar_opts.cmxa llvm_target.cmxa %t.builddir/scalar_opts.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_scalar_opts.%cma llvm_target.%cma %t.builddir/scalar_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
index 0a2283aa3ed5961679697420f6bf5a0d17a2ba62..35135880e29fee440b62634590f2f467a50b75cd 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -g -warn-error A llvm.cmxa llvm_target.cmxa llvm_executionengine.cmxa %t.builddir/target.ml -o %t
+ * RUN: %ocamlcomp -g -warn-error A llvm.%cma llvm_target.%cma llvm_executionengine.%cma %t.builddir/target.ml -o %t
  * RUN: %t %t.bc
  * REQUIRES: native, object-emission
  * XFAIL: vg_leak
index 5ef985d5dc18a39808655245128f00fa12820bbc..05bbfe227f63a6f79405d75d24d7e6fc717c1555 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_vectorize.cmxa llvm_target.cmxa %t.builddir/vectorize_opts.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_vectorize.%cma llvm_target.%cma %t.builddir/vectorize_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
index dcfeaea1e023f3c5026331bdf3de2adf21a63c04..a75f298ca2d78b28157fea199461bba3cdc2a9f3 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A llvm.cmxa llvm_analysis.cmxa llvm_bitwriter.cmxa %t.builddir/vmcore.ml -o %t
+ * RUN: %ocamlcomp -warn-error A llvm.%cma llvm_analysis.%cma llvm_bitwriter.%cma %t.builddir/vmcore.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc > %t.ll
  * RUN: FileCheck %s < %t.ll
index 156009d026c1a8f759ed1284a3b57214620b15b9..00626695bc1cee18712c7f9220371a05513fbf05 100644 (file)
@@ -108,11 +108,6 @@ check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-site-cfgs
 clean::
        $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
 
-ifneq ($(OCAMLOPT),)
-CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
-CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT))
-endif
-
 FORCE:
 
 ifeq ($(DISABLE_ASSERTIONS),1)
@@ -132,7 +127,9 @@ lit.site.cfg: FORCE
        @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp
        @$(ECHOPATH) s=@EXEEXT@=$(EXEEXT)=g >> lit.tmp
        @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp
-       @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc $(subst *,'\\\"',*$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))*) -cclib -L$(LibDir) -I $(LibDir)/ocaml=g >> lit.tmp
+       @$(ECHOPATH) s=@OCAMLC@=$(OCAMLC)=g >> lit.tmp
+       @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT)=g >> lit.tmp
+       @$(ECHOPATH) s=@OCAMLFLAGS@=-cclib -lstdc++ -cclib -L$(LibDir) -I $(LibDir)/ocaml=g >> lit.tmp
        @$(ECHOPATH) s=@GO_EXECUTABLE@=$(GO)=g >> lit.tmp
        @$(ECHOPATH) s!@HOST_CC@!$(CC)!g >> lit.tmp
        @$(ECHOPATH) s!@HOST_CXX@!$(CXX)!g >> lit.tmp
index 55f559e68dc7f2b379705238e09a12fa7270219d..63880d0dac78965705365f1b5494332dafbff114 100644 (file)
@@ -167,13 +167,23 @@ if re.search(r'win32', config.target_triple):
 config.substitutions.append( ('%llc_dwarf', llc_dwarf) )
 
 # Add site-specific substitutions.
-config.substitutions.append( ('%ocamlopt', config.ocamlopt_executable) )
 config.substitutions.append( ('%go', config.go_executable) )
 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
 config.substitutions.append( ('%exeext', config.llvm_exe_ext) )
 config.substitutions.append( ('%python', config.python_executable) )
 
+# OCaml substitutions.
+# Support tests for both native and bytecode builds.
+if config.ocamlopt_executable != "":
+    config.substitutions.append( ('%ocamlcomp',
+        "%s %s" % (config.ocamlopt_executable, config.ocaml_flags)) )
+    config.substitutions.append( ('%cma', 'cmxa') )
+else:
+    config.substitutions.append( ('%ocamlcomp',
+        "%s %s" % (config.ocamlc_executable, config.ocaml_flags)) )
+    config.substitutions.append( ('%cma', 'cma') )
+
 # For each occurrence of an llvm tool name as its own word, replace it
 # with the full path to the build directory holding that tool.  This
 # ensures that we are testing the tools just built and not some random
index f3141df3268bc4b2def7e5d3144c65ee89705355..2a058e9fa3b17b64a7b6aa0cdc980b084d36ec20 100644 (file)
@@ -12,7 +12,9 @@ config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
+config.ocamlc_executable = "@OCAMLC@"
 config.ocamlopt_executable = "@OCAMLOPT@"
+config.ocaml_flags = "@OCAMLFLAGS@"
 config.go_executable = "@GO_EXECUTABLE@"
 config.enable_shared = @ENABLE_SHARED@
 config.enable_assertions = @ENABLE_ASSERTIONS@