<div dir="ltr">Looks like this broke a bunch of tests:<div><br></div><div><a href="http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37720/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aobject.cpp">http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37720/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aobject.cpp</a><br></div><div><a href="http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37720/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adriver-test.c">http://lab.llvm.org:8011/builders/clang-cuda-build/builds/37720/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adriver-test.c</a><br></div><div><br></div><div>If it takes a while to fix, please revert and investigate async.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 6:47 PM Puyan Lotfi via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: zer0<br>
Date: Wed Oct 2 15:50:07 2019<br>
New Revision: 373538<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=373538&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=373538&view=rev</a><br>
Log:<br>
[clang][ifs] Clang Interface Stubs ToolChain plumbing.<br>
<br>
This patch enables end to end support for generating ELF interface stubs<br>
directly from clang. Now the following:<br>
<br>
clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp<br>
<br>
will product an ELF binary with visible symbols populated. Visibility attributes<br>
and -fvisibility can be used to control what gets populated.<br>
<br>
* Adding ToolChain support for clang Driver IFS Merge Phase<br>
* Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain<br>
* Adds support for the clang Driver to involve llvm-ifs on ifs files.<br>
* Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file<br>
instead of the final object format (normally ELF)<br>
<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D63978" rel="noreferrer" target="_blank">https://reviews.llvm.org/D63978</a><br>
<br>
Added:<br>
cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp<br>
cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h<br>
cfe/trunk/test/InterfaceStubs/conflict-type.ifs<br>
cfe/trunk/test/InterfaceStubs/driver-test.c<br>
cfe/trunk/test/InterfaceStubs/func.ifs<br>
cfe/trunk/test/InterfaceStubs/merge-conflict-test.c<br>
cfe/trunk/test/InterfaceStubs/object-double.c<br>
cfe/trunk/test/InterfaceStubs/object-float.c<br>
cfe/trunk/test/InterfaceStubs/object.c<br>
cfe/trunk/test/InterfaceStubs/object.ifs<br>
Modified:<br>
cfe/trunk/include/clang/Driver/Action.h<br>
cfe/trunk/include/clang/Driver/Options.td<br>
cfe/trunk/include/clang/Driver/Phases.h<br>
cfe/trunk/include/clang/Driver/ToolChain.h<br>
cfe/trunk/include/clang/Driver/Types.def<br>
cfe/trunk/lib/Driver/Action.cpp<br>
cfe/trunk/lib/Driver/CMakeLists.txt<br>
cfe/trunk/lib/Driver/Driver.cpp<br>
cfe/trunk/lib/Driver/Phases.cpp<br>
cfe/trunk/lib/Driver/ToolChain.cpp<br>
cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
cfe/trunk/lib/Driver/Types.cpp<br>
cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
cfe/trunk/test/InterfaceStubs/bad-format.cpp<br>
cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp<br>
cfe/trunk/test/InterfaceStubs/externstatic.c<br>
cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp<br>
cfe/trunk/test/InterfaceStubs/inline.c<br>
cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp<br>
cfe/trunk/test/InterfaceStubs/weak.cpp<br>
cfe/trunk/test/<a href="http://lit.cfg.py" rel="noreferrer" target="_blank">lit.cfg.py</a><br>
<br>
Modified: cfe/trunk/include/clang/Driver/Action.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Action.h (original)<br>
+++ cfe/trunk/include/clang/Driver/Action.h Wed Oct 2 15:50:07 2019<br>
@@ -65,6 +65,7 @@ public:<br>
BackendJobClass,<br>
AssembleJobClass,<br>
LinkJobClass,<br>
+ IfsMergeJobClass,<br>
LipoJobClass,<br>
DsymutilJobClass,<br>
VerifyDebugInfoJobClass,<br>
@@ -485,6 +486,17 @@ public:<br>
}<br>
};<br>
<br>
+class IfsMergeJobAction : public JobAction {<br>
+ void anchor() override;<br>
+<br>
+public:<br>
+ IfsMergeJobAction(ActionList &Inputs, types::ID Type);<br>
+<br>
+ static bool classof(const Action *A) {<br>
+ return A->getKind() == IfsMergeJobClass;<br>
+ }<br>
+};<br>
+<br>
class LinkJobAction : public JobAction {<br>
void anchor() override;<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/Options.td Wed Oct 2 15:50:07 2019<br>
@@ -633,6 +633,9 @@ def emit_llvm : Flag<["-"], "emit-llvm"><br>
HelpText<"Use the LLVM representation for assembler and object files">;<br>
def emit_iterface_stubs : Flag<["-"], "emit-interface-stubs">, Flags<[CC1Option]>, Group<Action_Group>,<br>
HelpText<"Generate Inteface Stub Files.">;<br>
+def emit_merged_ifs : Flag<["-"], "emit-merged-ifs">,<br>
+ Flags<[CC1Option]>, Group<Action_Group>,<br>
+ HelpText<"Generate Interface Stub Files, emit merged text not binary.">;<br>
def iterface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Flags<[CC1Option]>;<br>
def exported__symbols__list : Separate<["-"], "exported_symbols_list">;<br>
def e : JoinedOrSeparate<["-"], "e">, Group<Link_Group>;<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Phases.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Phases.h?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Phases.h?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Phases.h (original)<br>
+++ cfe/trunk/include/clang/Driver/Phases.h Wed Oct 2 15:50:07 2019<br>
@@ -20,7 +20,8 @@ namespace phases {<br>
Compile,<br>
Backend,<br>
Assemble,<br>
- Link<br>
+ Link,<br>
+ IfsMerge,<br>
};<br>
<br>
enum {<br>
<br>
Modified: cfe/trunk/include/clang/Driver/ToolChain.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)<br>
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Oct 2 15:50:07 2019<br>
@@ -136,11 +136,13 @@ private:<br>
mutable std::unique_ptr<Tool> Clang;<br>
mutable std::unique_ptr<Tool> Assemble;<br>
mutable std::unique_ptr<Tool> Link;<br>
+ mutable std::unique_ptr<Tool> IfsMerge;<br>
mutable std::unique_ptr<Tool> OffloadBundler;<br>
<br>
Tool *getClang() const;<br>
Tool *getAssemble() const;<br>
Tool *getLink() const;<br>
+ Tool *getIfsMerge() const;<br>
Tool *getClangAs() const;<br>
Tool *getOffloadBundler() const;<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Types.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Types.def (original)<br>
+++ cfe/trunk/include/clang/Driver/Types.def Wed Oct 2 15:50:07 2019<br>
@@ -84,7 +84,8 @@ TYPE("lto-bc", LTO_BC,<br>
<br>
// Misc.<br>
TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link)<br>
-TYPE("ifs", IFS, INVALID, "ifs", phases::Compile, phases::Backend, phases::Assemble, phases::Link)<br>
+TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge)<br>
+TYPE("ifs-cpp", IFS_CPP, INVALID, "ifs", phases::Compile, phases::IfsMerge)<br>
TYPE("pcm", ModuleFile, INVALID, "pcm", phases::Compile, phases::Backend, phases::Assemble, phases::Link)<br>
TYPE("plist", Plist, INVALID, "plist", phases::Compile, phases::Backend, phases::Assemble, phases::Link)<br>
TYPE("rewritten-objc", RewrittenObjC,INVALID, "cpp", phases::Compile, phases::Backend, phases::Assemble, phases::Link)<br>
<br>
Modified: cfe/trunk/lib/Driver/Action.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Action.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Action.cpp Wed Oct 2 15:50:07 2019<br>
@@ -31,6 +31,7 @@ const char *Action::getClassName(ActionC<br>
case CompileJobClass: return "compiler";<br>
case BackendJobClass: return "backend";<br>
case AssembleJobClass: return "assembler";<br>
+ case IfsMergeJobClass: return "interface-stub-merger";<br>
case LinkJobClass: return "linker";<br>
case LipoJobClass: return "lipo";<br>
case DsymutilJobClass: return "dsymutil";<br>
@@ -357,6 +358,11 @@ void AssembleJobAction::anchor() {}<br>
AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)<br>
: JobAction(AssembleJobClass, Input, OutputType) {}<br>
<br>
+void IfsMergeJobAction::anchor() {}<br>
+<br>
+IfsMergeJobAction::IfsMergeJobAction(ActionList &Inputs, types::ID Type)<br>
+ : JobAction(IfsMergeJobClass, Inputs, Type) {}<br>
+<br>
void LinkJobAction::anchor() {}<br>
<br>
LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)<br>
<br>
Modified: cfe/trunk/lib/Driver/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/CMakeLists.txt (original)<br>
+++ cfe/trunk/lib/Driver/CMakeLists.txt Wed Oct 2 15:50:07 2019<br>
@@ -66,6 +66,7 @@ add_clang_library(clangDriver<br>
ToolChains/WebAssembly.cpp<br>
ToolChains/XCore.cpp<br>
ToolChains/PPCLinux.cpp<br>
+ ToolChains/InterfaceStubs.cpp<br>
Types.cpp<br>
XRayArgs.cpp<br>
<br>
<br>
Modified: cfe/trunk/lib/Driver/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Driver.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 2 15:50:07 2019<br>
@@ -274,11 +274,11 @@ phases::ID Driver::getFinalPhase(const D<br>
(PhaseArg = DAL.getLastArg(options::OPT__SLASH_P))) {<br>
FinalPhase = phases::Preprocess;<br>
<br>
- // --precompile only runs up to precompilation.<br>
+ // --precompile only runs up to precompilation.<br>
} else if ((PhaseArg = DAL.getLastArg(options::OPT__precompile))) {<br>
FinalPhase = phases::Precompile;<br>
<br>
- // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.<br>
+ // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.<br>
} else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) ||<br>
@@ -286,20 +286,23 @@ phases::ID Driver::getFinalPhase(const D<br>
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||<br>
- (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT__analyze)) ||<br>
(PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {<br>
FinalPhase = phases::Compile;<br>
<br>
- // -S only runs up to the backend.<br>
+ // clang interface stubs<br>
+ } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs))) {<br>
+ FinalPhase = phases::IfsMerge;<br>
+<br>
+ // -S only runs up to the backend.<br>
} else if ((PhaseArg = DAL.getLastArg(options::OPT_S))) {<br>
FinalPhase = phases::Backend;<br>
<br>
- // -c compilation only runs up to the assembler.<br>
+ // -c compilation only runs up to the assembler.<br>
} else if ((PhaseArg = DAL.getLastArg(options::OPT_c))) {<br>
FinalPhase = phases::Assemble;<br>
<br>
- // Otherwise do everything.<br>
+ // Otherwise do everything.<br>
} else<br>
FinalPhase = phases::Link;<br>
<br>
@@ -3323,6 +3326,7 @@ void Driver::BuildActions(Compilation &C<br>
// Construct the actions to perform.<br>
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr;<br>
ActionList LinkerInputs;<br>
+ ActionList MergerInputs;<br>
<br>
for (auto &I : Inputs) {<br>
types::ID InputType = I.first;<br>
@@ -3360,6 +3364,17 @@ void Driver::BuildActions(Compilation &C<br>
break;<br>
}<br>
<br>
+ // TODO: Consider removing this because the merged may not end up being<br>
+ // the final Phase in the pipeline. Perhaps the merged could just merge<br>
+ // and then pass an artifact of some sort to the Link Phase.<br>
+ // Queue merger inputs.<br>
+ if (Phase == phases::IfsMerge) {<br>
+ assert(Phase == PL.back() && "merging must be final compilation step.");<br>
+ MergerInputs.push_back(Current);<br>
+ Current = nullptr;<br>
+ break;<br>
+ }<br>
+<br>
// Each precompiled header file after a module file action is a module<br>
// header of that same module file, rather than being compiled to a<br>
// separate PCH.<br>
@@ -3409,6 +3424,11 @@ void Driver::BuildActions(Compilation &C<br>
Actions.push_back(LA);<br>
}<br>
<br>
+ // Add an interface stubs merge action if necessary.<br>
+ if (!MergerInputs.empty())<br>
+ Actions.push_back(<br>
+ C.MakeAction<IfsMergeJobAction>(MergerInputs, types::TY_Image));<br>
+<br>
// If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a custom<br>
// Compile phase that prints out supported cpu models and quits.<br>
if (Arg *A = Args.getLastArg(options::OPT_print_supported_cpus)) {<br>
@@ -3445,6 +3465,8 @@ Action *Driver::ConstructPhaseAction(<br>
switch (Phase) {<br>
case phases::Link:<br>
llvm_unreachable("link action invalid here.");<br>
+ case phases::IfsMerge:<br>
+ llvm_unreachable("ifsmerge action invalid here.");<br>
case phases::Preprocess: {<br>
types::ID OutputTy;<br>
// -M and -MM specify the dependency file name by altering the output type,<br>
@@ -3509,7 +3531,7 @@ Action *Driver::ConstructPhaseAction(<br>
if (Args.hasArg(options::OPT_verify_pch))<br>
return C.MakeAction<VerifyPCHJobAction>(Input, types::TY_Nothing);<br>
if (Args.hasArg(options::OPT_emit_iterface_stubs))<br>
- return C.MakeAction<CompileJobAction>(Input, types::TY_IFS);<br>
+ return C.MakeAction<CompileJobAction>(Input, types::TY_IFS_CPP);<br>
return C.MakeAction<CompileJobAction>(Input, types::TY_LLVM_BC);<br>
}<br>
case phases::Backend: {<br>
<br>
Modified: cfe/trunk/lib/Driver/Phases.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Phases.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Phases.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Phases.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Phases.cpp Wed Oct 2 15:50:07 2019<br>
@@ -20,6 +20,7 @@ const char *phases::getPhaseName(ID Id)<br>
case Backend: return "backend";<br>
case Assemble: return "assembler";<br>
case Link: return "linker";<br>
+ case IfsMerge: return "ifsmerger";<br>
}<br>
<br>
llvm_unreachable("Invalid phase id.");<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChain.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Oct 2 15:50:07 2019<br>
@@ -10,6 +10,7 @@<br>
#include "InputInfo.h"<br>
#include "ToolChains/Arch/ARM.h"<br>
#include "ToolChains/Clang.h"<br>
+#include "ToolChains/InterfaceStubs.h"<br>
#include "clang/Basic/ObjCRuntime.h"<br>
#include "clang/Basic/Sanitizers.h"<br>
#include "clang/Config/config.h"<br>
@@ -279,6 +280,12 @@ Tool *ToolChain::getLink() const {<br>
return Link.get();<br>
}<br>
<br>
+Tool *ToolChain::getIfsMerge() const {<br>
+ if (!IfsMerge)<br>
+ IfsMerge.reset(new tools::ifstool::Merger(*this));<br>
+ return IfsMerge.get();<br>
+}<br>
+<br>
Tool *ToolChain::getOffloadBundler() const {<br>
if (!OffloadBundler)<br>
OffloadBundler.reset(new tools::OffloadBundler(*this));<br>
@@ -290,6 +297,9 @@ Tool *ToolChain::getTool(Action::ActionC<br>
case Action::AssembleJobClass:<br>
return getAssemble();<br>
<br>
+ case Action::IfsMergeJobClass:<br>
+ return getIfsMerge();<br>
+<br>
case Action::LinkJobClass:<br>
return getLink();<br>
<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Oct 2 15:50:07 2019<br>
@@ -3683,32 +3683,15 @@ void Clang::ConstructJob(Compilation &C,<br>
} else if (JA.getType() == types::TY_LLVM_BC ||<br>
JA.getType() == types::TY_LTO_BC) {<br>
CmdArgs.push_back("-emit-llvm-bc");<br>
- } else if (JA.getType() == types::TY_IFS) {<br>
+ } else if (JA.getType() == types::TY_IFS ||<br>
+ JA.getType() == types::TY_IFS_CPP) {<br>
StringRef ArgStr =<br>
Args.hasArg(options::OPT_iterface_stub_version_EQ)<br>
? Args.getLastArgValue(options::OPT_iterface_stub_version_EQ)<br>
- : "";<br>
- StringRef StubFormat =<br>
- llvm::StringSwitch<StringRef>(ArgStr)<br>
- .Case("experimental-ifs-v1", "experimental-ifs-v1")<br>
- .Default("");<br>
-<br>
- if (StubFormat.empty()) {<br>
- std::string ErrorMessage =<br>
- "Invalid interface stub format: " + ArgStr.str() +<br>
- ((ArgStr == "experimental-yaml-elf-v1" ||<br>
- ArgStr == "experimental-tapi-elf-v1")<br>
- ? " is deprecated."<br>
- : ".");<br>
- D.Diag(diag::err_drv_invalid_value)<br>
- << "Must specify a valid interface stub format type, ie: "<br>
- "-interface-stub-version=experimental-ifs-v1"<br>
- << ErrorMessage;<br>
- }<br>
-<br>
+ : "experimental-ifs-v1";<br>
CmdArgs.push_back("-emit-interface-stubs");<br>
CmdArgs.push_back(<br>
- Args.MakeArgString(Twine("-interface-stub-version=") + StubFormat));<br>
+ Args.MakeArgString(Twine("-interface-stub-version=") + ArgStr.str()));<br>
} else if (JA.getType() == types::TY_PP_Asm) {<br>
CmdArgs.push_back("-S");<br>
} else if (JA.getType() == types::TY_AST) {<br>
<br>
Added: cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp (added)<br>
+++ cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.cpp Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,37 @@<br>
+//===--- InterfaceStubs.cpp - Base InterfaceStubs Implementations C++ ---===//<br>
+//<br>
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
+// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "InterfaceStubs.h"<br>
+#include "CommonArgs.h"<br>
+#include "clang/Driver/Compilation.h"<br>
+<br>
+namespace clang {<br>
+namespace driver {<br>
+namespace tools {<br>
+namespace ifstool {<br>
+void Merger::ConstructJob(Compilation &C, const JobAction &JA,<br>
+ const InputInfo &Output, const InputInfoList &Inputs,<br>
+ const llvm::opt::ArgList &Args,<br>
+ const char *LinkingOutput) const {<br>
+ std::string Merger = getToolChain().GetProgramPath(getShortName());<br>
+ llvm::opt::ArgStringList CmdArgs;<br>
+ CmdArgs.push_back("-action");<br>
+ CmdArgs.push_back(Args.getLastArg(options::OPT_emit_merged_ifs)<br>
+ ? "write-ifs"<br>
+ : "write-bin");<br>
+ CmdArgs.push_back("-o");<br>
+ CmdArgs.push_back(Output.getFilename());<br>
+ for (const auto &Input : Inputs)<br>
+ CmdArgs.push_back(Input.getFilename());<br>
+ C.addCommand(std::make_unique<Command>(JA, *this, Args.MakeArgString(Merger),<br>
+ CmdArgs, Inputs));<br>
+}<br>
+} // namespace ifstool<br>
+} // namespace tools<br>
+} // namespace driver<br>
+} // namespace clang<br>
<br>
Added: cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h (added)<br>
+++ cfe/trunk/lib/Driver/ToolChains/InterfaceStubs.h Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,36 @@<br>
+//===--- InterfaceStubs.cpp - Base InterfaceStubs Implementations C++ ---===//<br>
+//<br>
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
+// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_IFS_H<br>
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_IFS_H<br>
+<br>
+#include "clang/Driver/Tool.h"<br>
+#include "clang/Driver/ToolChain.h"<br>
+<br>
+namespace clang {<br>
+namespace driver {<br>
+namespace tools {<br>
+namespace ifstool {<br>
+class LLVM_LIBRARY_VISIBILITY Merger : public Tool {<br>
+public:<br>
+ Merger(const ToolChain &TC) : Tool("IFS::Merger", "llvm-ifs", TC) {}<br>
+<br>
+ bool hasIntegratedCPP() const override { return false; }<br>
+ bool isLinkJob() const override { return false; }<br>
+<br>
+ void ConstructJob(Compilation &C, const JobAction &JA,<br>
+ const InputInfo &Output, const InputInfoList &Inputs,<br>
+ const llvm::opt::ArgList &TCArgs,<br>
+ const char *LinkingOutput) const override;<br>
+};<br>
+} // end namespace ifstool<br>
+} // end namespace tools<br>
+} // end namespace driver<br>
+} // end namespace clang<br>
+<br>
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_IFS_H<br>
<br>
Modified: cfe/trunk/lib/Driver/Types.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Types.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Types.cpp Wed Oct 2 15:50:07 2019<br>
@@ -269,6 +269,7 @@ types::ID types::lookupTypeForExtension(<br>
.Case("lib", TY_Object)<br>
.Case("mii", TY_PP_ObjCXX)<br>
.Case("obj", TY_Object)<br>
+ .Case("ifs", TY_IFS)<br>
.Case("pch", TY_PCH)<br>
.Case("pcm", TY_ModuleFile)<br>
.Case("c++m", TY_CXXModule)<br>
@@ -319,6 +320,22 @@ void types::getCompilationPhases(const c<br>
llvm::copy_if(PhaseList, std::back_inserter(P),<br>
[](phases::ID Phase) { return Phase <= phases::Precompile; });<br>
<br>
+ // Treat Interface Stubs like its own compilation mode.<br>
+ else if (DAL.getLastArg(options::OPT_emit_iterface_stubs)) {<br>
+ llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> IfsModePhaseList;<br>
+ llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> &PL = PhaseList;<br>
+ phases::ID LastPhase = phases::IfsMerge;<br>
+ if (Id != types::TY_IFS) {<br>
+ if (DAL.hasArg(options::OPT_c))<br>
+ LastPhase = phases::Compile;<br>
+ PL = IfsModePhaseList;<br>
+ types::getCompilationPhases(types::TY_IFS_CPP, PL);<br>
+ }<br>
+ llvm::copy_if(PL, std::back_inserter(P), [&](phases::ID Phase) {<br>
+ return Phase <= LastPhase;<br>
+ });<br>
+ }<br>
+<br>
// -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.<br>
else if (DAL.getLastArg(options::OPT_fsyntax_only) ||<br>
DAL.getLastArg(options::OPT_print_supported_cpus) ||<br>
@@ -327,7 +344,6 @@ void types::getCompilationPhases(const c<br>
DAL.getLastArg(options::OPT_rewrite_objc) ||<br>
DAL.getLastArg(options::OPT_rewrite_legacy_objc) ||<br>
DAL.getLastArg(options::OPT__migrate) ||<br>
- DAL.getLastArg(options::OPT_emit_iterface_stubs) ||<br>
DAL.getLastArg(options::OPT__analyze) ||<br>
DAL.getLastArg(options::OPT_emit_ast))<br>
llvm::copy_if(PhaseList, std::back_inserter(P),<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1734,24 +1734,25 @@ static InputKind ParseFrontendArgs(Front<br>
StringRef ArgStr =<br>
Args.hasArg(OPT_iterface_stub_version_EQ)<br>
? Args.getLastArgValue(OPT_iterface_stub_version_EQ)<br>
- : "";<br>
- llvm::Optional<frontend::ActionKind> ProgramAction =<br>
- llvm::StringSwitch<llvm::Optional<frontend::ActionKind>>(ArgStr)<br>
- .Case("experimental-ifs-v1", frontend::GenerateInterfaceIfsExpV1)<br>
- .Default(llvm::None);<br>
- if (!ProgramAction) {<br>
+ : "experimental-ifs-v1";<br>
+ if (ArgStr == "experimental-yaml-elf-v1" ||<br>
+ ArgStr == "experimental-tapi-elf-v1") {<br>
std::string ErrorMessage =<br>
"Invalid interface stub format: " + ArgStr.str() +<br>
- ((ArgStr == "experimental-yaml-elf-v1" ||<br>
- ArgStr == "experimental-tapi-elf-v1")<br>
- ? " is deprecated."<br>
- : ".");<br>
+ " is deprecated.";<br>
+ Diags.Report(diag::err_drv_invalid_value)<br>
+ << "Must specify a valid interface stub format type, ie: "<br>
+ "-interface-stub-version=experimental-ifs-v1"<br>
+ << ErrorMessage;<br>
+ } else if (ArgStr != "experimental-ifs-v1") {<br>
+ std::string ErrorMessage =<br>
+ "Invalid interface stub format: " + ArgStr.str() + ".";<br>
Diags.Report(diag::err_drv_invalid_value)<br>
<< "Must specify a valid interface stub format type, ie: "<br>
"-interface-stub-version=experimental-ifs-v1"<br>
<< ErrorMessage;<br>
} else {<br>
- Opts.ProgramAction = *ProgramAction;<br>
+ Opts.ProgramAction = frontend::GenerateInterfaceIfsExpV1;<br>
}<br>
break;<br>
}<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/bad-format.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/bad-format.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/bad-format.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/bad-format.cpp (original)<br>
+++ cfe/trunk/test/InterfaceStubs/bad-format.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1,28 +1,25 @@<br>
-// REQUIRES: x86-registered-target<br>
-// RUN: not %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=bar-format %s 2>&1 | FileCheck %s<br>
+// RUN: not %clang -emit-interface-stubs -interface-stub-version=bad-format %s 2>&1 | \<br>
+// RUN: FileCheck %s<br>
<br>
-// RUN: not %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s 2>&1 | \<br>
+// RUN: not %clang -emit-interface-stubs -interface-stub-version=experimental-tapi-elf-v1 %s 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-TAPI-DEPRECATED %s<br>
<br>
-// RUN: not %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s 2>&1 | \<br>
+// RUN: not %clang -emit-interface-stubs -interface-stub-version=experimental-yaml-elf-v1 %s 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-YAML-DEPRECATED %s<br>
<br>
-// RUN: not %clang_cc1 -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=bar-format %s 2>&1 | FileCheck %s<br>
+// RUN: not %clang -emit-interface-stubs -interface-stub-version=bad-format %s 2>&1 | \<br>
+// RUN: FileCheck %s<br>
<br>
-// RUN: not %clang_cc1 -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: not %clang -emit-interface-stubs \<br>
// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-TAPI-DEPRECATED %s<br>
<br>
-// RUN: not %clang_cc1 -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: not %clang -emit-interface-stubs \<br>
// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-YAML-DEPRECATED %s<br>
<br>
// CHECK: error: invalid value<br>
-// CHECK: 'Invalid interface stub format: bar-format.' in 'Must specify a<br>
+// CHECK: 'Invalid interface stub format: bad-format.' in 'Must specify a<br>
// CHECK: valid interface stub format type, ie:<br>
// CHECK: -interface-stub-version=experimental-ifs-v1'<br>
<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp (original)<br>
+++ cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1,9 +1,9 @@<br>
// REQUIRES: x86-registered-target<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-TAPI %s<br>
<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-TAPI2 %s<br>
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/conflict-type.ifs<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/conflict-type.ifs?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/conflict-type.ifs?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/conflict-type.ifs (added)<br>
+++ cfe/trunk/test/InterfaceStubs/conflict-type.ifs Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,16 @@<br>
+# RUN: not %clang -emit-merged-ifs -emit-interface-stubs -o - %s %S/func.ifs 2>&1 | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-IFS<br>
+<br>
+# Here we are testing to see if two symbols with identical names will fail to<br>
+# merge in conflict due to mismatched types.<br>
+# CHECK-IFS: error: Interface Stub: Type Mismatch for a.<br>
+# CHECK-IFS-NEXT: Filename:<br>
+# CHECK-IFS-NEXT: Type Values: Object Func<br>
+<br>
+--- !experimental-ifs-v1<br>
+IfsVersion: 1.0<br>
+Triple: x86_64-linux-gnu<br>
+ObjectFileFormat: ELF<br>
+Symbols:<br>
+ a: { Type: Object, Size: 1 }<br>
+...<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/driver-test.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/driver-test.c?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/driver-test.c?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/driver-test.c (added)<br>
+++ cfe/trunk/test/InterfaceStubs/driver-test.c Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,12 @@<br>
+// RUN: %clang -x c -o libfoo.so -emit-interface-stubs %s %S/object.c %S/weak.cpp && \<br>
+// RUN: llvm-nm libfoo.so 2>&1 | FileCheck %s<br>
+<br>
+// RUN: %clang -x c -o libfoo.so -shared %s %S/object.c %S/weak.cpp && \<br>
+// RUN: llvm-nm libfoo.so 2>&1 | FileCheck %s<br>
+<br>
+// CHECK-DAG: data<br>
+// CHECK-DAG: foo<br>
+// CHECK-DAG: strongFunc<br>
+// CHECK-DAG: weakFunc<br>
+<br>
+int foo(int bar) { return 42 + 1844; }<br>
\ No newline at end of file<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/externstatic.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/externstatic.c?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/externstatic.c?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/externstatic.c (original)<br>
+++ cfe/trunk/test/InterfaceStubs/externstatic.c Wed Oct 2 15:50:07 2019<br>
@@ -1,24 +1,20 @@<br>
-// REQUIRES: x86-registered-target<br>
-// RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DSTORAGE="extern" -o - -emit-interface-stubs -std=c99 -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-EXTERN %s<br>
-// RUN: %clang -DSTORAGE="extern" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \<br>
+<br>
+// RUN: %clang -DSTORAGE="extern" -O0 -o - -c -std=c99 \<br>
// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-EXTERN %s<br>
<br>
-// RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DSTORAGE="extern" -o - -emit-interface-stubs -std=c99 -xc %s | \<br>
+// RUN: FileCheck -check-prefix=CHECK-EXTERN2 %s<br>
+<br>
+// RUN: %clang -DSTORAGE="extern" -O0 -o - -c -std=c99 -xc %s | llvm-nm - 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-EXTERN2 %s<br>
-// RUN: %clang -DSTORAGE="extern" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \<br>
-// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-EXTERN2 %s<br>
<br>
-// RUN: %clang -DSTORAGE="static" -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DSTORAGE="static" -o - -emit-interface-stubs -std=c99 -xc %s | \<br>
+// RUN: FileCheck -check-prefix=CHECK-STATIC %s<br>
+<br>
+// RUN: %clang -DSTORAGE="static" -O0 -o - -c -std=c99 -xc %s | llvm-nm - 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-STATIC %s<br>
-// RUN: %clang -DSTORAGE="static" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \<br>
-// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-STATIC %s<br>
<br>
// CHECK-EXTERN-NOT: foo<br>
// CHECK-STATIC-NOT: foo<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/func.ifs<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/func.ifs?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/func.ifs?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/func.ifs (added)<br>
+++ cfe/trunk/test/InterfaceStubs/func.ifs Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,40 @@<br>
+# RUN: %clang -emit-interface-stubs -o - %s %S/object.ifs -emit-merged-ifs | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-IFS<br>
+<br>
+# RUN: %clang -emit-interface-stubs -o - %s %S/object.ifs | llvm-readelf --all | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-ELF<br>
+<br>
+# RUN: %clang -emit-interface-stubs -o - %s %s -emit-merged-ifs | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS<br>
+<br>
+# CHECK-IFS: --- !experimental-ifs-v1<br>
+# CHECK-IFS-NEXT: IfsVersion: 1.0<br>
+# CHECK-IFS-NEXT: Triple: x86_64-linux-gnu<br>
+# CHECK-IFS-NEXT: ObjectFileFormat: ELF<br>
+# CHECK-IFS-NEXT: Symbols:<br>
+# CHECK-IFS-DAG: a: { Type: Func }<br>
+# CHECK-IFS-DAG: b: { Type: Object, Size: 4 }<br>
+# CHECK-IFS: ...<br>
+<br>
+# CHECK-ELF: ELF Header:<br>
+# CHECK-ELF: Class: ELF64<br>
+# CHECK-ELF: Type: DYN (Shared object file)<br>
+# CHECK-ELF: FUNC GLOBAL DEFAULT 1 a<br>
+# CHECK-ELF: OBJECT GLOBAL DEFAULT 1 b<br>
+<br>
+# Here we are testing to see if two identical symbols will merge.<br>
+# CHECK-MERGE-IFS: --- !experimental-ifs-v1<br>
+# CHECK-MERGE-IFS-NEXT: IfsVersion: 1.0<br>
+# CHECK-MERGE-IFS-NEXT: Triple: x86_64-linux-gnu<br>
+# CHECK-MERGE-IFS-NEXT: ObjectFileFormat: ELF<br>
+# CHECK-MERGE-IFS-NEXT: Symbols:<br>
+# CHECK-MERGE-IFS-NEXT: a: { Type: Func }<br>
+# CHECK-MERGE-IFS-NEXT: ...<br>
+<br>
+--- !experimental-ifs-v1<br>
+IfsVersion: 1.0<br>
+Triple: x86_64-linux-gnu<br>
+ObjectFileFormat: ELF<br>
+Symbols:<br>
+ a: { Type: Func }<br>
+...<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp (original)<br>
+++ cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1,13 +1,15 @@<br>
// REQUIRES: x86-registered-target<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+<br>
+// TODO: Fix the case in llvm-ifs where it crashes on an empty Symbols list.<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -c \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 %s | FileCheck %s<br>
<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 \<br>
// RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s<br>
<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 \<br>
// RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/inline.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/inline.c?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/inline.c?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/inline.c (original)<br>
+++ cfe/trunk/test/InterfaceStubs/inline.c Wed Oct 2 15:50:07 2019<br>
@@ -1,37 +1,32 @@<br>
// REQUIRES: x86-registered-target<br>
-// RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=gnu89 -xc %s | \<br>
+// RUN: %clang -c -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \<br>
+// RUN: -emit-interface-stubs -std=gnu89 -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-GNU %s<br>
// RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c \<br>
// RUN: -std=gnu89 -xc %s | llvm-nm - | FileCheck -check-prefix=CHECK-GNU %s<br>
<br>
-// RUN: %clang -DINLINE="__attribute__((always_inline))" \<br>
-// RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -xc %s | \<br>
+// RUN: %clang -c -DINLINE="__attribute__((always_inline))" \<br>
+// RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-GNU %s<br>
// RUN: %clang -DINLINE="__attribute__((always_inline))" \<br>
// RUN: -target x86_64-linux-gnu -O0 -o - -c -xc %s | \<br>
// RUN: llvm-nm - | FileCheck -check-prefix=CHECK-GNU %s<br>
<br>
-// RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \<br>
+// RUN: -emit-interface-stubs -std=c99 -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-STD %s<br>
// RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c -std=c99 \<br>
// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-STD %s<br>
<br>
-// RUN: %clang -DINLINE="__attribute__((noinline))" \<br>
-// RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DINLINE="__attribute__((noinline))" \<br>
+// RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -std=c99 -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-NOINLINE %s<br>
// RUN: %clang -DINLINE="__attribute__((noinline))" -target x86_64-linux-gnu \<br>
// RUN: -O0 -o - -c -std=c99 -xc %s | llvm-nm - 2>&1 | \<br>
// RUN: FileCheck -check-prefix=CHECK-NOINLINE %s<br>
<br>
-// RUN: %clang -DINLINE="static" -target x86_64-unknown-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs \<br>
-// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \<br>
+// RUN: %clang -c -DINLINE="static" -target x86_64-unknown-linux-gnu -o - \<br>
+// RUN: -emit-interface-stubs -std=c99 -xc %s | \<br>
// RUN: FileCheck -check-prefix=CHECK-STATIC %s<br>
// RUN: %clang -DINLINE="static" -target x86_64-linux-gnu -O0 -o - -c \<br>
// RUN: -std=c99 -xc %s | llvm-nm - 2>&1 | \<br>
@@ -50,12 +45,12 @@ INLINE int foo() {<br>
return var;<br>
}<br>
<br>
-// RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \<br>
+// RUN: %clang -c -DINLINE=inline -target x86_64-linux-gnu -o - \<br>
+// RUN: -emit-interface-stubs \<br>
// RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-TAPI %s<br>
<br>
-// RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \<br>
-// RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \<br>
+// RUN: %clang -c -DINLINE=inline -target x86_64-linux-gnu -o - \<br>
+// RUN: -emit-interface-stubs \<br>
// RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-SYMBOLS %s<br>
// RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \<br>
// RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/merge-conflict-test.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/merge-conflict-test.c?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/merge-conflict-test.c?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/merge-conflict-test.c (added)<br>
+++ cfe/trunk/test/InterfaceStubs/merge-conflict-test.c Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,3 @@<br>
+// RUN: not %clang -o libfoo.so -emit-interface-stubs %s %S/driver-test.c 2>&1 | FileCheck %s<br>
+// CHECK: error: Interface Stub: Type Mismatch<br>
+int foo;<br>
\ No newline at end of file<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/object-double.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object-double.c?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object-double.c?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/object-double.c (added)<br>
+++ cfe/trunk/test/InterfaceStubs/object-double.c Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,5 @@<br>
+// RUN: not %clang -o - -emit-interface-stubs %s %S/object.c 2>&1 | FileCheck %s<br>
+// Need to encode more type info or weak vs strong symbol resolution in llvm-ifs<br>
+// XFAIL: *<br>
+// CHECK: error: Interface Stub: Size Mismatch<br>
+float data = 42.0;<br>
\ No newline at end of file<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/object-float.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object-float.c?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object-float.c?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/object-float.c (added)<br>
+++ cfe/trunk/test/InterfaceStubs/object-float.c Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,3 @@<br>
+// RUN: not %clang -o - -emit-interface-stubs %s %S/object.c 2>&1 | FileCheck %s<br>
+// CHECK: error: Interface Stub: Size Mismatch<br>
+double data = 42.0;<br>
\ No newline at end of file<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/object.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object.c?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object.c?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/object.c (added)<br>
+++ cfe/trunk/test/InterfaceStubs/object.c Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,7 @@<br>
+// RUN: %clang -c -o - -emit-interface-stubs %s | FileCheck -check-prefix=CHECK-TAPI %s<br>
+// RUN: %clang -c -o - -emit-interface-stubs %s | FileCheck -check-prefix=CHECK-SYMBOLS %s<br>
+// RUN: %clang -c -o - %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s<br>
+<br>
+// CHECK-TAPI: data: { Type: Object, Size: 4 }<br>
+// CHECK-SYMBOLS: data<br>
+int data = 42;<br>
<br>
Added: cfe/trunk/test/InterfaceStubs/object.ifs<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object.ifs?rev=373538&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/object.ifs?rev=373538&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/object.ifs (added)<br>
+++ cfe/trunk/test/InterfaceStubs/object.ifs Wed Oct 2 15:50:07 2019<br>
@@ -0,0 +1,28 @@<br>
+# RUN: %clang -emit-interface-stubs -o - -emit-merged-ifs %s | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-IFS<br>
+<br>
+# RUN: %clang -emit-interface-stubs -o - %s | llvm-readelf --all | \<br>
+# RUN: FileCheck %s --check-prefixes=CHECK-ELF<br>
+<br>
+# CHECK-IFS: --- !experimental-ifs-v1<br>
+# CHECK-IFS-NEXT: IfsVersion: 1.0<br>
+# CHECK-IFS-NEXT: Triple: x86_64-linux-gnu<br>
+# CHECK-IFS-NEXT: ObjectFileFormat: ELF<br>
+# CHECK-IFS-NEXT: Symbols:<br>
+# CHECK-IFS-NEXT: b: { Type: Object, Size: 4 }<br>
+# CHECK-IFS-NEXT: ...<br>
+<br>
+# CHECK-ELF: ELF Header:<br>
+# CHECK-ELF: Class: ELF64<br>
+# CHECK-ELF: Data: 2's complement, little endian<br>
+# CHECK-ELF: Type: DYN (Shared object file)<br>
+# CHECK-ELF-NOT: FUNC GLOBAL DEFAULT 1 a<br>
+# CHECK-ELF: OBJECT GLOBAL DEFAULT 1 b<br>
+<br>
+--- !experimental-ifs-v1<br>
+IfsVersion: 1.0<br>
+Triple: x86_64-linux-gnu<br>
+ObjectFileFormat: ELF<br>
+Symbols:<br>
+ b: { Type: Object, Size: 4 }<br>
+...<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp (original)<br>
+++ cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1,5 +1,5 @@<br>
// REQUIRES: x86-registered-target<br>
-// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \<br>
// RUN: FileCheck %s<br>
<br>
<br>
Modified: cfe/trunk/test/InterfaceStubs/weak.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/weak.cpp?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/weak.cpp?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/InterfaceStubs/weak.cpp (original)<br>
+++ cfe/trunk/test/InterfaceStubs/weak.cpp Wed Oct 2 15:50:07 2019<br>
@@ -1,5 +1,5 @@<br>
// REQUIRES: x86-registered-target<br>
-// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \<br>
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \<br>
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \<br>
// RUN: FileCheck %s<br>
<br>
<br>
Modified: cfe/trunk/test/<a href="http://lit.cfg.py" rel="noreferrer" target="_blank">lit.cfg.py</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=373538&r1=373537&r2=373538&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=373538&r1=373537&r2=373538&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/<a href="http://lit.cfg.py" rel="noreferrer" target="_blank">lit.cfg.py</a> (original)<br>
+++ cfe/trunk/test/<a href="http://lit.cfg.py" rel="noreferrer" target="_blank">lit.cfg.py</a> Wed Oct 2 15:50:07 2019<br>
@@ -26,7 +26,7 @@ config.test_format = lit.formats.ShTest(<br>
<br>
# suffixes: A list of file extensions to treat as test files.<br>
config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu',<br>
- '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']<br>
+ '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']<br>
<br>
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'<br>
# subdirectories contain auxiliary inputs for various tests in their parent<br>
@@ -61,7 +61,7 @@ config.substitutions.append(('%PATH%', c<br>
tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]<br>
<br>
tools = [<br>
- 'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'opt',<br>
+ 'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'opt', 'llvm-ifs',<br>
ToolSubst('%clang_extdef_map', command=FindTool(<br>
'clang-extdef-mapping'), unresolved='ignore'),<br>
]<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>