llvm
llvm-ld -link-as-library -native -O5 re_exec.o re_comp.o re.o -o ../../lib/auto/re/re.so
=> Still a bytecode file. Why?
This is my idea:
diff --git a/Makefile.SH b/Makefile.SH
index 0a2df3e..c418686 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -178,6 +178,21 @@ EOT
;;
esac
+: TODO replace $(CC) -o with $(LD) -o
+case "$cc" in
+llvm-gcc*)
+ ld=llvm-ld
+ ar=llvm-ar
+ ldflags=-native `echo "$ldflags" | sed 's/-fstack-protector//'`
+ lddlflags=-link-as-library -native -disable-internalize `echo "$lddlflags" | sed 's/-fstack-protector//'`
+ slddlflags=$lddlflags
+ cddlflags=
+ ccflags="-emit-llvm $ccflags"
+ archname="$archname-llvm"
+ ;;
+esac
+
+
: Prepare dependency lists for Makefile.
dynamic_list=' '
dynamic_ext_re="lib/auto/re/re.$dlext"
Looks like llvm-ld contrary to the man page alway emits bytecode, which has to be assembled by something like this to a ELF/COFF .so/.dll:
$ld $lddlflags; llc a.out -o - | as -o $@
llvm-ld -link-as-library -native -O5 re_exec.o re_comp.o re.o -o a.out && \
llc a.out -o - | as -o ../../lib/auto/re/re.so
I could not get llvm-ld to write to pipes:
$ llvm-ld -native -link-as-library -O5 re_exec.bc re_comp.bc re.bc -o -| llc - -o - | \
as -o ../../lib/auto/re/re.so
llc: bitcode didn't read correctly.
Reason: Invalid bitcode signature
We might also be forced to save to .s and compile with cc -shared
On the CC vs LD problem
Still thinking about the CC => LD patchup for llvm. Other non-gcc/cl compilers would also like to use LD to link executables from objects files I guess. Legacy.