Skip to content

Commit 6a01b2a

Browse files
committed
hal_mmd: remove support for dynamically loading custom non-MMD libraries
When a dynamically loaded MMD library did not export the MMD API, tested by the absense of aocl_mmd_get_offline_info(), the runtime would reload the library into the global lookup scope, with the intention of providing the symbols to another, actual MMD library. Since this feature was never documented or used in a reference BSP, it should be safe to remove and avoid polluting the global scope. As an alternative, an MMD library requiring additional symbols could dynamically link with the corresponding shared library at build time. Signed-off-by: Peter Colberg <[email protected]>
1 parent 03ebe32 commit 6a01b2a

File tree

1 file changed

+9
-38
lines changed

1 file changed

+9
-38
lines changed

src/acl_hal_mmd.cpp

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,6 @@ void *my_dlopen(const char *library_name, char **error_msg) {
397397
return my_dlopen_flags(library_name, RTLD_NOW, error_msg);
398398
#endif
399399
}
400-
void *my_dlopen_global(const char *library_name, char **error_msg) {
401-
#ifdef _WIN32
402-
return my_dlopen_flags(library_name, 0, error_msg);
403-
#else
404-
return my_dlopen_flags(library_name, RTLD_NOW | RTLD_GLOBAL, error_msg);
405-
#endif
406-
}
407400

408401
void *my_dlsym(void *library, const char *function_name, char **error_msg) {
409402
void *symbol;
@@ -578,39 +571,17 @@ cl_bool l_load_single_board_library(const char *library_name,
578571
return CL_FALSE;
579572
}
580573

581-
auto *test_symbol =
582-
my_dlsym(mmd_library, "aocl_mmd_get_offline_info", &error_msg);
583-
if (!test_symbol) {
584-
// On Linux, for custom libraries close the library (which was opened
585-
// locally) and then reopen globally. For Windows, there is no option (i.e.
586-
// it is always global)
587-
#ifdef __linux__
588-
my_dlclose(mmd_library);
589-
ACL_HAL_DEBUG_MSG_VERBOSE(
590-
1, "This library is a custom library. Opening globally.\n");
591-
mmd_library = my_dlopen_global(library_name, &error_msg);
592-
if (!mmd_library) {
593-
std::cout << "Error: Could not load custom library " << library_name;
594-
if (error_msg && error_msg[0] != '\0') {
595-
std::cout << " (error_msg: " << error_msg << ")";
596-
}
597-
std::cout << "\n";
598-
return CL_FALSE;
599-
}
600-
#endif
601-
} else {
602-
if (load_libraries) {
603-
auto result =
604-
l_load_board_functions(&(internal_mmd_dispatch[num_boards_found]),
605-
library_name, mmd_library, error_msg);
606-
if (result == CL_FALSE) {
607-
std::cout << "Error: Could not load board library " << library_name
608-
<< " due to failure to load symbols\n";
609-
return result;
610-
}
574+
if (load_libraries) {
575+
auto result =
576+
l_load_board_functions(&(internal_mmd_dispatch[num_boards_found]),
577+
library_name, mmd_library, error_msg);
578+
if (result == CL_FALSE) {
579+
std::cout << "Error: Could not load board library " << library_name
580+
<< " due to failure to load symbols\n";
581+
return result;
611582
}
612-
++num_boards_found;
613583
}
584+
++num_boards_found;
614585

615586
return CL_TRUE;
616587
}

0 commit comments

Comments
 (0)