diff options
| author | Vedant Kumar <vsk@apple.com> | 2017-09-12 19:15:31 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2017-09-12 19:15:31 +0000 |
| commit | 796a13fcde6b4ebd8d6fc1b9f00899f2a6d573c0 (patch) | |
| tree | 6ab61e7cb877c717d99f353e3b196fe94caceea6 /clang/lib/Driver/ToolChains/Darwin.h | |
| parent | c589f5f87559c5e32a5dbc3fadcb9257140ce72f (diff) | |
| download | bcm5719-llvm-796a13fcde6b4ebd8d6fc1b9f00899f2a6d573c0.tar.gz bcm5719-llvm-796a13fcde6b4ebd8d6fc1b9f00899f2a6d573c0.zip | |
[Driver] Darwin: Link in the profile runtime archive first
While building a project with code coverage enabled, we can link in
dependencies which export a weak definition of __llvm_profile_filename.
After r306710, linking in the profiling runtime could pull in a weak
definition of this symbol from a dependency, instead of from within the
runtime's archive.
This inconsistency causes issues during API verification, and is also a
practical problem (the symbol would go missing were the dependent dylib
to be switched out). Introduce a LinkFirst runtime link option to make
sure we always search the profiling runtime for this symbol first.
rdar://problem/33271080
Differential Revision: https://reviews.llvm.org/D35385
llvm-svn: 313065
Diffstat (limited to 'clang/lib/Driver/ToolChains/Darwin.h')
| -rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index db88ba07f40..3c6c740645c 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -152,6 +152,9 @@ public: llvm::opt::ArgStringList &CmdArgs) const {} /// Add the linker arguments to link the compiler runtime library. + /// + /// FIXME: This API is intended for use with embedded libraries only, and is + /// misleadingly named. virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; @@ -169,10 +172,26 @@ public: /// Is the target either iOS or an iOS simulator? bool isTargetIOSBased() const { return false; } + /// Options to control how a runtime library is linked. + enum RuntimeLinkOptions : unsigned { + // Link the library in even if it can't be found in the VFS. + RLO_AlwaysLink = 1 << 0, + + // Use the embedded runtime from the macho_embedded directory. + RLO_IsEmbedded = 1 << 1, + + // Emit rpaths for @executable_path as well as the resource directory. + RLO_AddRPath = 1 << 2, + + //< Link the library in before any others. + RLO_FirstLink = 1 << 3, + }; + + /// Add a runtime library to the list of items to link. void AddLinkRuntimeLib(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, - StringRef DarwinLibName, bool AlwaysLink = false, - bool IsEmbedded = false, bool AddRPath = false) const; + StringRef DarwinLibName, + RuntimeLinkOptions Opts = RuntimeLinkOptions()) const; /// Add any profiling runtime libraries that are needed. This is essentially a /// MachO specific version of addProfileRT in Tools.cpp. |

