diff options
author | Puyan Lotfi <puyan@puyan.org> | 2019-10-02 22:50:07 +0000 |
---|---|---|
committer | Puyan Lotfi <puyan@puyan.org> | 2019-10-02 22:50:07 +0000 |
commit | 2b8b74a6ff09a52dcd751e5429f4be32899ae3a3 (patch) | |
tree | 992233c4a6a6d5cd6e6a96aa771282b7da4e4b67 /lib/Driver/Types.cpp | |
parent | 6aa1f42be9f8fc0a416590815e92e42cdad60fa3 (diff) | |
download | clang-2b8b74a6ff09a52dcd751e5429f4be32899ae3a3.tar.gz |
[clang][ifs] Clang Interface Stubs ToolChain plumbing.
This patch enables end to end support for generating ELF interface stubs
directly from clang. Now the following:
clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp
will product an ELF binary with visible symbols populated. Visibility attributes
and -fvisibility can be used to control what gets populated.
* Adding ToolChain support for clang Driver IFS Merge Phase
* Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain
* Adds support for the clang Driver to involve llvm-ifs on ifs files.
* Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file
instead of the final object format (normally ELF)
Differential Revision: https://reviews.llvm.org/D63978
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Types.cpp')
-rw-r--r-- | lib/Driver/Types.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Driver/Types.cpp b/lib/Driver/Types.cpp index da01e1acfc..6241fac0c8 100644 --- a/lib/Driver/Types.cpp +++ b/lib/Driver/Types.cpp @@ -269,6 +269,7 @@ types::ID types::lookupTypeForExtension(llvm::StringRef Ext) { .Case("lib", TY_Object) .Case("mii", TY_PP_ObjCXX) .Case("obj", TY_Object) + .Case("ifs", TY_IFS) .Case("pch", TY_PCH) .Case("pcm", TY_ModuleFile) .Case("c++m", TY_CXXModule) @@ -319,6 +320,22 @@ void types::getCompilationPhases(const clang::driver::Driver &Driver, llvm::copy_if(PhaseList, std::back_inserter(P), [](phases::ID Phase) { return Phase <= phases::Precompile; }); + // Treat Interface Stubs like its own compilation mode. + else if (DAL.getLastArg(options::OPT_emit_iterface_stubs)) { + llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> IfsModePhaseList; + llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> &PL = PhaseList; + phases::ID LastPhase = phases::IfsMerge; + if (Id != types::TY_IFS) { + if (DAL.hasArg(options::OPT_c)) + LastPhase = phases::Compile; + PL = IfsModePhaseList; + types::getCompilationPhases(types::TY_IFS_CPP, PL); + } + llvm::copy_if(PL, std::back_inserter(P), [&](phases::ID Phase) { + return Phase <= LastPhase; + }); + } + // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler. else if (DAL.getLastArg(options::OPT_fsyntax_only) || DAL.getLastArg(options::OPT_print_supported_cpus) || @@ -327,7 +344,6 @@ void types::getCompilationPhases(const clang::driver::Driver &Driver, DAL.getLastArg(options::OPT_rewrite_objc) || DAL.getLastArg(options::OPT_rewrite_legacy_objc) || DAL.getLastArg(options::OPT__migrate) || - DAL.getLastArg(options::OPT_emit_iterface_stubs) || DAL.getLastArg(options::OPT__analyze) || DAL.getLastArg(options::OPT_emit_ast)) llvm::copy_if(PhaseList, std::back_inserter(P), |