diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 24cb6f8e54..6a5700da8b 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -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 diff --git a/examples/collector/CMakeLists.txt b/examples/collector/CMakeLists.txt index 5fe484d0b8..6dd112aae0 100644 --- a/examples/collector/CMakeLists.txt +++ b/examples/collector/CMakeLists.txt @@ -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) diff --git a/include/ur_api.h b/include/ur_api.h index a707d40a3f..e75793f3d2 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -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 /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/common.yml b/scripts/core/common.yml index d06333eb07..5df4a7c04e 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -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 diff --git a/test/layers/tracing/CMakeLists.txt b/test/layers/tracing/CMakeLists.txt index 969e4318b1..c09f2eafb1 100644 --- a/test/layers/tracing/CMakeLists.txt +++ b/test/layers/tracing/CMakeLists.txt @@ -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 diff --git a/tools/urtrace/CMakeLists.txt b/tools/urtrace/CMakeLists.txt index 085f361223..9b385606ea 100644 --- a/tools/urtrace/CMakeLists.txt +++ b/tools/urtrace/CMakeLists.txt @@ -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)