Unverified Commit b3a72c3b authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Visibility for libraries (#3514)

Set up visibility support for all the library backends.
parent b329fb2c
......@@ -14,30 +14,14 @@
// limitations under the License.
//*****************************************************************************
// https://gcc.gnu.org/wiki/Visibility
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
#define NGRAPH_HELPER_DLL_IMPORT __declspec(dllimport)
#define NGRAPH_HELPER_DLL_EXPORT __declspec(dllexport)
#define NGRAPH_HELPER_DLL_LOCAL
#elif defined NGRAPH_LINUX_VISIBILITY_ENABLE && __GNUC__ >= 4
#define NGRAPH_HELPER_DLL_IMPORT __attribute__((visibility("default")))
#define NGRAPH_HELPER_DLL_EXPORT __attribute__((visibility("default")))
#define NGRAPH_HELPER_DLL_LOCAL __attribute__((visibility("hidden")))
#else
#define NGRAPH_HELPER_DLL_IMPORT
#define NGRAPH_HELPER_DLL_EXPORT
#define NGRAPH_HELPER_DLL_LOCAL
#endif
#include "ngraph/visibility.hpp"
// Now we use the generic helper definitions above to define NGRAPH_API and NGRAPH_LOCAL.
// Now we use the generic helper definitions above to define NGRAPH_API
// NGRAPH_API is used for the public API symbols. It either DLL imports or DLL exports
// (or does nothing for static build)
// NGRAPH_LOCAL is used for non-api symbols.
#ifdef NGRAPH_DLL_EXPORTS // defined if we are building the NGRAPH DLL (instead of using it)
#define NGRAPH_API NGRAPH_HELPER_DLL_EXPORT
#else
#define NGRAPH_API NGRAPH_HELPER_DLL_IMPORT
#endif // NGRAPH_DLL_EXPORTS
#define NGRAPH_LOCAL NGRAPH_HELPER_DLL_LOCAL
......@@ -14,37 +14,10 @@
// limitations under the License.
//*****************************************************************************
// https://gcc.gnu.org/wiki/Visibility
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
#define CPU_BACKEND_HELPER_DLL_IMPORT __declspec(dllimport)
#define CPU_BACKEND_HELPER_DLL_EXPORT __declspec(dllexport)
#define CPU_BACKEND_HELPER_DLL_LOCAL
#else
#if __GNUC__ >= 4
#define CPU_BACKEND_HELPER_DLL_IMPORT __attribute__((visibility("default")))
#define CPU_BACKEND_HELPER_DLL_EXPORT __attribute__((visibility("default")))
#define CPU_BACKEND_HELPER_DLL_LOCAL __attribute__((visibility("hidden")))
#else
#define CPU_BACKEND_HELPER_DLL_IMPORT
#define CPU_BACKEND_HELPER_DLL_EXPORT
#define CPU_BACKEND_HELPER_DLL_LOCAL
#endif
#endif
// Now we use the generic helper definitions above to define CPU_BACKEND_API and CPU_BACKEND_LOCAL.
// CPU_BACKEND_API is used for the public API symbols. It either DLL imports or DLL exports
// (or does nothing for static build)
// CPU_BACKEND_LOCAL is used for non-api symbols.
#include "ngraph/visibility.hpp"
// #ifdef CPU_BACKEND_DLL // defined if CPU_BACKEND is compiled as a DLL
#ifdef CPU_BACKEND_DLL_EXPORTS // defined if we are building the CPU_BACKEND DLL (instead of using it)
#define CPU_BACKEND_API CPU_BACKEND_HELPER_DLL_EXPORT
#ifdef CPU_BACKEND_DLL_EXPORTS // defined if we are building the CPU_BACKEND
#define CPU_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define CPU_BACKEND_API CPU_BACKEND_HELPER_DLL_IMPORT
#endif // CPU_BACKEND_DLL_EXPORTS
#define CPU_BACKEND_LOCAL CPU_BACKEND_HELPER_DLL_LOCAL
// #else // CPU_BACKEND_DLL is not defined: this means CPU_BACKEND is a static lib.
// #define CPU_BACKEND_API
// #define CPU_BACKEND_LOCAL
// #endif // CPU_BACKEND_DLL
#define CPU_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
......@@ -26,6 +26,7 @@ if (NGRAPH_GENERIC_CPU_ENABLE)
SOVERSION ${NGRAPH_API_VERSION})
endif()
target_link_libraries(gcpu_backend PRIVATE ngraph libeigen)
target_compile_definitions(gcpu_backend PRIVATE GCPU_BACKEND_DLL_EXPORTS)
install(TARGETS gcpu_backend
LIBRARY DESTINATION "${NGRAPH_INSTALL_LIB}"
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/visibility.hpp"
#ifdef GCPU_BACKEND_DLL_EXPORTS // defined if we are building the CPU_BACKEND
#define GCPU_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define GCPU_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
......@@ -145,6 +145,7 @@ if (NGRAPH_GPU_ENABLE)
endif()
add_library(gpu_backend SHARED ${SRC} ${CUDA_OBJ})
target_compile_definitions(gpu_backend PRIVATE GPU_BACKEND_EXPORTS)
if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(gpu_backend PROPERTIES
VERSION ${NGRAPH_VERSION}
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/visibility.hpp"
// Now we use the generic helper definitions above to define GPU_BACKEND_API
// GPU_BACKEND_API is used for the public API symbols. It either DLL imports or DLL exports
// (or does nothing for static build)
#ifdef GPU_BACKEND_EXPORTS // defined if we are building the GPU_BACKEND
#define GPU_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define GPU_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
......@@ -32,6 +32,7 @@ set(SRC
if (NGRAPH_INTELGPU_ENABLE)
add_library(intelgpu_backend SHARED ${SRC})
target_link_libraries(intelgpu_backend PUBLIC ngraph libcldnn)
target_compile_definitions(intelgpu_backend PRIVATE INTELGPU_BACKEND_DLL_EXPORTS)
if (NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(intelgpu_backend
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/visibility.hpp"
#ifdef INTELGPU_BACKEND_EXPORTS // defined if we are building the INTELGPU_BACKEND
#define INTELGPU_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define INTELGPU_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
......@@ -22,6 +22,7 @@ endif()
if (NGRAPH_INTERPRETER_ENABLE)
add_library(interpreter_backend ${LIBRARY_TYPE} int_backend.cpp node_wrapper.cpp int_executable.cpp)
target_compile_definitions(interpreter_backend PRIVATE INTERPRETER_BACKEND_EXPORTS)
if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(interpreter_backend PROPERTIES
VERSION ${NGRAPH_VERSION}
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/visibility.hpp"
// Now we use the generic helper definitions above to define INTERPRETER_API
// INTERPRETER_API is used for the public API symbols. It either DLL imports or DLL exports
// (or does nothing for static build)
#ifdef INTERPRETER_BACKEND_EXPORTS // defined if we are building the INTERPRETER DLL (instead of
// using
// it)
#define INTERPRETER_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define INTERPRETER_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif // INTERPRETER_DLL_EXPORTS
......@@ -16,6 +16,7 @@
if (NGRAPH_NOP_ENABLE)
add_library(nop_backend SHARED nop_backend.cpp)
target_compile_definitions(nop_backend PRIVATE NOP_BACKEND_EXPORTS)
if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(nop_backend PROPERTIES
VERSION ${NGRAPH_VERSION}
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/visibility.hpp"
#ifdef NOP_BACKEND_EXPORTS // defined if we are building the NOP_BACKEND
#define NOP_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define NOP_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
......@@ -75,7 +75,7 @@ target_include_directories(plaidml_backend SYSTEM PUBLIC ${PLAIDML_INCLUDE_DIRS}
target_link_libraries(plaidml_backend PUBLIC ngraph libplaidml)
install(TARGETS plaidml_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
target_compile_definitions(plaidml_backend PRIVATE PLAIDML_BACKEND_DLL_EXPORTS)
target_compile_definitions(plaidml_backend PRIVATE PLAIDML_BACKEND_EXPORTS)
set(CMAKE_MACOSX_RPATH 1)
if(APPLE)
......
......@@ -14,40 +14,10 @@
// limitations under the License.
//*****************************************************************************
// https://gcc.gnu.org/wiki/Visibility
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
#define PLAIDML_BACKEND_HELPER_DLL_IMPORT __declspec(dllimport)
#define PLAIDML_BACKEND_HELPER_DLL_EXPORT __declspec(dllexport)
#define PLAIDML_BACKEND_HELPER_DLL_LOCAL
#else
#if __GNUC__ >= 4
#define PLAIDML_BACKEND_HELPER_DLL_IMPORT __attribute__((visibility("default")))
#define PLAIDML_BACKEND_HELPER_DLL_EXPORT __attribute__((visibility("default")))
#define PLAIDML_BACKEND_HELPER_DLL_LOCAL __attribute__((visibility("hidden")))
#else
#define PLAIDML_BACKEND_HELPER_DLL_IMPORT
#define PLAIDML_BACKEND_HELPER_DLL_EXPORT
#define PLAIDML_BACKEND_HELPER_DLL_LOCAL
#endif
#endif
#include "ngraph/visibility.hpp"
// Now we use the generic helper definitions above to define PLAIDML_BACKEND_API and
// PLAIDML_BACKEND_LOCAL.
//
// PLAIDML_BACKEND_API is used for the public API symbols. It either DLL imports or DLL exports
// (or does nothing for static build)
// PLAIDML_BACKEND_LOCAL is used for non-api symbols.
// #ifdef PLAIDML_BACKEND_DLL // defined if PLAIDML_BACKEND is compiled as a DLL
#ifdef PLAIDML_BACKEND_DLL_EXPORTS // defined if we are building the PLAIDML_BACKEND DLL (instead of
// using it)
#define PLAIDML_BACKEND_API PLAIDML_BACKEND_HELPER_DLL_EXPORT
#ifdef PLAIDML_BACKEND_EXPORTS // defined if we are building the PLAIDML_BACKEND
#define PLAIDML_BACKEND_API NGRAPH_HELPER_DLL_EXPORT
#else
#define PLAIDML_BACKEND_API PLAIDML_BACKEND_HELPER_DLL_IMPORT
#endif // PLAIDML_BACKEND_DLL_EXPORTS
#define PLAIDML_BACKEND_LOCAL PLAIDML_BACKEND_HELPER_DLL_LOCAL
// #else // PLAIDML_BACKEND_DLL is not defined: this means PLAIDML_BACKEND is a static lib.
// #define PLAIDML_BACKEND_API
// #define PLAIDML_BACKEND_LOCAL
// #endif // PLAIDML_BACKEND_DLL
#define PLAIDML_BACKEND_API NGRAPH_HELPER_DLL_IMPORT
#endif
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
// https://gcc.gnu.org/wiki/Visibility
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
#define NGRAPH_HELPER_DLL_IMPORT __declspec(dllimport)
#define NGRAPH_HELPER_DLL_EXPORT __declspec(dllexport)
#define NGRAPH_HELPER_DLL_LOCAL
#elif defined NGRAPH_LINUX_VISIBILITY_ENABLE && __GNUC__ >= 4
#define NGRAPH_HELPER_DLL_IMPORT __attribute__((visibility("default")))
#define NGRAPH_HELPER_DLL_EXPORT __attribute__((visibility("default")))
#define NGRAPH_HELPER_DLL_LOCAL __attribute__((visibility("hidden")))
#else
#define NGRAPH_HELPER_DLL_IMPORT
#define NGRAPH_HELPER_DLL_EXPORT
#define NGRAPH_HELPER_DLL_LOCAL
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment