[llvm-dev] Why can't clang -emit-llvm when linking?
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Mon May 30 10:35:18 PDT 2016
On 30 May 2016 at 09:34, Lorenzo Laneve via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I know right, but if I do -emit-llvm clang will emit an IR module as .ll
> file for each source I give him. So why can't it just emit the modules for
> the sources and then continue the compilation? I don't get the point of this
> error. Just for curiosity
I think it's that -emit-llvm is treated like a final-output option
(-c, -S, default is linking). There's a -save-temps option that will
store intermediate forms even when linking. I think it saves the
preprocessed source, .bc file and .o file for a link step.
Cheers.
Tim.
>
> On May 30, 2016, at 6:17 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
> There is no single LLVM IR for the entire compilation process in such a
> command line - separate IR is created for each source file, an object file
> is created, then those (native, non-IR) object files are linked together. So
> it's somewhat a invalid concept.
>
> In your case, since there's only one file anyway, just add -c and you should
> be fine (your IR won't include the standard library/other thingsn that would
> be linked into the program - but those would be native objects and not IR in
> any case)
>
> - Dave
>
> On Mon, May 30, 2016 at 5:33 AM, Lorenzo Laneve via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
>>
>> When I try to do
>>
>> clang++ main.cpp -emit-llvm
>>
>> without -S, clang says that he can’t:
>>
>> clang: error: -emit-llvm cannot be used when linking
>>
>>
>> why can’t it emit the IR in a complete compilation process?
>>
>> Is there a particular technical reason or just to avoid confusing jobs?
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
More information about the llvm-dev
mailing list