llvm.org GIT mirror llvm / a8c3660
Incorporating review feedback for GC verifier patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42163 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 11 years ago
6 changed file(s) with 94 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
157157 GZIP := @GZIP@
158158 OCAMLC := @OCAMLC@
159159 OCAMLOPT := @OCAMLOPT@
160 OCAMLDEP := @OCAMLDEP@
160161 POD2HTML := @POD2HTML@
161162 POD2MAN := @POD2MAN@
162163 RUNTEST := @RUNTEST@
533533 AC_PATH_PROG(ZIP,[zip],[echo "Skipped: zip not found"])
534534 AC_PATH_PROG(OCAMLC,[ocamlc],[echo "Skipped: ocamlc not found"])
535535 AC_PATH_PROG(OCAMLOPT,[ocamlopt],[echo "Skipped: ocamlopt not found"])
536 AC_PATH_PROG(OCAMLDEP,[ocamldep],[echo "Skipped: ocamldep not found"])
536537
537538 dnl Determine if the linker supports the -R option.
538539 AC_LINK_USE_R
3737 endif
3838
3939 # Tools
40 OCAMLCFLAGS += -I $(OcamlDir)
40 OCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir)
4141 OCAMLAFLAGS += $(patsubst %,-cclib %, \
4242 $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \
4343 $(UsedLibs) -l$(LIBRARYNAME))
5050 Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) -o)
5151
5252 # Source files
53 OcamlSources := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml))
54 OcamlHeaders := $(OcamlSources:.ml=.mli)
55
56 # Output and intermediate files
57 # The .cmo files are the only intermediates; all others get installed.
58 BareLibraryA := lib$(LIBRARYNAME).a
59 LibraryA := $(OcamlDir)/$(BareLibraryA)
60 LibraryCMA := $(OcamlDir)/$(LIBRARYNAME).cma
61 LibraryCMXA := $(OcamlDir)/$(LIBRARYNAME).cmxa
62 ObjectsCMI := $(OcamlSources:$(PROJ_SRC_DIR)/%.ml=$(OcamlDir)/%.cmi)
63 ObjectsCMO := $(OcamlSources:$(PROJ_SRC_DIR)/%.ml=$(ObjDir)/%.cmo)
64 ObjectsCMX := $(OcamlSources:$(PROJ_SRC_DIR)/%.ml=$(OcamlDir)/%.cmx)
65
66 # Dependencies
67 # Punting on ocamldep, since its output is only suitable for builds where
68 # objects are placed directly adjacent to sources, which is not us.
69 # Unfortunately, this is subtly incorrect and leads to occasional problems.
70 # ocamlc/ocamlopt really need an option akin to gcc -M or gcc -MD.
71 $(ObjectsCMO): $(ObjectsCMI) $(UsedOcamLibs:%=$(OcamlDir)/%.cmi)
72 $(ObjectsCMX): $(ObjectsCMI) $(UsedOcamLibs:%=$(OcamlDir)/%.cmi)
53 OcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml))
54 OcamlHeaders1 := $(OcamlSources1:.ml=.mli)
55
56 OcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%)
57 OcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%)
58
59 # Intermediate files
60 LibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma
61 LibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa
62 ObjectsCMI := $(OcamlSources:%.ml=%.cmi)
63 ObjectsCMO := $(OcamlSources:%.ml=%.cmo)
64 ObjectsCMX := $(OcamlSources:%.ml=%.cmx)
65
66 # Output files
67 # The .cmo files are the only intermediates; all others are to be installed.
68 LibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a
69 OutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma)
70 OutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa)
71 OutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi)
72 OutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx)
7373
7474 # Installation targets
7575 DestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a
7676 DestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma
7777 DestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa
78
79
80 ##===- Dependencies -------------------------------------------------------===##
81 # Copy the sources into the intermediate directory because older ocamlc doesn't
82 # support -o except when linking (outputs are placed next to inputs).
83
84 $(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir
85 $(Verb) $(CP) -f $< $@
86
87 $(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir
88 $(Verb) $(CP) -f $< $@
89
90 $(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders)
91 $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@
92
93 -include $(ObjDir)/$(LIBRARYNAME).ocamldep
7894
7995
8096 ##===- Build static library from C sources --------------------------------===##
111127 install-local:: install-cmis
112128 uninstall-local:: uninstall-cmis
113129
114 build-cmis: $(ObjectsCMI)
115
116 $(OcamlDir)/%.cmi: $(PROJ_SRC_DIR)/%.mli $(OcamlDir)/.dir
130 build-cmis: $(OutputsCMI)
131
132 $(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir
133 $(Verb) $(CP) -f $< $@
134
135 $(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir
117136 $(Echo) "Compiling $(notdir $<) for $(BuildMode) build"
118137 $(Verb) $(Compile.CMI) $@ $<
119138
120139 clean-cmis::
121 -$(Verb) $(RM) -f $(ObjectsCMI)
140 -$(Verb) $(RM) -f $(OutputsCMI)
122141
123142 # Also install the .mli's (headers) as documentation.
124 install-cmis: $(ObjectsCMI)
125 $(Verb) $(MKDIR) $(PROJ_libocamldir)
126 $(Verb) for i in $(patsubst $(OcamlDir)/%,%,$(ObjectsCMI)); do \
143 install-cmis: $(OutputsCMI) $(OcamlHeaders)
144 $(Verb) $(MKDIR) $(PROJ_libocamldir)
145 $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \
127146 $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
128147 $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \
129148 done
130 $(Verb) for i in $(patsubst $(PROJ_SRC_DIR)/%,%,$(OcamlHeaders)); do \
131 $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
132 $(DataInstall) $(PROJ_SRC_DIR)/$$i "$(PROJ_libocamldir)/$$i"; \
149 $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \
150 $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
151 $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \
133152 done
134153
135154 uninstall-cmis::
136 $(Verb) for i in $(patsubst $(OcamlDir)/%,%,$(ObjectsCMI)); do \
155 $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \
137156 $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
138157 $(RM) -f "$(PROJ_libocamldir)/$$i"; \
139158 done
140 $(Verb) for i in $(patsubst $(PROJ_SRC_DIR)/%,%,$(OcamlHeaders)); do \
159 $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \
141160 $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
142161 $(RM) -f "$(PROJ_libocamldir)/$$i"; \
143162 done
145164
146165 ##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===##
147166
148 all-local:: $(LibraryCMA)
167 all-local:: $(OutputCMA)
149168 clean-local:: clean-cma
150169 install-local:: install-cma
151170 uninstall-local:: uninstall-cma
171
172 $(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir
173 $(Verb) $(CP) -f $< $@
152174
153175 $(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir
154176 $(Echo) "Archiving $(notdir $@) for $(BuildMode) build"
157179 ln -sf "$(LibDir)/$$i" "$(OcamlDir)/$$i"; \
158180 done
159181
160 $(ObjDir)/%.cmo: $(PROJ_SRC_DIR)/%.ml $(OcamlDir)/.dir
182 $(ObjDir)/%.cmo: $(ObjDir)/%.ml
161183 $(Echo) "Compiling $(notdir $<) for $(BuildMode) build"
162184 $(Verb) $(Compile.CMO) $@ $<
163185
164186 clean-cma::
165 $(Verb) $(RM) -f $(LibraryCMA)
166
167 install-cma:: $(LibraryCMA)
187 $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%)
188
189 install-cma:: $(OutputCMA)
168190 $(Echo) "Installing $(BuildMode) $(DestCMA)"
169191 $(Verb) $(MKDIR) $(PROJ_libocamldir)
170 $(Verb) $(DataInstall) $(LibraryCMA) "$(DestCMA)"
192 $(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)"
171193 $(Verb) for i in $(UsedLibNames); do \
172194 $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
173195 ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \
188210 # If unavailable, 'configure' will not define OCAMLOPT in Makefile.config.
189211 ifdef OCAMLOPT
190212
191 all-local:: $(LibraryCMXA)
213 all-local:: $(OutputCMXA) $(OutputsCMX)
192214 clean-local:: clean-cmxa
193215 install-local:: install-cmxa
194216 uninstall-local:: uninstall-cmxa
217
218 $(OutputCMXA): $(LibraryCMXA)
219 $(Verb) $(CP) -f $< $@
220 $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a)
221
222 $(OcamlDir)/%.cmx: $(ObjDir)/%.cmx
223 $(Verb) $(CP) -f $< $@
195224
196225 $(LibraryCMXA): $(ObjectsCMX)
197226 $(Echo) "Archiving $(notdir $@) for $(BuildMode) build"
198227 $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX)
199228 $(Verb) $(RM) -f $(@:.cmxa=.o)
200229
201 $(OcamlDir)/%.cmx: $(PROJ_SRC_DIR)/%.ml
230 $(ObjDir)/%.cmx: $(ObjDir)/%.ml
202231 $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build"
203232 $(Verb) $(Compile.CMX) $@ $<
204233
205234 clean-cmxa::
206 $(Verb) $(RM) -f $(LibraryCMXA) $(LibraryCMXA:.cmxa=.o) \
207 $(LibraryCMXA:.cmxa=.a) $(ObjectsCMX)
208
209 install-cmxa:: $(LibraryCMXA)
235 $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.o) $(OutputsCMX)
236
237 install-cmxa:: $(OutputCMXA) $(OutputsCMX)
210238 $(Verb) $(MKDIR) $(PROJ_libocamldir)
211239 $(Echo) "Installing $(BuildMode) $(DestCMXA)"
212 $(Verb) $(DataInstall) $(LibraryCMXA) $(DestCMXA)
240 $(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA)
213241 $(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)"
214 $(Verb) $(DataInstall) $(LibraryCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a)
215 $(Verb) for i in $(ObjectsCMX:$(OcamlDir)/%=%); do \
242 $(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a)
243 $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \
216244 $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \
217245 $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \
218246 done
219247
220 uninstall-cmxa:: $(LibraryCMXA)
248 uninstall-cmxa::
221249 $(Echo) "Uninstalling $(DestCMXA)"
222250 $(Verb) $(RM) -f $(DestCMXA)
223251 $(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)"
224252 $(Verb) $(RM) -f $(DestCMXA:.cmxa=.a)
225 $(Verb) for i in $(ObjectsCMX:$(OcamlDir)/%=%); do \
253 $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \
226254 $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \
227255 $(RM) -f $(PROJ_libocamldir)/$$i; \
228256 done
239267 $(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)'
240268 $(Echo) "OCAMLC : " '$(OCAMLC)'
241269 $(Echo) "OCAMLOPT : " '$(OCAMLOPT)'
270 $(Echo) "OCAMLDEP : " '$(OCAMLDEP)'
242271 $(Echo) "Compile.CMI : " '$(Compile.CMI)'
243272 $(Echo) "Compile.CMO : " '$(Compile.CMO)'
244273 $(Echo) "Archive.CMA : " '$(Archive.CMA)'
247276 $(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)'
248277 $(Echo) "LibraryCMA : " '$(LibraryCMA)'
249278 $(Echo) "LibraryCMXA : " '$(LibraryCMXA)'
279 $(Echo) "OcamlSources1: " '$(OcamlSources1)'
250280 $(Echo) "OcamlSources : " '$(OcamlSources)'
281 $(Echo) "OcamlHeaders : " '$(OcamlHeaders)'
251282 $(Echo) "ObjectsCMI : " '$(ObjectsCMI)'
252283 $(Echo) "ObjectsCMO : " '$(ObjectsCMO)'
253284 $(Echo) "ObjectsCMX : " '$(ObjectsCMX)'
2424
2525 /* Llvm.llmodule -> string -> bool */
2626 CAMLprim value llvm_write_bitcode_file(value M, value Path) {
27 CAMLparam1(Path);
2827 int res = LLVMWriteBitcodeToFile((LLVMModuleRef) M, String_val(Path));
29 CAMLreturn(Val_bool(res == 0));
28 return Val_bool(res == 0);
3029 }
133133
134134 /* copy into an ocaml array */
135135 unsigned i;
136 value ParamTys = caml_alloc(Count, 0);
136 value ParamTys = alloc(Count, 0);
137137
138138 LLVMGetFunctionParamTypes((LLVMTypeRef) FunTy, FunTys);
139139 for (i = 0; i != Count; ++i)
158158
159159 /* copy into an ocaml array */
160160 unsigned i;
161 value ElementTys = caml_alloc(Count, 0);
161 value ElementTys = alloc(Count, 0);
162162
163163 LLVMGetStructElementTypes((LLVMTypeRef) StructTy, Tys);
164164 for (i = 0; i != Count; ++i)
224224
225225 /* llvalue -> string */
226226 CAMLprim value llvm_value_name(value Val) {
227 return caml_copy_string(LLVMGetValueName((LLVMValueRef) Val));
227 return copy_string(LLVMGetValueName((LLVMValueRef) Val));
228228 }
229229
230230 /* string -> llvalue -> unit */
295295 /* string -> bool -> llvalue */
296296 CAMLprim value llvm_make_string_constant(value Str, value NullTerminate) {
297297 return (value) LLVMGetStringConstant(String_val(Str),
298 caml_string_length(Str),
298 string_length(Str),
299299 Bool_val(NullTerminate) == 0);
300300 }
301301
339339
340340 /* llvalue -> string */
341341 CAMLprim value llvm_section(value Global) {
342 return caml_copy_string(LLVMGetSection((LLVMValueRef) Global));
342 return copy_string(LLVMGetSection((LLVMValueRef) Global));
343343 }
344344
345345 /* string -> llvalue -> unit */
154154 (* RUN: grep {Const04.*"cruel\\\\00world"} < %t.ll
155155 *)
156156 group "string";
157 let c = make_string_constant "cruel\x00world" false in
157 let c = make_string_constant "cruel\000world" false in
158158 ignore (define_global "Const04" c m);
159159 insist ((make_array_type i8_type 11) = type_of c);
160160
161161 (* RUN: grep {Const05.*"hi\\\\00again\\\\00"} < %t.ll
162162 *)
163163 group "string w/ null";
164 let c = make_string_constant "hi\x00again" true in
164 let c = make_string_constant "hi\000again" true in
165 prerr_string "====> ";
166 prerr_int (array_length (type_of c));
167 prerr_endline " <====";
165168 ignore (define_global "Const05" c m);
166169 insist ((make_array_type i8_type 9) = type_of c);
167170