[LLVMdev] Questions about clang options

Xinglin Zhang xinglinzh at gmail.com
Thu Aug 2 13:16:30 PDT 2012


Thank you guys for the answer. These definitely help a lot:)

On Thu, Aug 2, 2012 at 3:54 PM, Dmitry N. Mikushin <maemarcus at gmail.com>wrote:

> Dear Zhang,
>
> Compiler ends up invoking cc1 (the backend) anyways. So if you would
> like to invoke it by hand, the only thing to know is the right
> combination of options. Try to use the compiler verbose option "-v".
> It will show you how exactly clang invokes the backend:
>
> > clang -v -c showdebug.c
> clang version 3.2 (trunk 156703)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
>  "/opt/kernelgen/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu
> -emit-obj -mrelax-all -disable-free -main-file-name showdebug.c
> -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
> -mconstructor-aliases -munwind-tables -target-cpu x86-64
> -target-linker-version 11 -momit-leaf-frame-pointer -v -coverage-file
> showdebug.o -resource-dir /opt/kernelgen/bin/../lib/clang/3.2
> -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem
> /usr/local/include -internal-isystem
> /opt/kernelgen/bin/../lib/clang/3.2/include -internal-externc-isystem
> /include -internal-externc-isystem /usr/include
> -fdebug-compilation-dir
> /RHM/users/work/dmikushin/forge/kernelgen/trunk/src -ferror-limit 19
> -fmessage-length 173 -mstackrealign -fgnu-runtime
> -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
> -fdiagnostics-show-option -fcolor-diagnostics -o showdebug.o -x c
> showdebug.c
> clang -cc1 version 3.2 based upon LLVM 3.2svn default target
> x86_64-unknown-linux-gnu
> ignoring nonexistent directory "/include"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/local/include
>  /opt/kernelgen/bin/../lib/clang/3.2/include
>  /usr/include
> End of search list.
>
> Happy hacking,
> - Dima.
>
> 2012/8/2 Eli Friedman <eli.friedman at gmail.com>:
> > On Thu, Aug 2, 2012 at 8:56 AM, Xinglin Zhang <xinglinzh at gmail.com>
> wrote:
> >> Hi,
> >>
> >> I am quite new to LLVM. I just compiled LLVM and clang on Ubuntu11.10
> then
> >> followed the tutorial  http://llvm.org/docs/DebuggingJITedCode.html
> >>
> >> clang -cc1 -O0 -g -emit-llvm showdebug.c
> >>
> >>
> >> where showdebug.c contains:
> >>
> >> #include<stdio.h>
> >> int main()
> >> {
> >>   printf("hello\n");
> >>   return 0;
> >> }
> >>
> >> But I got
> >> Fatal error: 'stdio.h' file not found.
> >>
> >>
> >> However,
> >>
> >> clang showdebug.c
> >>
> >>
> >> has no problem. I know -g means to generate debug information,
> -emit-llvm
> >> means use the llvm representation for assembler and object files.
> >>
> >> Then what do -cc1 and -O0 mean?
> >
> > -O0 means "turn off optimization".  -cc1 means "please screw up my
> > compilation in mysterious ways".
> >
> > -Eli
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
Xinglin Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120802/c22d28e9/attachment.html>


More information about the llvm-dev mailing list