Hi all, A question about statically linking a pass to clang instead of dynamically loading it at runtime. I am stumped on this bug for a while. I inserted a pass under lib/Transforms/mypass directory, registered it with INITIALIZE_PASS and defined createMyPass in the pass. Also I added file mypass.h in include/llvm/Transforms/ to expose the accessor functions that expose my passes. Entries are added in include/llvm/LinkAllPasses.h to force pass linking. The archive files of my passes are added to LINK_COMPONENTS in the Makefiles for opt and clang. However, the passes are still not statically linked. Is there a way to statically link a pass into clang? If possible, how do turn on and off my passes with command line options? I am trying to use clang as a c and c++ compiler. I can walk around this by compiling source into bitcode and then invoke opt which dynamically loads my passes and then compile it into x86 assembly with llc. How can I pass some command line options for clang such as -fomit-frame-pointer to llc so that frame pointer is reserved? Thank you so much in advance. Bin Zeng -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110923/d50e5c3e/attachment.html>
2011/9/24 Zeng Bin <ezengbin at gmail.com>:> A question about statically linking a pass to clang instead of dynamically > loading it at runtime. I am stumped on this bug for a while. I inserted a > pass under lib/Transforms/mypass directory, registered it with > INITIALIZE_PASS and defined createMyPass in the pass. Also I added file > mypass.h in include/llvm/Transforms/ to expose the accessor functions that > expose my passes. Entries are added in include/llvm/LinkAllPasses.h to force > pass linking. The archive files of my passes are added to LINK_COMPONENTS in > the Makefiles for opt and clang. However, the passes are still not > statically linked. Is there a way to statically link a pass into clang? If > possible, how do turn on and off my passes with command line options?I don't think include/llvm/LinkAllPasses.h would affect clang. Did you see lib/Transforms/IPO/PassManagerBuilder.cpp ? ...Takumi
2011/9/27 Zeng Bin <ezengbin at gmail.com>:> > > On Sun, Sep 25, 2011 at 8:45 PM, NAKAMURA Takumi <geek4civic at gmail.com> > wrote: >> >> 2011/9/24 Zeng Bin <ezengbin at gmail.com>: >> > A question about statically linking a pass to clang instead of >> > dynamically >> > loading it at runtime. I am stumped on this bug for a while. I inserted >> > a >> > pass under lib/Transforms/mypass directory, registered it with >> > INITIALIZE_PASS and defined createMyPass in the pass. Also I added file >> > mypass.h in include/llvm/Transforms/ to expose the accessor functions >> > that >> > expose my passes. Entries are added in include/llvm/LinkAllPasses.h to >> > force >> > pass linking. The archive files of my passes are added to >> > LINK_COMPONENTS in >> > the Makefiles for opt and clang. However, the passes are still not >> > statically linked. Is there a way to statically link a pass into clang? >> > If >> > possible, how do turn on and off my passes with command line options? >> >> I don't think include/llvm/LinkAllPasses.h would affect clang. >> Did you see lib/Transforms/IPO/PassManagerBuilder.cpp ? >> >> ...Takumi > > Hi Takumi, > > Thank you very much for the reply. There is no file called > PassManagerBuilder.cpp in lib/Transforms/IPO/. I am using LLVM 2.8.Then, seek StandardPasses.h in include/llvm. IMO, you should take top of trunk if you would play with clang. 2.8 is too old. 3.0 branch will come soon. ...Takumi
Bin, please don't send only to me, but CC to llvmdev. or you would not receive 3rd person's answer. 2011/9/27 Zeng Bin <ezengbin at gmail.com>:> Thanks a lot for the info. Now my passes are linked into clang. Is there a > way to pass a parameter to clang to turn off my passes? With opt, you can > disable a pass by command line switch -mypass. Can you do that with clang?Try to ask on cfe-dev ;) ..Takumi
Apparently Analagous Threads
- [LLVMdev] statically link pass to clang
- [LLVMdev] statically link pass to clang
- [LLVMdev] [cfe-commits] r157260 - in /cfe/trunk: include/clang/Rewrite/Rewriter.h lib/Rewrite/Rewriter.cpp unittests/CMakeLists.txt unittests/Tooling/RewriterTest.cpp unittests/Tooling/RewriterTestContext.h
- [LLVMdev] statically linked passes
- [LLVMdev] A potential bug