Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang -Xclang -cc1 -O3 mips.c -emit-llvm , clang error: -emit-llvm cannot be used when linking

Tags:

c

llvm

clang

I want to use the clang front-end to convert mips.c to mips.ll which is a llvm IR.

So I use the command: clang -cc1 O3 mips.c -emit-llvm. A fatal error occurs: 'stdio.h'(which is included in mips.c) file not found.

Then I change the command as following: clang -Xclang -cc1 O3 mips.c -emit-llvm. Another error occurs: -emit-llvm cannot be used when linking

How can I solve the problem?

like image 933
Shindou Avatar asked Mar 15 '23 19:03

Shindou


1 Answers

As written in the error message, you can only compile when emitting LLVM IR, not link.

Either add -c for the bitcode or -S for the readable form to your command line:

clang -Xclang -cc1 -O3 mips.c -emit-llvm -S
like image 81
Stefano Sanfilippo Avatar answered Apr 05 '23 21:04

Stefano Sanfilippo