Skip to content

Commit b8e6976

Browse files
committed
[libc] Set default visibility to 'hidden' and make entrypoints default
Summary: See for visibility: https://llvm.org/docs/LangRef.html#visibility-styles Currently we build everything with default visibility, meaning that all internal symbols are preemptable and visible to any `.so` they're linked into. What we want is hidden visibility for all the internal parts, and default visibility for the API functions / exposed globals. This patch is based on #97109.
1 parent 6ba764a commit b8e6976

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function(_get_common_compile_options output_var flags)
4141

4242
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
4343
list(APPEND compile_options "-fpie")
44+
list(APPEND compile_options "-fvisibility=hidden")
4445

4546
if(LLVM_LIBC_FULL_BUILD)
4647
list(APPEND compile_options "-DLIBC_FULL_BUILD")
@@ -94,7 +95,6 @@ function(_get_common_compile_options output_var flags)
9495
endif()
9596
if (LIBC_TARGET_OS_IS_GPU)
9697
list(APPEND compile_options "-nogpulib")
97-
list(APPEND compile_options "-fvisibility=hidden")
9898
list(APPEND compile_options "-fconvergent-functions")
9999
list(APPEND compile_options "-flto")
100100
list(APPEND compile_options "-Wno-multi-gpu")

libc/src/__support/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include "src/__support/macros/attributes.h"
1717
#include "src/__support/macros/properties/architectures.h"
1818

19+
#ifndef LIBC_TARGET_ARCH_IS_GPU
20+
#define LLVM_LIBC_FUNCTION_ATTR [[gnu::visibility("default")]]
21+
#endif
22+
1923
#ifndef LLVM_LIBC_FUNCTION_ATTR
2024
#define LLVM_LIBC_FUNCTION_ATTR
2125
#endif

0 commit comments

Comments
 (0)