Make the indirect branch optimization deterministic. No functionality change.
[oota-llvm.git] / test / Makefile
1 #===- test/Makefile ----------------------------------------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===------------------------------------------------------------------------===#
9
10 LEVEL = ..
11 DIRS  =
12
13 all:: check-local
14
15 # Include other test rules
16 include Makefile.tests
17
18 #===------------------------------------------------------------------------===#
19 # DejaGNU testing support
20 #===------------------------------------------------------------------------===#
21
22 ifneq ($(GREP_OPTIONS),)
23 $(warning GREP_OPTIONS environment variable may interfere with test results)
24 endif
25
26 ifdef VERBOSE
27 LIT_ARGS := -v
28 else
29 LIT_ARGS := -s -v
30 endif
31
32 ifdef TESTSUITE
33 LIT_TESTSUITE := $(TESTSUITE)
34 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
35 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
36 else
37 LIT_TESTSUITE := .
38 endif
39
40 ifdef VG
41 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full $(VALGRIND_EXTRA_ARGS)
42 endif
43
44 # Check what to run for -all.
45 LIT_ALL_TESTSUITES := $(LIT_TESTSUITE)
46
47 extra-site-cfgs::
48 .PHONY: extra-site-cfgs
49
50 ifneq ($(strip $(filter check-local-all,$(MAKECMDGOALS))),)
51 ifndef TESTSUITE
52 ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/Makefile && echo OK), OK)
53 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/test
54
55 # Force creation of Clang's lit.site.cfg.
56 clang-site-cfg: FORCE
57         $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/test lit.site.cfg Unit/lit.site.cfg
58 extra-site-cfgs:: clang-site-cfg
59 endif
60
61 ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/Makefile && echo OK), OK)
62 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test
63
64 # Force creation of Clang Tools' lit.site.cfg.
65 clang-tools-site-cfg: FORCE
66         $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test lit.site.cfg
67 extra-site-cfgs:: clang-tools-site-cfg
68 endif
69 endif
70 endif
71
72 # ulimits like these are redundantly enforced by the buildbots, so
73 # just removing them here won't work.
74 # Both AuroraUX & Solaris do not have the -m flag for ulimit
75 ifeq ($(HOST_OS),SunOS)
76 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
77 else # !SunOS
78 ifeq ($(HOST_OS),AuroraUX)
79 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
80 else # !AuroraUX
81 # Fedora 13 x86-64 python fails with -v 76800
82 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 1024000 ;
83 endif # AuroraUX
84 endif # SunOS
85
86 check-local:: lit.site.cfg Unit/lit.site.cfg
87         ( $(ULIMIT) \
88           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) )
89
90 # This is a legacy alias dating from when both DejaGNU and lit were in use.
91 check-local-lit:: check-local
92
93 check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-site-cfgs
94         ( $(ULIMIT) \
95           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
96
97 clean::
98         $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
99
100 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
101 ifeq ($(TARGET_OS),Darwin)
102 DSYMUTIL=dsymutil
103 else
104 DSYMUTIL=true
105 endif
106
107 ifneq ($(OCAMLOPT),)
108 CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
109 CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT))
110 endif
111
112 FORCE:
113
114 ifeq ($(DISABLE_ASSERTIONS),1)
115 ENABLE_ASSERTIONS=0
116 else
117 ENABLE_ASSERTIONS=1
118 endif
119
120 # Derive whether or not LTO is enabled by checking the extra options.
121 LTO_IS_ENABLED := 0
122 ifneq ($(findstring -flto,$(CompileCommonOpts)),)
123 LTO_IS_ENABLED := 1
124 else
125 ifneq ($(findstring -O4,$(CompileCommonOpts)),)
126 LTO_IS_ENABLED := 1
127 endif
128 endif
129
130 lit.site.cfg: FORCE
131         @echo "Making LLVM 'lit.site.cfg' file..."
132         @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g > lit.tmp
133         @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g >> lit.tmp
134         @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
135         @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
136         @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> lit.tmp
137         @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp
138         @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=python=g >> lit.tmp
139         @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc $(subst *,'\\\"',*$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))*) -I $(LibDir)/ocaml=g >> lit.tmp
140         @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp
141         @$(ECHOPATH) s=@ENABLE_ASSERTIONS@=$(ENABLE_ASSERTIONS)=g >> lit.tmp
142         @$(ECHOPATH) s=@LTO_IS_ENABLED@=$(LTO_IS_ENABLED)=g >> lit.tmp
143         @$(ECHOPATH) s=@TARGETS_TO_BUILD@=$(TARGETS_TO_BUILD)=g >> lit.tmp
144         @$(ECHOPATH) s=@LLVM_BINDINGS@=$(BINDINGS_TO_BUILD)=g >> lit.tmp
145         @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> lit.tmp
146         @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp
147         @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
148         @-rm -f lit.tmp
149
150 Unit/lit.site.cfg: $(PROJ_OBJ_DIR)/Unit/.dir FORCE
151         @echo "Making LLVM unittest 'lit.site.cfg' file..."
152         @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > unit.tmp
153         @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> unit.tmp
154         @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> unit.tmp
155         @$(ECHOPATH) s=@LLVM_BUILD_MODE@=$(BuildMode)=g >> unit.tmp
156         @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> unit.tmp
157         @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> unit.tmp
158         @$(ECHOPATH) s=@SHLIBPATH_VAR@=$(SHLIBPATH_VAR)=g >> unit.tmp
159         @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> unit.tmp
160         @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp
161         @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
162         @-rm -f unit.tmp