Skip to content

Commit 06c4cd0

Browse files
Merge pull request #2085 from RossBrunton/ross/defvis
Set default visibility to hidden in Rel. builds
2 parents ad43e28 + 29e5519 commit 06c4cd0

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

cmake/helpers.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function(add_ur_target_compile_options name)
7070
)
7171
if (CMAKE_BUILD_TYPE STREQUAL "Release")
7272
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
73+
target_compile_options(${name} PRIVATE -fvisibility=hidden)
7374
endif()
7475
if(UR_DEVELOPER_MODE)
7576
target_compile_options(${name} PRIVATE

examples/collector/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI})
1717
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)
1818

1919
if(MSVC)
20-
target_compile_definitions(${TARGET_NAME} PRIVATE
21-
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
20+
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY)
2221
endif()
22+
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS)

include/ur_api.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,17 @@ typedef enum ur_structure_type_t {
332332
#if defined(_WIN32)
333333
/// @brief Microsoft-specific dllexport storage-class attribute
334334
#define UR_APIEXPORT __declspec(dllexport)
335+
#endif // defined(_WIN32)
336+
#endif // UR_APIEXPORT
337+
338+
///////////////////////////////////////////////////////////////////////////////
339+
#ifndef UR_APIEXPORT
340+
#if __GNUC__ >= 4
341+
/// @brief GCC-specific dllexport storage-class attribute
342+
#define UR_APIEXPORT __attribute__((visibility("default")))
335343
#else
336344
#define UR_APIEXPORT
337-
#endif // defined(_WIN32)
345+
#endif // __GNUC__ >= 4
338346
#endif // UR_APIEXPORT
339347

340348
///////////////////////////////////////////////////////////////////////////////

scripts/core/common.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ desc: "Microsoft-specific dllexport storage-class attribute"
3939
condition: "defined(_WIN32)"
4040
name: $X_APIEXPORT
4141
value: __declspec(dllexport)
42+
--- #--------------------------------------------------------------------------
43+
type: macro
44+
desc: "GCC-specific dllexport storage-class attribute"
45+
condition: "__GNUC__ >= 4"
46+
name: $X_APIEXPORT
47+
value: __attribute__ ((visibility ("default")))
4248
altvalue: ""
4349
--- #--------------------------------------------------------------------------
4450
type: macro

test/layers/tracing/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ target_link_libraries(test_collector PRIVATE ${TARGET_XPTI})
1515
target_include_directories(test_collector PRIVATE ${xpti_SOURCE_DIR}/include)
1616

1717
if(MSVC)
18-
target_compile_definitions(test_collector PRIVATE
19-
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
18+
target_compile_definitions(test_collector PRIVATE XPTI_STATIC_LIBRARY)
2019
endif()
20+
target_compile_definitions(test_collector PRIVATE XPTI_CALLBACK_API_EXPORTS)
2121

2222
function(set_tracing_test_props target_name collector_name)
2323
set_tests_properties(${target_name} PROPERTIES

tools/urtrace/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI} ${PROJECT_NAME}::com
1717
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)
1818

1919
if(MSVC)
20-
target_compile_definitions(${TARGET_NAME} PRIVATE
21-
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
20+
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY)
2221
endif()
22+
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS)
2323

2424
set(UR_TRACE_CLI_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/urtrace)
2525

0 commit comments

Comments
 (0)