Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
0f146a35
Commit
0f146a35
authored
3 years ago
by
Sprite
Committed by
Adrien Béraud
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmake: check atomic for `RISC-V` architecture
parent
9fcaca92
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+9
-0
9 additions, 0 deletions
CMakeLists.txt
cmake/CheckAtomic.cmake
+31
-0
31 additions, 0 deletions
cmake/CheckAtomic.cmake
with
40 additions
and
0 deletions
CMakeLists.txt
+
9
−
0
View file @
0f146a35
...
@@ -320,6 +320,9 @@ if (OPENDHT_STATIC)
...
@@ -320,6 +320,9 @@ if (OPENDHT_STATIC)
PUBLIC
${
CMAKE_THREAD_LIBS_INIT
}
${
GNUTLS_LIBRARIES
}
${
Nettle_STATIC_LIBRARIES
}
PUBLIC
${
CMAKE_THREAD_LIBS_INIT
}
${
GNUTLS_LIBRARIES
}
${
Nettle_STATIC_LIBRARIES
}
${
Jsoncpp_STATIC_LIBRARIES
}
${
FMT_LIBRARY
}
${
HTTP_PARSER_LIBRARY
}
${
Jsoncpp_STATIC_LIBRARIES
}
${
FMT_LIBRARY
}
${
HTTP_PARSER_LIBRARY
}
${
OPENSSL_STATIC_LIBRARIES
}
)
${
OPENSSL_STATIC_LIBRARIES
}
)
if
(
NOT HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB
)
target_link_libraries
(
opendht-static PUBLIC
"atomic"
)
endif
()
else
()
else
()
if
(
OPENDHT_TOOLS
)
if
(
OPENDHT_TOOLS
)
function
(
add_obj_lib name libfile
)
function
(
add_obj_lib name libfile
)
...
@@ -393,6 +396,9 @@ if (OPENDHT_SHARED)
...
@@ -393,6 +396,9 @@ if (OPENDHT_SHARED)
PRIVATE
${
GNUTLS_LIBRARIES
}
${
Nettle_LIBRARIES
}
PRIVATE
${
GNUTLS_LIBRARIES
}
${
Nettle_LIBRARIES
}
${
Jsoncpp_LIBRARIES
}
${
Jsoncpp_LIBRARIES
}
${
FMT_LIBRARY
}
${
HTTP_PARSER_LIBRARY
}
${
argon2_LIBRARIES
}
)
${
FMT_LIBRARY
}
${
HTTP_PARSER_LIBRARY
}
${
argon2_LIBRARIES
}
)
if
(
NOT HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB
)
target_link_libraries
(
opendht PUBLIC
"atomic"
)
endif
()
endif
()
endif
()
install
(
TARGETS opendht DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
EXPORT opendht
)
install
(
TARGETS opendht DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
EXPORT opendht
)
...
@@ -497,6 +503,9 @@ if (OPENDHT_TESTS)
...
@@ -497,6 +503,9 @@ if (OPENDHT_TESTS)
${
GNUTLS_LIBRARIES
}
${
GNUTLS_LIBRARIES
}
${
Jsoncpp_LIBRARIES
}
${
Jsoncpp_LIBRARIES
}
)
)
if
(
NOT HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB
)
target_link_libraries
(
opendht_unit_tests
"atomic"
)
endif
()
if
(
OPENDHT_PROXY_OPENSSL
)
if
(
OPENDHT_PROXY_OPENSSL
)
target_link_libraries
(
opendht_unit_tests
${
OPENSSL_LIBRARIES
}
)
target_link_libraries
(
opendht_unit_tests
${
OPENSSL_LIBRARIES
}
)
endif
()
endif
()
...
...
This diff is collapsed.
Click to expand it.
cmake/CheckAtomic.cmake
+
31
−
0
View file @
0f146a35
...
@@ -34,6 +34,21 @@ int main() {
...
@@ -34,6 +34,21 @@ int main() {
set
(
CMAKE_REQUIRED_FLAGS
${
OLD_CMAKE_REQUIRED_FLAGS
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
OLD_CMAKE_REQUIRED_FLAGS
}
)
endfunction
(
check_working_cxx_atomics64
)
endfunction
(
check_working_cxx_atomics64
)
function
(
check_working_cxx_atomics_for_risc_v varname
)
set
(
OLD_CMAKE_REQUIRED_FLAGS
${
CMAKE_REQUIRED_FLAGS
}
)
set
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
-std=c++11"
)
CHECK_CXX_SOURCE_COMPILES
(
"
#include <atomic>
std::atomic<uint8_t> x;
std::atomic<uint16_t> y;
int main() {
x++;
y++;
return 0;
}
"
${
varname
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
OLD_CMAKE_REQUIRED_FLAGS
}
)
endfunction
(
check_working_cxx_atomics_for_risc_v
)
# This isn't necessary on MSVC, so avoid command-line switch annoyance
# This isn't necessary on MSVC, so avoid command-line switch annoyance
# by only running on GCC-like hosts.
# by only running on GCC-like hosts.
...
@@ -76,6 +91,22 @@ if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
...
@@ -76,6 +91,22 @@ if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
endif
()
endif
()
endif
()
endif
()
# Check for RISC-V atomic operations.
if
(
MSVC
)
set
(
HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB True
)
else
()
check_working_cxx_atomics_for_risc_v
(
HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB
)
endif
()
# If not, check if the library exists, and atomics work with it.
if
(
NOT HAVE_CXX_ATOMICS_RISC_V_WITHOUT_LIB
)
list
(
APPEND CMAKE_REQUIRED_LIBRARIES
"atomic"
)
check_working_cxx_atomics_for_risc_v
(
HAVE_CXX_ATOMICS_RISC_V_WITH_LIB
)
if
(
NOT HAVE_CXX_ATOMICS_RISC_V_WITH_LIB
)
message
(
FATAL_ERROR
"Host compiler must support RISC-V std::atomic!"
)
endif
()
endif
()
## TODO: This define is only used for the legacy atomic operations in
## TODO: This define is only used for the legacy atomic operations in
## llvm's Atomic.h, which should be replaced. Other code simply
## llvm's Atomic.h, which should be replaced. Other code simply
## assumes C++11 <atomic> works.
## assumes C++11 <atomic> works.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment