I have a problem with clang and compiling/linking/preprocessing several files together.
Working situation:
If all of them are .c
files, then I can use
clang -c -g -emit-llvm myfile1.c myfile2.c myfile3.c
# outputs myfile1.bc myfile2.bc myfile3.bc
Then, I'm linking with
llvm-link myfile1.bc myfile2.bc myfile3.bc -o merged.bc
However, I cannot do the same, if one of my files is an x86 assembly file.
clang -c -g -emit-llvm myfile4.s
Produces myfile4.o
as an output. When I try to link them using llvm-link
, I have the following output:
llvm-link: myfile4.o:1:1: error: expected top-level entity
ELF SOME GIBBERISH...
I need those .s
files and I don't know how can I use this method. I have looked at this link and also to this link too.
Is there any method, way to achieve what I want to do?