Skip to content

Commit bc70128

Browse files
committed
Port to LLVM 3.8, and fix 'make run' example
1 parent 92abe21 commit bc70128

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

part2/Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ TOOLS:=tutorial02
55
#TARGET:=native
66
TARGET:=byte
77

8-
LLVM_VERSION := 3.5
8+
LLVM_VERSION := 3.8
9+
CLANG := clang-$(LLVM_VERSION)
910

1011
OCAMLBUILDFLAGS:=-classic-display -j 0 -cflags -w,@a-4
1112

1213
export OCAMLPATH=/usr/lib/ocaml/llvm-$(LLVM_VERSION)
1314

14-
tutorial02_OCAMLBUILDFLAGS:=-use-ocamlfind -pkgs llvm,llvm.bitreader
15+
tutorial02_OCAMLBUILDFLAGS:=-use-ocamlfind -pkgs llvm,llvm.bitreader -lflags -ccopt,-L/usr/lib/llvm-$(LLVM_VERSION)/lib
1516

1617

1718

@@ -32,12 +33,14 @@ default: $(TOOLS)
3233
$(TOOLS):
3334
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) $($@_OCAMLBUILDFLAGS) $($@_OCAMLBUILDFLAGS_$(TARGET)) -I $(SRC_DIR) -build-dir build/$@ $@.$(TARGET)
3435

35-
run: $(TOOLS)
36-
CAML_LD_LIBRARY_PATH=/usr/lib/ocaml/llvm-$(LLVM_VERSION) ./build/llvmBCTargetTriple/src/llvmBCTargetTriple.byte
36+
run: $(TOOLS) hello.bc
37+
CAML_LD_LIBRARY_PATH=/usr/lib/ocaml/llvm-$(LLVM_VERSION) ./build/tutorial02/src/tutorial02.byte hello.bc
3738

3839
clean: $(CLEAN_RULES)
40+
-rm -f hello.bc
3941

4042
$(CLEAN_RULES):
4143
$(OCAMLBUILD) $(OCAMLBUILDFLAGS) -I $(SRC_DIR) -build-dir build/$(patsubst %-clean,%,$@) -clean $(patsubst %-clean,%,$@).$(TARGET)
4244

43-
45+
hello.bc: hello.c
46+
$(CLANG) -c -emit-llvm $<

part2/hello.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* compile with: clang -emit-llvm -c hello.c -o hello.bc */
2+
#include <stdio.h>
3+
4+
int main(void)
5+
{
6+
printf("hello, world\n");
7+
8+
return 0;
9+
}

0 commit comments

Comments
 (0)