From ca4c88430676586748ea13bec0a5643b159a0e33 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Wed, 22 Nov 2017 19:27:32 -0600 Subject: [PATCH] Report library load errors in debug builds. Change-Id: I24e63b15ad74fb86ecfe839f543800c2140c09d9 --- runtime/hsa-runtime/core/runtime/hsa.cpp | 4 +--- runtime/hsa-runtime/core/util/lnx/os_linux.cpp | 1 + runtime/hsa-runtime/core/util/utils.h | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/hsa.cpp b/runtime/hsa-runtime/core/runtime/hsa.cpp index aa83ff88da..0c55e38105 100644 --- a/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -53,7 +53,6 @@ #define __lseek__ _lseek #else #include -#include #define __read__ read #define __lseek__ lseek #endif // _WIN32 || _WIN64 @@ -473,10 +472,9 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v os::LibHandle lib = os::LoadLib(kAqlProfileLib); if (lib == NULL) { - fprintf(stderr, "Loading '%s' error: %s\n", kAqlProfileLib, dlerror()); + debug_print("Loading '%s' failed\n", kAqlProfileLib); return HSA_STATUS_ERROR; } - dlerror(); // Clear any existing error hsa_ven_amd_aqlprofile_1_00_pfn_t ext_table; ext_table.hsa_ven_amd_aqlprofile_error_string = diff --git a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp index c5f5abc628..86a8dc93d5 100644 --- a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp +++ b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp @@ -67,6 +67,7 @@ static_assert(sizeof(Thread) == sizeof(pthread_t), LibHandle LoadLib(std::string filename) { void* ret = dlopen(filename.c_str(), RTLD_LAZY); + if (ret == nullptr) debug_print("LoadLib(%s) failed: %s\n", filename.c_str(), dlerror()); return *(LibHandle*)&ret; } diff --git a/runtime/hsa-runtime/core/util/utils.h b/runtime/hsa-runtime/core/util/utils.h index ab279d7f2f..2132e277e1 100755 --- a/runtime/hsa-runtime/core/util/utils.h +++ b/runtime/hsa-runtime/core/util/utils.h @@ -98,7 +98,9 @@ static __forceinline unsigned long long int strtoull(const char* str, #define PASTE(x, y) PASTE2(x, y) #ifdef NDEBUG -#define debug_warning(exp) +#define debug_warning(exp) \ + do { \ + } while (false) #else #define debug_warning(exp) \ do { \