Everywhere: Move to C++26

This commit is contained in:
Sönke Holz
2025-12-29 21:51:05 +01:00
committed by Sönke Holz
parent e72ff2dbcf
commit 3c8233af08
26 changed files with 53 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
PROGRAM = little
OBJS = main.o other.o
CXXFLAGS = -g -std=c++23
CXXFLAGS = -g -std=c++26
all: $(PROGRAM)

View File

@@ -3,7 +3,7 @@
echo > $2/Makefile <<-EOF
PROGRAM = $1
OBJS = main.o
CXXFLAGS = -g -std=c++23
CXXFLAGS = -g -std=c++26
all: \$(PROGRAM)

View File

@@ -12,7 +12,7 @@ sed -i "s/\\\$LibName/$3/g" $2/Class1.cpp
echo > $2/Makefile <<-EOF
LIBRARY = $1.so
OBJS = Class1.o
CXXFLAGS = -g -std=c++23
CXXFLAGS = -g -std=c++26
all: \$(LIBRARY)

View File

@@ -43,7 +43,7 @@ Nobody is perfect, and sometimes we mess things up. That said, here are some goo
**Do:**
- Write in idiomatic SerenityOS C++23, using the `AK` containers in all code.
- Write in idiomatic SerenityOS C++26, using the `AK` containers in all code.
- Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 20 or later) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/AdvancedBuildInstructions.md#clang-format-updates) for instructions on how to get an up-to-date version if your OS distribution does not ship clang-format-20.
- Choose expressive variable, function and class names. Make it as obvious as possible what the code is doing.
- Split your changes into separate, atomic commits (i.e. A commit per feature or fix, where the build, tests and the system are all functioning).

View File

@@ -14,7 +14,7 @@ Optional: `fuse2fs` for [building images without root](https://github.com/Sereni
#### GCC 14 or Clang 17+
A host compiler that supports C++23 features is required for building host tools, the newer the better. Tested versions include gcc-14 and Clang 17 through 19.
A host compiler that supports C++26 features is required for building host tools, the newer the better. Tested versions include gcc-14 and Clang 17 through 19.
On Ubuntu gcc-14 is available in the repositories of 24.04 (Noble) and later.
If you are running an older version, you will either need to upgrade, or find an alternative installation source

View File

@@ -5,7 +5,7 @@
## Build Prerequisites
Qt6 development packages and a C++23 capable compiler are required. g++-14 or clang-17 are required at a minimum for c++23 support.
Qt6 development packages and a C++26 capable compiler are required. g++-14 or clang-17 are required at a minimum for c++26 support.
On Debian/Ubuntu required packages include, but are not limited to:

View File

@@ -22,7 +22,7 @@ This is a roughly categorized list of pages relating to SerenityOS and its subpr
- [Issues Found by OSS-Fuzz Continuous Fuzzing](https://bugs.chromium.org/p/oss-fuzz/issues/list?q=label:Proj-serenity)
- [LibJS website](https://serenityos.github.io/libjs-website/)
- [Try LibJS Online!](https://serenityos.github.io/libjs-website/repl/)
- [Compiler Explorer](https://serenity.godbolt.org/): Select "Lagom trunk" under "Libraries" and add the compiler option `-std=c++23`
- [Compiler Explorer](https://serenity.godbolt.org/): Select "Lagom trunk" under "Libraries" and add the compiler option `-std=c++26`
## Related Projects

View File

@@ -45,7 +45,7 @@ Use the following settings to ensure that coc-clangd works out of the box.
```json
{
"clangd.fallbackFlags": ["-std=c++23"],
"clangd.fallbackFlags": ["-std=c++26"],
"clangd.arguments": ["--query-driver=${workspaceFolder}/Toolchain/Local/**/*"],
"semanticTokens.enable": true,
"inlayHint.subSeparator": "︴",

View File

@@ -28,7 +28,7 @@ First, make sure you have a working toolchain and can build and run SerenityOS.
If you're working on the Kernel, just uncomment `#define KERNEL`.
- Edit the `serenity.cxxflags` file to say `-std=c++23 -fsigned-char -fconcepts -fno-exceptions -fno-semantic-interposition -fPIC`
- Edit the `serenity.cxxflags` file to say `-std=c++26 -fsigned-char -fconcepts -fno-exceptions -fno-semantic-interposition -fPIC`
- Edit the `serenity.includes` file to list the following lines:
```
./

View File

@@ -53,7 +53,7 @@ following `c_cpp_properties.json` to circumvent some errors. Even with the confi
"defines": ["DEBUG", "__serenity__"],
"compilerPath": "${workspaceFolder}/Toolchain/Local/x86_64/bin/x86_64-pc-serenity-g++",
"cStandard": "c17",
"cppStandard": "c++23",
"cppStandard": "c++26",
"intelliSenseMode": "linux-gcc-x86",
"compileCommands": "Build/x86_64/compile_commands.json",
"compilerArgs": ["-Wall", "-Wextra", "-Werror"],

View File

@@ -1,5 +1,15 @@
# Flags shared by Lagom (including Ladybird) and Serenity.
set(CMAKE_CXX_STANDARD 23)
# FIXME: Remove this once CMake knows that AppleClang understands -std=c++26.
# see https://gitlab.kitware.com/cmake/cmake/-/issues/27486
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX_FLAGS "-std=c++26")
else()
set(CMAKE_CXX_STANDARD 26)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

View File

@@ -99,12 +99,7 @@ config("compiler_defaults") {
ldflags += [ "-Wl,--color-diagnostics" ]
}
if (current_os == "mac") {
# FIXME: Use -std=c++23 once Xcode's clang supports that.
cflags_cc += [ "-std=c++2b" ]
} else {
cflags_cc += [ "-std=c++23" ]
}
cflags_cc += [ "-std=c++26" ]
cflags_cc += [ "-fvisibility-inlines-hidden" ]

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrew Kaster <andrewdkaster@gmail.com>
Date: Sun, 12 Jun 2022 23:13:56 -0600
Subject: [PATCH] make: Build with c++23 when targeting serenity
Subject: [PATCH] make: Build with c++26 when targeting serenity
---
make/autoconf/flags-cflags.m4 | 8 ++++++--
@@ -12,7 +12,7 @@ Subject: [PATCH] make: Build with c++23 when targeting serenity
5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4
index 88679489fc09019212286e0cb75885a05103dc85..f1cf955434f65b8cecb00af9f600e93089bd5dd0 100644
index 88679489fc09019212286e0cb75885a05103dc85..8222672a1dfe23d40225e631777d5b492a7c6d19 100644
--- a/make/autoconf/flags-cflags.m4
+++ b/make/autoconf/flags-cflags.m4
@@ -187,7 +187,8 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
@@ -39,7 +39,7 @@ index 88679489fc09019212286e0cb75885a05103dc85..f1cf955434f65b8cecb00af9f600e930
AC_MSG_ERROR([Don't know how to enable C++14 for this toolchain])
fi
+ if test "x$OPENJDK_TARGET_OS" = xserenity; then
+ LANGSTD_CXXFLAGS="-std=c++23"
+ LANGSTD_CXXFLAGS="-std=c++26"
+ fi
TOOLCHAIN_CFLAGS_JDK_CXXONLY="$TOOLCHAIN_CFLAGS_JDK_CXXONLY $LANGSTD_CXXFLAGS"
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $LANGSTD_CXXFLAGS"

View File

@@ -5,9 +5,9 @@
make: Add Serenity support, masquerading as BSD when necessary
## `0002-make-Build-with-c-23-when-targeting-serenity.patch`
## `0002-make-Build-with-c-26-when-targeting-serenity.patch`
make: Build with c++23 when targeting serenity
make: Build with c++26 when targeting serenity
## `0003-make-Remove-CUPS-dependency.patch`

View File

@@ -43,9 +43,9 @@ Co-Authored-By: sdomi <ja@sdomi.pl>
src/video/serenity/SDL_serenitymessagebox.h | 38 +
src/video/serenity/SDL_serenitymouse.cpp | 157 +++++
src/video/serenity/SDL_serenitymouse.h | 39 ++
src/video/serenity/SDL_serenityvideo.cpp | 659 ++++++++++++++++++
src/video/serenity/SDL_serenityvideo.cpp | 658 ++++++++++++++++++
src/video/serenity/SDL_serenityvideo.h | 101 +++
21 files changed, 1379 insertions(+), 28 deletions(-)
21 files changed, 1378 insertions(+), 28 deletions(-)
create mode 100644 src/audio/serenity/SDL_serenityaudio.cpp
create mode 100644 src/audio/serenity/SDL_serenityaudio.h
create mode 100644 src/video/serenity/SDL_serenityevents.cpp
@@ -132,7 +132,7 @@ index 4aaae46f6f74428949f32922308f48bd1316e7c1..9491448493b88c7bd54e3fbfcb9e518d
os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
;;
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index ea4c0ff4300ea8dcffad6af9da57ac10d120bc04..172fc896e32902a947788ef11ac3dd67d49c62f4 100644
index ea4c0ff4300ea8dcffad6af9da57ac10d120bc04..033037b4306efa5e9f463c890e4b25157ccb3208 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -809,6 +809,26 @@ macro(CheckDirectFB)
@@ -148,7 +148,7 @@ index ea4c0ff4300ea8dcffad6af9da57ac10d120bc04..172fc896e32902a947788ef11ac3dd67
+ set(HAVE_SDL_VIDEO TRUE)
+ set(HAVE_SDL_AUDIO TRUE)
+
+ set(CMAKE_CXX_FLAGS "-std=c++23 -fno-exceptions ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-std=c++26 -fno-exceptions ${CMAKE_CXX_FLAGS}")
+ file(GLOB SERENITY_SOURCES ${SDL2_SOURCE_DIR}/src/video/serenity/*.cpp ${SDL2_SOURCE_DIR}/src/audio/serenity/*.cpp)
+ list(APPEND SOURCE_FILES ${SERENITY_SOURCES})
+ set(SDL_VIDEO_DRIVER_SERENITY 1)
@@ -910,7 +910,7 @@ index 0000000000000000000000000000000000000000..039f0361b3d1b248e218ea69495f58e5
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/serenity/SDL_serenityvideo.cpp b/src/video/serenity/SDL_serenityvideo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64f956a456730cfd99998566810c04df64a1bfa0
index 0000000000000000000000000000000000000000..9299649cfa64e256c1cee8d138c49cb5fd68cbd8
--- /dev/null
+++ b/src/video/serenity/SDL_serenityvideo.cpp
@@ -0,0 +1,658 @@

View File

@@ -13,7 +13,7 @@ Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
create mode 100644 src/api/dirmonitor/inodewatcher.cpp
diff --git a/meson.build b/meson.build
index 3f88be37..70627782 100644
index 3f88be37c3353869a7db127ccf44cdfcd181cd94..7782ecf9b8bbd4f5cc73f54e774b4afd48707369 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,8 @@ project('lite-xl',
@@ -22,13 +22,13 @@ index 3f88be37..70627782 100644
default_options : [
- 'c_std=gnu11'
+ 'c_std=gnu11',
+ 'cpp_std=c++20'
+ 'cpp_std=c++26'
]
)
diff --git a/src/api/dirmonitor/inodewatcher.cpp b/src/api/dirmonitor/inodewatcher.cpp
new file mode 100644
index 00000000..e749f5bd
index 0000000000000000000000000000000000000000..e749f5bd8c5b16dd348f19bf9f5c450fbe0bf018
--- /dev/null
+++ b/src/api/dirmonitor/inodewatcher.cpp
@@ -0,0 +1,75 @@
@@ -108,7 +108,7 @@ index 00000000..e749f5bd
+
+int get_mode_dirmonitor() { return 2; }
diff --git a/src/main.c b/src/main.c
index dca3cbd1..e11fb7ae 100644
index dca3cbd1eb2990b9f1517a826022f07a21ec9ecb..e11fb7aeb428a38fb43e64cd76424c711c2bf9a5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,7 +9,7 @@
@@ -140,7 +140,7 @@ index dca3cbd1..e11fb7ae 100644
#if !defined(ARCH_PROCESSOR) || !defined(ARCH_PLATFORM)
diff --git a/src/meson.build b/src/meson.build
index a156ae3f..501914c8 100644
index a156ae3f2582d195b6cce1e29c33002c9855238b..501914c8687c944a16a19fd229a843146ad4af18 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -11,20 +11,31 @@ lite_sources = [

View File

@@ -1,7 +1,8 @@
# Patches for Lite-XL on SerenityOS
# Patches for lite-xl on SerenityOS
## `0001-Add-SerenityOS-platform-support.patch`
Add SerenityOS platform support
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>

View File

@@ -8,7 +8,7 @@ Subject: [PATCH] Include strings.h
1 file changed, 1 insertion(+)
diff --git a/src/ppui/BasicTypes.h b/src/ppui/BasicTypes.h
index 20eba8b..e353345 100644
index 20eba8bc79b10ca7cb5f9eb02678c5e493eb55f9..e353345fb0bd485bea10f45954f28ba8dfd3683c 100644
--- a/src/ppui/BasicTypes.h
+++ b/src/ppui/BasicTypes.h
@@ -30,6 +30,7 @@ typedef signed short pp_int16;

View File

@@ -8,7 +8,7 @@ Subject: [PATCH] Remove OpenGL
1 file changed, 2 insertions(+), 40 deletions(-)
diff --git a/src/ppui/sdl/DisplayDevice_SDL.cpp b/src/ppui/sdl/DisplayDevice_SDL.cpp
index a4b966c..7ecedc7 100644
index a4b966cff12fb73d73f970ac610e23bf9df604b0..7ecedc7a369cd862a0e6bd1a9221ff12252e1da1 100644
--- a/src/ppui/sdl/DisplayDevice_SDL.cpp
+++ b/src/ppui/sdl/DisplayDevice_SDL.cpp
@@ -26,30 +26,8 @@

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "jake.westrip" <jake.westrip@lonsec.com.au>
Date: Tue, 27 Apr 2021 18:34:53 +1000
Subject: [PATCH] Set C++ standard to C++20 and remove some unnecessary
Subject: [PATCH] Set C++ standard to C++26 and remove some unnecessary
subdirectories
---
@@ -9,7 +9,7 @@ Subject: [PATCH] Set C++ standard to C++20 and remove some unnecessary
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bdecf1..a64b843 100644
index 4bdecf1b51d6ab14865dd242c98531bbc4d0ebb8..2e7f4339fd056b1bc0f3bd10c1397ce15d77b92b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,8 +22,8 @@
@@ -18,8 +18,8 @@ index 4bdecf1..a64b843 100644
-# Set C++ standard to C++98
-set(CMAKE_CXX_STANDARD 98)
+# Set C++ standard to C++20
+set(CMAKE_CXX_STANDARD 20)
+# Set C++ standard to C++26
+set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_EXTENSIONS OFF)
# Enable IDE solution folders

View File

@@ -8,7 +8,7 @@ Subject: [PATCH] Link against the needed serenity libraries
1 file changed, 3 insertions(+)
diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt
index f4243a0..02f67c0 100644
index f4243a0fff9a462c68add0f6f5e11d956546f93e..02f67c087a4c60a168fdab74f1d9c8f52f340618 100644
--- a/src/tracker/CMakeLists.txt
+++ b/src/tracker/CMakeLists.txt
@@ -374,4 +374,7 @@ else()

View File

@@ -8,7 +8,7 @@ Subject: [PATCH] Replace tmpnam with mkstemp
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ppui/osinterface/posix/PPSystem_POSIX.cpp b/src/ppui/osinterface/posix/PPSystem_POSIX.cpp
index 9b84cfe..03b22b4 100644
index 9b84cfe6e2b3087df8f1215b9ba348f8d30c9b4b..03b22b4834a06b96de644db0bf4ab6de83e01e03 100644
--- a/src/ppui/osinterface/posix/PPSystem_POSIX.cpp
+++ b/src/ppui/osinterface/posix/PPSystem_POSIX.cpp
@@ -67,7 +67,7 @@ const SYSCHAR* System::getTempFileName()

View File

@@ -10,9 +10,9 @@ Include strings.h
Remove OpenGL
## `0003-Set-C-standard-to-C-20-and-remove-some-unnecessary-s.patch`
## `0003-Set-C-standard-to-C-26-and-remove-some-unnecessary-s.patch`
Set C++ standard to C++20 and remove some unnecessary subdirectories
Set C++ standard to C++26 and remove some unnecessary subdirectories
## `0004-Link-against-the-needed-serenity-libraries.patch`

View File

@@ -9,7 +9,7 @@ files=(
)
configure() {
run cmake "${configopts[@]}" -DCMAKE_CXX_FLAGS="-std=c++23 -O2"
run cmake "${configopts[@]}" -DCMAKE_CXX_FLAGS="-std=c++26 -O2"
}
install() {

View File

@@ -13,14 +13,14 @@ Subject: [PATCH] Add support for Serenity LibAudio
create mode 100644 src/sound_serenity.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index b65eb85244acec722b2f240976f184f06db11a27..6745ed1d04cde08b9811781c2bfe552d488a6a82 100644
index b65eb85244acec722b2f240976f184f06db11a27..489085a024711f42722247196532a7c428aeb268 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@
AM_CPPFLAGS = -DSYSCONFDIR=\"${sysconfdir}/${PACKAGE_NAME}\" ${LIBXMP_CFLAGS} \
${alsa_CFLAGS} ${pulseaudio_CFLAGS}
+AM_CXXFLAGS = -std=c++23 -fno-exceptions
+AM_CXXFLAGS = -std=c++26 -fno-exceptions
AM_CFLAGS = -Wall
bin_PROGRAMS = xmp

View File

@@ -4,7 +4,7 @@ include(AddLLVM)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
get_property(CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS GLOBAL PROPERTY CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS)
list(APPEND CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -std=c++23 -Wno-user-defined-literals -Wno-literal-range)
list(APPEND CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -std=c++26 -Wno-user-defined-literals -Wno-literal-range)
# Ensure we always check for invalid function field types regardless of the value of ENABLE_CLANG_PLUGINS_INVALID_FUNCTION_MEMBERS
list(APPEND CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -fplugin-arg-libjs_gc_scanner-detect-invalid-function-members)