don't expose symbols from code_object_bundle (#1971)

Change-Id: I56479485aad42c3d517fe6d9055be1cd846eeb00

[ROCm/hip commit: 43abf84f54]
This commit is contained in:
Siu Chi Chan
2020-03-27 04:39:07 -04:00
gecommit door GitHub
bovenliggende 1909e436cf
commit e58a0d06f7
9 gewijzigde bestanden met toevoegingen van 33 en 51 verwijderingen
+4 -2
Bestand weergeven
@@ -259,7 +259,6 @@ if(HIP_PLATFORM STREQUAL "hcc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIP_HCC_BUILD_FLAGS}")
set(SOURCE_FILES_RUNTIME
src/code_object_bundle.cpp
src/program_state.cpp
src/hip_clang.cpp
src/hip_hcc.cpp
@@ -305,7 +304,7 @@ if(HIP_PLATFORM STREQUAL "hcc")
target_link_libraries(hip_hcc PRIVATE hc_am)
target_link_libraries(hip_hcc_static PRIVATE hc_am)
add_library(hiprtc SHARED src/hiprtc.cpp src/code_object_bundle.cpp)
add_library(hiprtc SHARED src/hiprtc.cpp)
target_compile_options(hiprtc PRIVATE -DDISABLE_REDUCED_GPU_BLOB_COPY)
set_property ( TARGET hiprtc PROPERTY VERSION "${HIP_LIB_VERSION_STRING}" )
set_property ( TARGET hiprtc PROPERTY SOVERSION "${HIP_LIB_VERSION_MAJOR}" )
@@ -315,6 +314,9 @@ if(HIP_PLATFORM STREQUAL "hcc")
endif()
set_target_properties(hip_hcc PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(hip_hcc PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
set_target_properties(hiprtc PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(hiprtc PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
if(HIP_PLATFORM STREQUAL "hcc")
find_package(amd_comgr REQUIRED CONFIG
@@ -28,6 +28,8 @@ extern "C" {
#include <stdlib.h>
#pragma GCC visibility push (default)
enum hiprtcResult {
HIPRTC_SUCCESS = 0,
HIPRTC_ERROR_OUT_OF_MEMORY = 1,
@@ -79,6 +81,8 @@ hiprtcResult hiprtcGetCode(hiprtcProgram prog, char* code);
hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t* codeSizeRet);
#pragma GCC visibility pop
#ifdef __cplusplus
}
#endif /* __cplusplus */
+1 -1
Bestand weergeven
@@ -14,7 +14,7 @@ install(TARGETS lpl RUNTIME DESTINATION bin)
#-------------------------------------LPL--------------------------------------#
#-------------------------------------CA---------------------------------------#
add_executable(ca ca.cpp ${PROJECT_SOURCE_DIR}/src/code_object_bundle.cpp)
add_executable(ca ca.cpp)
set_target_properties(
ca PROPERTIES
CXX_STANDARD 11
+1 -1
Bestand weergeven
@@ -2,7 +2,7 @@
#include "common.hpp"
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include "../src/code_object_bundle.inl"
#include "clara/clara.hpp"
@@ -1,34 +0,0 @@
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include <hsa/hsa.h>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
using namespace std;
// CREATORS
hip_impl::Bundled_code_header::Bundled_code_header(const vector<char>& x)
: Bundled_code_header{x.cbegin(), x.cend()} {}
hip_impl::Bundled_code_header::Bundled_code_header(
const void* p) { // This is a pretty terrible interface, useful only because
// hipLoadModuleData is so poorly specified (for no fault of its own).
if (!p) return;
if (!valid(*static_cast<const Bundled_code_header*>(p))) return;
auto ph = static_cast<const Header_*>(p);
size_t sz = sizeof(Header_) + ph->bundle_cnt_ * sizeof(Bundled_code::Header);
auto pb = static_cast<const char*>(p) + sizeof(Header_);
auto n = ph->bundle_cnt_;
while (n--) {
sz += reinterpret_cast<const Bundled_code::Header*>(pb)->bundle_sz;
pb += sizeof(Bundled_code::Header);
}
read(static_cast<const char*>(p), static_cast<const char*>(p) + sz, *this);
}
@@ -92,10 +92,6 @@ struct Bundled_code {
#define magic_string_ "__CLANG_OFFLOAD_BUNDLE__"
#ifdef __GNUC__
#pragma GCC visibility push (default)
#endif
class Bundled_code_header {
// DATA - STATICS
static constexpr auto magic_string_sz_ = sizeof(magic_string_) - 1;
@@ -167,8 +163,26 @@ class Bundled_code_header {
Bundled_code_header() = default;
template <typename RandomAccessIterator>
Bundled_code_header(RandomAccessIterator f, RandomAccessIterator l);
explicit Bundled_code_header(const std::vector<char>& blob);
explicit Bundled_code_header(const void* maybe_blob);
explicit Bundled_code_header(const std::vector<char>& blob)
: Bundled_code_header{blob.cbegin(), blob.cend()} {}
explicit Bundled_code_header(const void* maybe_blob) {
// This is a pretty terrible interface, useful only because
// hipLoadModuleData is so poorly specified (for no fault of its own).
if (!maybe_blob) return;
if (!valid(*static_cast<const Bundled_code_header*>(maybe_blob))) return;
auto ph = static_cast<const Header_*>(maybe_blob);
size_t sz = sizeof(Header_) + ph->bundle_cnt_ * sizeof(Bundled_code::Header);
auto pb = static_cast<const char*>(maybe_blob) + sizeof(Header_);
auto n = ph->bundle_cnt_;
while (n--) {
sz += reinterpret_cast<const Bundled_code::Header*>(pb)->bundle_sz;
pb += sizeof(Bundled_code::Header);
}
read(static_cast<const char*>(maybe_blob), static_cast<const char*>(maybe_blob) + sz, *this);
}
Bundled_code_header(const Bundled_code_header&) = default;
Bundled_code_header(Bundled_code_header&&) = default;
~Bundled_code_header() = default;
@@ -180,10 +194,6 @@ class Bundled_code_header {
size_t bundled_code_size = 0;
};
#ifdef __GNUC__
#pragma GCC visibility pop
#endif
// CREATORS
template <typename RandomAccessIterator>
Bundled_code_header::Bundled_code_header(RandomAccessIterator f, RandomAccessIterator l)
+1 -1
Bestand weergeven
@@ -50,7 +50,7 @@ THE SOFTWARE.
#include <unordered_map>
#include <utility>
#include <vector>
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include "code_object_bundle.inl"
#include "hip_fatbin.h"
// TODO Use Pool APIs from HCC to get memory regions.
+1 -1
Bestand weergeven
@@ -21,7 +21,7 @@ THE SOFTWARE.
*/
#include "../include/hip/hiprtc.h"
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include "code_object_bundle.inl"
#include "../include/hip/hcc_detail/elfio/elfio.hpp"
#include "../include/hip/hcc_detail/program_state.hpp"
+1 -1
Bestand weergeven
@@ -1,6 +1,6 @@
#include "../include/hip/hcc_detail/program_state.hpp"
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include "code_object_bundle.inl"
#include "../include/hip/hcc_detail/hsa_helpers.hpp"
#if !defined(__cpp_exceptions)