Skip to content

Commit 989c0e8

Browse files
author
Hugh Delaney
committed
Undo code changes and add fix in cmake
1 parent 10d7714 commit 989c0e8

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

scripts/templates/libapi.cpp.mako

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,4 @@ try {
8282

8383
%endfor
8484
%endfor
85-
86-
namespace {
87-
// This uselessFunc is needed to ensure that pthread is linked correctly against
88-
// ur_loader.so for gcc-9
89-
void uselessFunc() {
90-
std::thread UselessThread([]{});
91-
}
92-
}
93-
9485
} // extern "C"

source/loader/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ if (UNIX)
4848
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
4949
find_package(Threads REQUIRED)
5050
target_link_libraries(ur_loader PRIVATE Threads::Threads)
51+
# Older gcc versions need -pthread, not just -lpthread
52+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
53+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1)
54+
find_library(PTHREAD_LIBRARY pthread)
55+
target_link_libraries(ur_loader PRIVATE "-pthread")
56+
endif()
57+
endif()
5158
endif()
5259

5360
if(WIN32)

source/loader/ur_lib.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <atomic>
2727
#include <mutex>
2828
#include <set>
29-
#include <thread>
3029
#include <vector>
3130

3231
struct ur_loader_config_handle_t_ {

source/loader/ur_libapi.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7743,12 +7743,4 @@ ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
77437743
return exceptionToResult(std::current_exception());
77447744
}
77457745

7746-
namespace {
7747-
// This uselessFunc is needed to ensure that pthread is linked correctly against
7748-
// ur_loader.so for gcc-9
7749-
void uselessFunc() {
7750-
std::thread UselessThread([] {});
7751-
}
7752-
} // namespace
7753-
77547746
} // extern "C"

0 commit comments

Comments
 (0)