[COMMIT seastar master] build: stop detecting concepts support

1 view
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Jan 26, 2023, 11:00:48 AM1/26/23
to seastar-dev@googlegroups.com, Kefu Chai
From: Kefu Chai <kefu...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>
Branch: master

build: stop detecting concepts support

* remove all stuff use for detecting C++20 concepts

since we only support the latest two major releases of compilers.
at the moment of writing, Clang just released v15, and the latest
major release of GCC is v12. both of them have a decent support of
C++ concepts. and if the tree is compiled with `-std=c++20`,
`-std=c++2a` or `-std=c++23`, `-fconcepts` or `-fconcepts-ts` is not
necessary for compiling C++ code using C++20 concepts.

also, because neither libc++ nor libstdc++ defines `__cpp_lib_concepts`
if the source is compiled with `-std=c++<standard>` where "standard" is
lower than 20, `include/seastar/util/concepts.hh` would define
`SEASTAR_CONCEPT` to nothing. also, `-std=c++17` makes compilers define
`__cpp_concepts` as `201507`. this also practically disables `SEASTAR_CONCEPT`.
please note, `__cpp_concepts` only detects the compiler's capability for
supporting C++20 concepts, but we still need the support from standard
library to program using C++20 concepts.

also, `code_tests/Concepts_test.cc` compares `__cpp_concepts` with `201507`.
this always fails when compiling with C++20, where `__cpp_concepts` is
`201907L` or `202002L`. see
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_concepts
.

so, in short, we don't use concepts when the tree is compiled with
C++17. and when compiling with C++20, supported C++ compilers do not
need an additional compiling option for enabling concepts support.

before this change, we pass `-fconcepts` to compiler if it compiles
code using C++20 concepts.

after this change, we stop checking the C++20 concepts support and
do not pass `-fconcepts` to compiler even it is accepted by the compiler
when compiling the test code using C++20 concepts.

Signed-off-by: Kefu Chai <kefu...@scylladb.com>

---
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1259,7 +1259,6 @@ if (Seastar_INSTALL)

install (
FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindConcepts.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGnuTLS.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLinuxMembarrier.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSanitizers.cmake
diff --git a/cmake/FindConcepts.cmake b/cmake/FindConcepts.cmake
--- a/cmake/FindConcepts.cmake
+++ b/cmake/FindConcepts.cmake
@@ -1,36 +0,0 @@
-#
-# This file is open source software, licensed to you under the terms
-# of the Apache License, Version 2.0 (the "License"). See the NOTICE file
-# distributed with this work for additional information regarding copyright
-# ownership. You may not use this file except in compliance with the License.
-#
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# Copyright (C) 2018 Scylladb, Ltd.
-#
-
-include (CheckCXXSourceCompiles)
-file (READ ${CMAKE_CURRENT_LIST_DIR}/code_tests/Concepts_test.cc _concepts_test_code)
-set (CMAKE_REQUIRED_FLAGS -fconcepts)
-check_cxx_source_compiles ("${_concepts_test_code}" Concepts_FOUND)
-set (CMAKE_REQUIRED_FLAGS "")
-
-if (Concepts_FOUND AND NOT (TARGET Concepts::concepts))
- set (CMAKE_REQUIRED_FLAGS -fconcepts)
- add_library (Concepts::concepts INTERFACE IMPORTED)
-
- set_target_properties (Concepts::concepts
- PROPERTIES
- INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CXX>:-fconcepts>)
-endif ()
diff --git a/cmake/SeastarDependencies.cmake b/cmake/SeastarDependencies.cmake
--- a/cmake/SeastarDependencies.cmake
+++ b/cmake/SeastarDependencies.cmake
@@ -89,7 +89,6 @@ macro (seastar_find_dependencies)
fmt
lz4
# Private and private/public dependencies.
- Concepts
GnuTLS
LibUring
LinuxMembarrier
diff --git a/cmake/code_tests/Concepts_test.cc b/cmake/code_tests/Concepts_test.cc
--- a/cmake/code_tests/Concepts_test.cc
+++ b/cmake/code_tests/Concepts_test.cc
@@ -1,3 +0,0 @@
-#if __cpp_concepts == 201507
-int main() { return 0; }
-#endif
Reply all
Reply to author
Forward
0 new messages