summaryrefslogtreecommitdiffstats
path: root/clang/test/InterfaceStubs/weak.cpp
diff options
context:
space:
mode:
authorPuyan Lotfi <puyan@puyan.org>2019-06-17 22:46:54 +0000
committerPuyan Lotfi <puyan@puyan.org>2019-06-17 22:46:54 +0000
commit8df7f1a218f216cc90d277baed3afc501df2a5bc (patch)
tree1cb4819241800e6973da852182cbb4e57e37db91 /clang/test/InterfaceStubs/weak.cpp
parent121956108f274f15a24ecc6df729e9cba8d2bb37 (diff)
downloadbcm5719-llvm-8df7f1a218f216cc90d277baed3afc501df2a5bc.tar.gz
bcm5719-llvm-8df7f1a218f216cc90d277baed3afc501df2a5bc.zip
[clang-ifs] Clang Interface Stubs, first version.
Clang interface stubs (previously referred to as clang-ifsos) is a new frontend action in clang that allows the generation of stub files that contain mangled name info that can be used to produce a stub library. These stub libraries can be useful for breaking up build dependencies and controlling access to a library's internal symbols. Generation of these stubs can be invoked by: clang -fvisibility=<visibility> -emit-interface-stubs \ -interface-stub-version=<interface format> Notice that -fvisibility (along with use of visibility attributes) can be used to control what symbols get generated. Currently the interface format is experimental but there are a wide range of possibilities here. Differential Revision: https://reviews.llvm.org/D60974 llvm-svn: 363626
Diffstat (limited to 'clang/test/InterfaceStubs/weak.cpp')
-rw-r--r--clang/test/InterfaceStubs/weak.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/InterfaceStubs/weak.cpp b/clang/test/InterfaceStubs/weak.cpp
new file mode 100644
index 00000000000..e089225b5d6
--- /dev/null
+++ b/clang/test/InterfaceStubs/weak.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: FileCheck --check-prefix=CHECK-YAML %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
+// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
+
+// CHECK: Symbols:
+// CHECK-DAG: _Z8weakFuncv: { Type: Func, Weak: true }
+// CHECK-DAG: _Z10strongFuncv: { Type: Func }
+
+// CHECK-YAML: Symbols:
+// CHECK-YAML-DAG: - Name: _Z8weakFuncv
+// CHECK-YAML-DAG: Type: STT_FUNC
+// CHECK-YAML-DAG: Binding: STB_WEAK
+// CHECK-YAML-DAG: - Name: _Z10strongFuncv
+// CHECK-YAML-DAG: Type: STT_FUNC
+// CHECK-YAML-DAG: Binding: STB_GLOBAL
+
+// CHECK-SYMBOLS-DAG: _Z10strongFuncv
+// CHECK-SYMBOLS-DAG: _Z8weakFuncv
+__attribute__((weak)) void weakFunc() {}
+int strongFunc() { return 42; }
OpenPOWER on IntegriCloud