Mahesha S via llvm-dev
2019-Mar-01 07:15 UTC
[llvm-dev] Question about passing -v -save-temps cmd args to clang++
Hello all, This could be a naive question, but still asking it here because of my limited knowledge on clang/llvm infrastructure. *Question:* When I pass `-v save-temps` options to clang++, I was expecting to see the command line for both `opt` and `llc` in the expanded command line output, but, I don't see it. What am I missing? *Clang++ Command Line:* clang++ -v -save-temps hello.cpp *Expanded Command Line Output:* clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2d6bb13443d86d650e92b280d4f7df0805eebac7) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/mahesha/LLVM/install/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/home/mahesha/LLVM/install/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -E -save-temps=cwd -disable-free -main-file-name hello.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath- errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/mahesha/LLVM/install/lib/clang/9.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux -gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/local/include -internal-isystem /home /mahesha/LLVM/install/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilat ion-dir /home/mahesha/Scratch -ferror-limit 19 -fmessage-length 211 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o hello.ii -x c++ hello.cpp -faddrsig clang -cc1 version 9.0.0 based upon LLVM 9.0.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward /usr/local/include /home/mahesha/LLVM/install/lib/clang/9.0.0/include /usr/include/x86_64-linux-gnu /usr/include End of search list. "/home/mahesha/LLVM/install/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists -save-temps=cwd -disable-free -main-file-name hello.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/mahesha/LLVM/install/li b/clang/9.0.0 -fdeprecated-macro -fdebug-compilation-dir /home/mahesha/Scratch -ferror-limit 19 -fmessage-length 211 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -disable-llvm-passes -o hello.bc -x c++-cpp-output hello.ii -faddrsig clang -cc1 version 9.0.0 based upon LLVM 9.0.0svn default target x86_64-unknown-linux-gnu #include "..." search starts here: End of search list. "/home/mahesha/LLVM/install/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -S -save-temps=cwd -disable-free -main-file-name hello.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath- errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/mahesha/LLVM/install/lib/clang/9.0.0 -fdebug-compilati on-dir /home/mahesha/Scratch -ferror-limit 19 -fmessage-length 211 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o hello.s -x ir hello.bc -faddrsig clang -cc1 version 9.0.0 based upon LLVM 9.0.0svn default target x86_64-unknown-linux-gnu "/home/mahesha/LLVM/install/bin/clang-9" -cc1as -triple x86_64-unknown-linux-gnu -filetype obj -main-file-name hello.cpp -target-cpu x86-64 -dwarf-version=4 -mrelocation-model static -mrelax-all -o hello.o hell o.s "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64 -linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0 -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu -L/lib/x86_6 4-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../.. -L/home/mahesha/LLVM/install/bin/../lib -L/lib -L/usr/lib hello.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lg cc /usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtend.o /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crtn.o -- Thanks, Mahesha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190301/5bf222ab/attachment.html>
Anton Korobeynikov via llvm-dev
2019-Mar-01 08:24 UTC
[llvm-dev] [cfe-dev] Question about passing -v -save-temps cmd args to clang++
Hello> Question: When I pass `-v save-temps` options to clang++, I was expecting to see the command line for both `opt` and `llc` in the expanded command line output, but, I don't see it. What am I missing?Nothing. Neither opt nor llc are executed by clang. Both of them are developer-side tools and not intended for "end-user consumption". clang calls LLVM API directly both for optimization and codegeneration. -- With best regards, Anton Korobeynikov Department of Statistical Modelling, Saint Petersburg State University
Mahesha S via llvm-dev
2019-Mar-01 08:48 UTC
[llvm-dev] [cfe-dev] Question about passing -v -save-temps cmd args to clang++
Hello Anton Korobeynikov, Thanks for the clarification. I can see three invocations of the compiler proper (-cc1) in the above-expanded command line. The first one takes .cc to .ii (preprocessing as usual), the second one takes .ii to .bc, and the third one takes .bc to .s. I assume that OPT APIs are invoked in the second phase and the LLC APIs are invoked in the third phase. Am I right? Next, I would like to play around with LLC directly by passing some input .bc file. More specifically I would like to debug LLC using GDB by passing an input .bc file. I did some googling and explored LLVM docs about it. But, I could find nothing helpful. I have an understanding of different phases that an LLVM IR goes through before actually getting converted to target instruction. But, I would like to debug LLC to get a practical hold of it. Could you please help me in this regard? Any links to appropriate documentation also are also fine. Thanks, Mahesha On Fri, Mar 1, 2019 at 1:55 PM Anton Korobeynikov <anton at korobeynikov.info> wrote:> Hello > > > Question: When I pass `-v save-temps` options to clang++, I was > expecting to see the command line for both `opt` and `llc` in the expanded > command line output, but, I don't see it. What am I missing? > Nothing. Neither opt nor llc are executed by clang. Both of them are > developer-side tools and not intended for "end-user consumption". > clang calls LLVM API directly both for optimization and > codegeneration. > > -- > With best regards, Anton Korobeynikov > Department of Statistical Modelling, Saint Petersburg State University >-- Thanks, Mahesha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190301/ba68823b/attachment.html>