From 23e9968752ddb2ceb78d9986182dcb503c13d9be Mon Sep 17 00:00:00 2001 From: Aaron Enye Shi Date: Wed, 6 Mar 2019 18:27:28 +0000 Subject: [PATCH] Fix hash_for undefined reference in hipTestConstant test Issue: mismatch undefined symbols in different user env - Binary expects modified return value std::string& - Fails to match libhip_hcc.so: return value is std::string& but doesn't match modified C++ env Fix: Change return value to char*, create new key std::string in header from char* --- include/hip/hcc_detail/hip_runtime_api.h | 5 +++-- src/hip_module.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index 7b7ffb0638..72cfbf7d3b 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -2518,7 +2518,7 @@ struct Agent_global { namespace hip_impl { hsa_executable_t executable_for(hipModule_t); -const std::string& hash_for(hipModule_t); +const char* hash_for(hipModule_t); template std::pair read_global_description( @@ -2543,7 +2543,8 @@ hipError_t read_agent_global_from_module(hipDeviceptr_t* dptr, size_t* bytes, // hipModule_t instance static std::unordered_map< std::string, std::vector> agent_globals; - auto key = hash_for(hmod); + const char* hash = hash_for(hmod); + std::string key(hash); if (agent_globals.count(key) == 0) { static std::mutex mtx; diff --git a/src/hip_module.cpp b/src/hip_module.cpp index 52d1fb38bd..178b0c9471 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -287,8 +287,8 @@ namespace hip_impl { return hmod->executable; } - const std::string& hash_for(hipModule_t hmod) { - return hmod->hash; + const char* hash_for(hipModule_t hmod) { + return hmod->hash.c_str(); } hsa_agent_t this_agent() {