Skip to content

Commit e57eae5

Browse files
committed
Build improvements
Register src/llvmrt as a subdir for the toplevel configure script Improve examples makefile to build arbitrary source files
1 parent 0e68c39 commit e57eae5

File tree

4 files changed

+550
-18
lines changed

4 files changed

+550
-18
lines changed

README.llvm

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Instructions
22
------------
33

4+
1. Run autoreconf
5+
2. Run ./configure
6+
3. Build scala with ant
7+
4. Enter docs/examples/llvm
8+
5. Run make run-sample
9+
410
There's an example in docs/examples/llvm/ that can be compiled and run by
511
running 'make run-sample' in that directory. For comparison, you can run
612
'make run-sample-jvm' to compile and run for the JVM.

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ CHECK_ALIGNMENT([int64_t])
3434
CHECK_ALIGNMENT([float])
3535
CHECK_ALIGNMENT([double])
3636

37+
AC_CONFIG_SUBDIRS([src/llvmrt])
3738
AC_CONFIG_FILES([src/llvm-ffi/scala/ffi/ctypes.scala])
3839
AC_OUTPUT

docs/examples/llvm/Makefile

+23-18
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@ [email protected]
33

44
run-sample:
55
make -C ../../../src/llvmrt llvmrt.a runscala
6-
make clean
7-
make code.bc; make code.bc
8-
../../../src/llvmrt/runscala code.bc example
6+
rm -rf irfiles/example irfiles/example.stamp
7+
rm -rf bin/example.bc bin/example.aot
8+
make irfiles/example.stamp bin/example.bc bin/example.aot
9+
../../../src/llvmrt/runscala bin/example.bc example
10+
./bin/example.aot
911

1012
run-sample-jvm:
1113
make classes
1214
../../../build/quick/bin/scala -cp classes example
1315

14-
code.bc: irfiles.stamp $(patsubst %.ll,%.bc,$(wildcard irfiles/*.ll))
15-
llvm-ld -o $@ -r -disable-internalize irfiles/*.bc ../../../src/llvmrt/llvmrt.a
16+
irfiles/%.stamp irfiles/%/*.ll: %.scala runtime.scala
17+
mkdir -p irfiles/$*
18+
JAVA_OPTS=-Xmx500M ../../../build/quick/bin/scalac -no-specialization -d irfiles/$* -target:llvm $*.scala runtime.scala @base.sources $(FFISOURCES) # $(SOURCES)
19+
touch irfiles/$*.stamp
1620

17-
irfiles.stamp irfiles/*.ll: example.scala runtime.scala
18-
mkdir -p irfiles
19-
JAVA_OPTS=-Xmx2500M ../../../build/quick/bin/scalac -no-specialization -d irfiles -target:llvm example.scala runtime.scala apr.scala $(FFISOURCES) @base.sources # $(SOURCES)
20-
touch irfiles.stamp
21+
bin/%.bc: irfiles/%.stamp
22+
mkdir -p `dirname $@`
23+
for x in irfiles/$*/*.ll ; do \
24+
llvm-as $$x; \
25+
done
26+
llvm-ld -o $@ -r -disable-internalize irfiles/$*/*.bc ../../../src/llvmrt/llvmrt.a
27+
28+
bin/%.aot: bin/%.bc
29+
../../../src/llvmrt/linkscala $< `basename $*`
30+
llvm-ld -v -native -o $@ b.out.bc ../../../src/llvmrt/llvmrt.a -lapr-1 -L/usr/lib64 `icu-config --ldflags-libsonly ` ../../../src/llvmrt/unwind.o
31+
rm -f b.out.bc
2132

2233
classes: example.scala
2334
mkdir -p classes
2435
../../../build/quick/bin/scalac -d classes example.scala
2536

26-
%.bc: %.ll
27-
llvm-as $<
28-
29-
%.ll: %.bc
30-
llvm-dis $<
31-
3237
a.out.ll: a.out.bc
3338
llvm-dis $<
3439

40+
%.bc: %.ll
41+
llvm-as -o $@ $<
42+
3543
force:
3644
touch example.scala
3745
$(MAKE) a.out
38-
39-
clean:
40-
rm -rf irfiles code.bc irfiles.stamp

0 commit comments

Comments
 (0)