Skip to content

Commit

Permalink
Undo code changes and add fix in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
hdelan committed Aug 15, 2023
1 parent 10d7714 commit 989c0e8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
9 changes: 0 additions & 9 deletions scripts/templates/libapi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,4 @@ try {

%endfor
%endfor

namespace {
// This uselessFunc is needed to ensure that pthread is linked correctly against
// ur_loader.so for gcc-9
void uselessFunc() {
std::thread UselessThread([]{});
}
}

} // extern "C"
7 changes: 7 additions & 0 deletions source/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ if (UNIX)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(ur_loader PRIVATE Threads::Threads)
# Older gcc versions need -pthread, not just -lpthread
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1)
find_library(PTHREAD_LIBRARY pthread)
target_link_libraries(ur_loader PRIVATE "-pthread")
endif()
endif()
endif()

if(WIN32)
Expand Down
1 change: 0 additions & 1 deletion source/loader/ur_lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <atomic>
#include <mutex>
#include <set>
#include <thread>
#include <vector>

struct ur_loader_config_handle_t_ {
Expand Down
8 changes: 0 additions & 8 deletions source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7743,12 +7743,4 @@ ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
return exceptionToResult(std::current_exception());
}

namespace {
// This uselessFunc is needed to ensure that pthread is linked correctly against
// ur_loader.so for gcc-9
void uselessFunc() {
std::thread UselessThread([] {});
}
} // namespace

} // extern "C"

0 comments on commit 989c0e8

Please sign in to comment.