Skip to content

Commit 8a033a9

Browse files
committed
[libc++] Always build with -fvisibility=hidden
Summary: This avoids symbols being accidentally exported from the dylib when they shouldn't. The next step is to use a pragma to apply hidden visibility to all declarations (unless otherwise specified), which will allow us to drop the per-declaration hidden visibility attributes we currently have. This also has the nice side effect of making sure the dylib exports the same symbols regardless of the optimization level. PR38138 Reviewers: EricWF, mclow.lists Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D62868 llvm-svn: 368703
1 parent 6765943 commit 8a033a9

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

libcxx/include/chrono

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,6 +2934,7 @@ struct _FilesystemClock {
29342934
typedef chrono::duration<rep, period> duration;
29352935
typedef chrono::time_point<_FilesystemClock> time_point;
29362936

2937+
_LIBCPP_EXPORTED_FROM_ABI
29372938
static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
29382939

29392940
_LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;

libcxx/include/filesystem

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,7 @@ public:
25832583
void disable_recursion_pending() { __rec_ = false; }
25842584

25852585
private:
2586+
_LIBCPP_FUNC_VIS
25862587
recursive_directory_iterator(const path& __p, directory_options __opt,
25872588
error_code* __ec);
25882589

libcxx/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ function(cxx_set_common_defines name)
204204
if(LIBCXX_CXX_ABI_HEADER_TARGET)
205205
add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
206206
endif()
207+
target_compile_options(${name} PRIVATE -fvisibility=hidden)
207208
if(WIN32 AND NOT MINGW)
208209
target_compile_definitions(${name}
209210
PRIVATE
@@ -355,7 +356,6 @@ if (LIBCXX_ENABLE_STATIC)
355356
cxx_set_common_defines(cxx_static)
356357

357358
if (LIBCXX_HERMETIC_STATIC_LIBRARY)
358-
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility=hidden)
359359
# If the hermetic library doesn't define the operator new/delete functions
360360
# then its code shouldn't declare them with hidden visibility. They might
361361
# actually be provided by a shared library at link time.

libcxx/src/valarray.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1212

1313
// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
1414
#if _LIBCPP_ABI_VERSION == 1
15-
template valarray<size_t>::valarray(size_t);
16-
template valarray<size_t>::~valarray();
15+
template _LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t);
16+
template _LIBCPP_FUNC_VIS valarray<size_t>::~valarray();
1717
#endif
1818

1919
template void valarray<size_t>::resize(size_t, size_t);

0 commit comments

Comments
 (0)