This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Move to cxx17.
Needs RevisionPublic

Authored by hctim on Apr 28 2021, 10:56 AM.

Details

Summary

This patch prefers cxx17 to cxx14, if it's available.

Please let me know if there's a good reason to stay at cxx14-only. The
rest of llvm seems to be using cxx17 without problems, and I'd like to
use the 'static inline' members feature of cxx17 to solve a GWP-ASan
dynamic initialization problem in Scudo standalone.

Diff Detail

Event Timeline

hctim created this revision.Apr 28 2021, 10:56 AM
hctim requested review of this revision.Apr 28 2021, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2021, 10:56 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

@srhines, @mcgrathr, @phosek, @echristo - please raise your hand if you foresee any problems with bumping compiler-rt to c++17. The rest of LLVM seems to use it just fine.

phosek accepted this revision.Apr 28 2021, 11:18 AM

I'd slightly prefer setting CXX_STANDARD 17 on individual targets (you might also need CXX_STANDARD_REQUIRED YES if you want to rely on C++17 features) which is a more idiomatic CMake, but either way it's fine with us.

This revision is now accepted and ready to land.Apr 28 2021, 11:18 AM
hctim added a comment.Apr 28 2021, 4:02 PM

I'd slightly prefer setting CXX_STANDARD 17 on individual targets (you might also need CXX_STANDARD_REQUIRED YES if you want to rely on C++17 features) which is a more idiomatic CMake, but either way it's fine with us.

You're right, the patch should be:

-append_string_if(COMPILER_RT_HAS_STD_CXX14_FLAG -std=c++14 CMAKE_CXX_FLAGS)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

I'd still like to hear the reception for upping the build requirements to cxx17. We need to at least do this for scudo/standalone.

I'd slightly prefer setting CXX_STANDARD 17 on individual targets (you might also need CXX_STANDARD_REQUIRED YES if you want to rely on C++17 features) which is a more idiomatic CMake, but either way it's fine with us.

You're right, the patch should be:

-append_string_if(COMPILER_RT_HAS_STD_CXX14_FLAG -std=c++14 CMAKE_CXX_FLAGS)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

I'd still like to hear the reception for upping the build requirements to cxx17. We need to at least do this for scudo/standalone.

Modifying global variables is highly discouraged in modern CMake. Ideally we would set that as a property on the target like we do for example in libcxx. Since all compiler-rt runtimes are created via add_compiler_rt_runtime function, it should be possible to just set that property there.

@srhines, @mcgrathr, @phosek, @echristo - please raise your hand if you foresee any problems with bumping compiler-rt to c++17. The rest of LLVM seems to use it just fine.

+1 ok from me

@llozano might also care about this, but I suspect it's ok.

@srhines, @mcgrathr, @phosek, @echristo - please raise your hand if you foresee any problems with bumping compiler-rt to c++17. The rest of LLVM seems to use it just fine.

+1 Fuchsia has been using 17 for a long time now. The only concern we have is that public headers (e.g. <sanitizer/asan_interface.h> et al) remain compatible with C++14 (since our public-facing headers must too, though our internal code uses 17 freely). Since most of them are compatible with C and very minimal C++ already, that doesn't seem like a problem in practice. It would be ideal for the public facing APIs to be tested against users in multiple -std modes by their own regression tests.

(I'll defer to @phosek on the cmake issues.)

vitalybuka accepted this revision.Apr 28 2021, 7:57 PM

I see a lot of inline variables are a C++17 extension [-Wc++17-extensions]
we probably need to add -Wno-c++17-extensions

vitalybuka added inline comments.Apr 28 2021, 10:42 PM
compiler-rt/CMakeLists.txt
273

Actually I see c++14 still there

Why we don't use?
set (CMAKE_CXX_STANDARD 17)

vitalybuka requested changes to this revision.Apr 28 2021, 10:44 PM
This revision now requires changes to proceed.Apr 28 2021, 10:44 PM