Skip to content

Commit

Permalink
Set default visibility to hidden in Rel. builds
Browse files Browse the repository at this point in the history
  • Loading branch information
RossBrunton committed Sep 16, 2024
1 parent ad43e28 commit 5bf9a36
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function(add_ur_target_compile_options name)
)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
target_compile_options(${name} PRIVATE -fvisibility=hidden)
endif()
if(UR_DEVELOPER_MODE)
target_compile_options(${name} PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions examples/collector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI})
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)

if(MSVC)
target_compile_definitions(${TARGET_NAME} PRIVATE
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY)
endif()
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS)
10 changes: 9 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,17 @@ typedef enum ur_structure_type_t {
#if defined(_WIN32)
/// @brief Microsoft-specific dllexport storage-class attribute
#define UR_APIEXPORT __declspec(dllexport)
#endif // defined(_WIN32)
#endif // UR_APIEXPORT

///////////////////////////////////////////////////////////////////////////////
#ifndef UR_APIEXPORT
#if __GNUC__ >= 4
/// @brief GCC-specific dllexport storage-class attribute
#define UR_APIEXPORT __attribute__((visibility("default")))
#else
#define UR_APIEXPORT
#endif // defined(_WIN32)
#endif // __GNUC__ >= 4
#endif // UR_APIEXPORT

///////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ desc: "Microsoft-specific dllexport storage-class attribute"
condition: "defined(_WIN32)"
name: $X_APIEXPORT
value: __declspec(dllexport)
--- #--------------------------------------------------------------------------
type: macro
desc: "GCC-specific dllexport storage-class attribute"
condition: "__GNUC__ >= 4"
name: $X_APIEXPORT
value: __attribute__ ((visibility ("default")))
altvalue: ""
--- #--------------------------------------------------------------------------
type: macro
Expand Down
4 changes: 2 additions & 2 deletions test/layers/tracing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ target_link_libraries(test_collector PRIVATE ${TARGET_XPTI})
target_include_directories(test_collector PRIVATE ${xpti_SOURCE_DIR}/include)

if(MSVC)
target_compile_definitions(test_collector PRIVATE
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
target_compile_definitions(test_collector PRIVATE XPTI_STATIC_LIBRARY)
endif()
target_compile_definitions(test_collector PRIVATE XPTI_CALLBACK_API_EXPORTS)

function(set_tracing_test_props target_name collector_name)
set_tests_properties(${target_name} PROPERTIES
Expand Down
4 changes: 2 additions & 2 deletions tools/urtrace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI} ${PROJECT_NAME}::com
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)

if(MSVC)
target_compile_definitions(${TARGET_NAME} PRIVATE
XPTI_STATIC_LIBRARY XPTI_CALLBACK_API_EXPORTS)
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_STATIC_LIBRARY)
endif()
target_compile_definitions(${TARGET_NAME} PRIVATE XPTI_CALLBACK_API_EXPORTS)

set(UR_TRACE_CLI_BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/urtrace)

Expand Down

0 comments on commit 5bf9a36

Please sign in to comment.