Skip to content

Commit

Permalink
Merge pull request #1 from jpsamaroo/jps/saot-refactor-compile
Browse files Browse the repository at this point in the history
Slightly refactor compile.jl
  • Loading branch information
tshort committed Apr 7, 2019
2 parents 964e143 + 90d2298 commit f8fc866
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/standalone-aot/standalone-exe/compile.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
include("../IRGen.jl")
using .IRGen

twox(x) = 2x
native = irgen(twox, Tuple{Int})
dump_native(native, "libtwox.o")
run(`clang -shared -fpic libtwox.o -o libtwox.so`)
dir = @__DIR__
run(`clang -c -std=gnu99 -I'../../../usr/include/julia' -DJULIA_ENABLE_THREADING=1 -fPIC twox.c`)
run(`clang -o twox twox.o -L$dir -L$dir/../../../usr/lib -Wl,--unresolved-symbols=ignore-in-object-files -Wl,-rpath,'.' -Wl,-rpath,'../../../usr/lib' -ljulia-debug -ltwox`)
arraysum(x) = sum([x, 1])

funcs = [
"twox" => (twox, Tuple{Int}),
"arraysum" => (arraysum, Tuple{Int}),
]

arraysum(x) = sum([x, 1])
native = irgen(arraysum, Tuple{Int})
dump_native(native, "libarraysum.o")
run(`clang -shared -fpic libarraysum.o -o libarraysum.so`)
dir = @__DIR__
run(`clang -c -std=gnu99 -I'../../../usr/include/julia' -DJULIA_ENABLE_THREADING=1 -fPIC arraysum.c`)
run(`clang -o arraysum arraysum.o -L$dir -L$dir/../../../usr/lib -Wl,--unresolved-symbols=ignore-in-object-files -Wl,-rpath,'.' -Wl,-rpath,'../../../usr/lib' -ljulia-debug -larraysum`)
for (fname, (func, sig)) in funcs
native = irgen(func, sig)
dump_native(native, "lib$fname.o")
run(`clang -shared -fpic lib$fname.o -o lib$fname.so`)
dir = @__DIR__
run(`clang -c -std=gnu99 -I'../../../usr/include/julia' -DJULIA_ENABLE_THREADING=1 -fPIC $fname.c`)
run(`clang -o $fname $fname.o -L$dir -L$dir/../../../usr/lib -Wl,--unresolved-symbols=ignore-in-object-files -Wl,-rpath,'.' -Wl,-rpath,'../../../usr/lib' -ljulia-debug -l$fname`)
end

0 comments on commit f8fc866

Please sign in to comment.