Second Landing Attempt: 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 llvm-svn: 374061
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
// REQUIRES: x86-registered-target
|
|
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \
|
|
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
|
|
// RUN: FileCheck -check-prefix=CHECK-TAPI %s
|
|
|
|
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs -emit-merged-ifs \
|
|
// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
|
|
// RUN: FileCheck -check-prefix=CHECK-TAPI2 %s
|
|
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | \
|
|
// RUN: llvm-readelf -s - 2>&1 | \
|
|
// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
|
|
|
|
// For the following:
|
|
// g()
|
|
// n::S<int>::S()
|
|
// n::S<int>::~S()
|
|
// n::S<int>::func() const
|
|
// n::S<int>::S(n::S<int> const&)
|
|
|
|
// We expect these manglings:
|
|
// CHECK-TAPI: Symbols:
|
|
// CHECK-TAPI-NOT: _ZNK1n1SIiEclEv
|
|
// CHECK-TAPI2: Symbols:
|
|
// CHECK-TAPI2: _Z1g
|
|
|
|
// CHECK-SYMBOLS-DAG: FUNC GLOBAL DEFAULT {{[0-9]}} _Z1g
|
|
// CHECK-SYMBOLS-DAG: FUNC WEAK HIDDEN {{[0-9]}} _ZNK1n1SIiEclEv
|
|
|
|
namespace n {
|
|
template <typename T>
|
|
struct __attribute__((__visibility__("default"))) S {
|
|
S() = default;
|
|
~S() = default;
|
|
int __attribute__((__visibility__(("default")))) func() const {
|
|
return 1844;
|
|
}
|
|
int __attribute__((__visibility__(("hidden")))) operator()() const {
|
|
return 1863;
|
|
}
|
|
};
|
|
} // namespace n
|
|
|
|
void g() { n::S<int>()(); }
|