forked from scylladb/seastar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compat: do not use std::source_location if it is broken
in a recent clang change, __builtin_source_location was added. see https://reviews.llvm.org/rGd61487490022 . but a bug in clang frontend pratically prevents us from using it. see llvm/llvm-project#48230. so before this issue is fixed, we have to prevent clang from using the builtin source location implementation. in this change, a new library is added for introducing the macro of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to use the homebrew implementation of source_location even the header file of <source_location> or <experimental/source_location> can be found by the C++ compiler. please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when performing the test, because we want to ensure that we are using the same CXX_FLAGS as the ones when compiling std-compat.hh. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
- Loading branch information
Showing
5 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# 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) 2022 Kefu Chai ( tchaikov@gmail.com ) | ||
# | ||
|
||
include (CheckCXXSourceCompiles) | ||
include(CMakePushCheckState) | ||
|
||
file (READ ${CMAKE_CURRENT_LIST_DIR}/code_tests/Source_location_test.cc _source_location_test_code) | ||
cmake_push_check_state () | ||
set(CMAKE_CXX_STANDARD ${Seastar_CXX_STANDARD}) | ||
# set(CMAKE_REQUIRED_FLAGS "-std=${Seastar_CXX_STANDARD}") | ||
check_cxx_source_compiles ("${_source_location_test_code}" CxxSourceLocation_SUPPORTED) | ||
cmake_pop_check_state () | ||
|
||
if (NOT (TARGET SourceLocation::source_location)) | ||
add_library (SourceLocation::source_location INTERFACE IMPORTED) | ||
if (NOT CxxSourceLocation_SUPPORTED) | ||
set_target_properties (SourceLocation::source_location | ||
PROPERTIES | ||
INTERFACE_COMPILE_DEFINITIONS SEASTAR_BROKEN_SOURCE_LOCATION) | ||
endif () | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#if __has_include(<source_location>) | ||
#include <source_location> | ||
#endif | ||
|
||
#ifdef __cpp_lib_source_location | ||
using source_location = std::source_location; | ||
#elif __has_include(<experimental/source_location>) | ||
#include <experimental/source_location> | ||
using source_location = std::experimental::source_location; | ||
#endif | ||
|
||
#if defined(__cpp_lib_source_location) || defined(__cpp_lib_experimental_source_location) | ||
struct format_info { | ||
format_info(source_location loc = source_location::current()) noexcept | ||
: loc(loc) | ||
{ } | ||
source_location loc; | ||
}; | ||
#else | ||
struct format_info { }; | ||
#endif | ||
|
||
int main() | ||
{ | ||
format_info fi; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters