From: Peter Zotov Date: Tue, 28 Oct 2014 22:39:36 +0000 (+0000) Subject: [OCaml] PR9719, PR14727: Make tests run without ocamlopt. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=b4d023aafe70ffaae8b5e8695ed0d5b4b51c2aa4 [OCaml] PR9719, PR14727: Make tests run without ocamlopt. 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 --- diff --git a/test/Bindings/Ocaml/analysis.ml b/test/Bindings/Ocaml/analysis.ml index c02645c0bce..fe71f6898dd 100644 --- a/test/Bindings/Ocaml/analysis.ml +++ b/test/Bindings/Ocaml/analysis.ml @@ -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 *) diff --git a/test/Bindings/Ocaml/bitreader.ml b/test/Bindings/Ocaml/bitreader.ml index f1d202ab049..f219550f92f 100644 --- a/test/Bindings/Ocaml/bitreader.ml +++ b/test/Bindings/Ocaml/bitreader.ml @@ -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 diff --git a/test/Bindings/Ocaml/bitwriter.ml b/test/Bindings/Ocaml/bitwriter.ml index d4d0417a80e..ece9a393325 100644 --- a/test/Bindings/Ocaml/bitwriter.ml +++ b/test/Bindings/Ocaml/bitwriter.ml @@ -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 diff --git a/test/Bindings/Ocaml/executionengine.ml b/test/Bindings/Ocaml/executionengine.ml index 3109081a71e..fa325ebc1df 100644 --- a/test/Bindings/Ocaml/executionengine.ml +++ b/test/Bindings/Ocaml/executionengine.ml @@ -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 *) diff --git a/test/Bindings/Ocaml/ext_exc.ml b/test/Bindings/Ocaml/ext_exc.ml index 9afc3c3ab4b..80924387110 100644 --- a/test/Bindings/Ocaml/ext_exc.ml +++ b/test/Bindings/Ocaml/ext_exc.ml @@ -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 %t.ll * RUN: FileCheck %s < %t.ll diff --git a/test/Makefile b/test/Makefile index 156009d026c..00626695bc1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 diff --git a/test/lit.cfg b/test/lit.cfg index 55f559e68dc..63880d0dac7 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -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 diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index f3141df3268..2a058e9fa3b 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -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@