From c43003617d32c5b440c740dd47e8648fd4e74316 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 9 Oct 2026 04:25:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Sync=202026-10-09=2004:25:14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gn/Makefile | 8 +- ...0-gn-fix-old-libstdcxx-ranges-unique.patch | 32 +++ gn/patches/020-clang-host-compat.patch | 71 ++++++ ...30-fix-clang-18-and-earlier-expected.patch | 208 ++++++++++++++++++ gn/patches/040-remove-check_all-target.patch | 15 ++ gn/src/out/last_commit_position.h | 4 +- 6 files changed, 332 insertions(+), 6 deletions(-) create mode 100644 gn/patches/010-gn-fix-old-libstdcxx-ranges-unique.patch create mode 100644 gn/patches/020-clang-host-compat.patch create mode 100644 gn/patches/030-fix-clang-18-and-earlier-expected.patch create mode 100644 gn/patches/040-remove-check_all-target.patch diff --git a/gn/Makefile b/gn/Makefile index d2f11d6da..9715e84ce 100644 --- a/gn/Makefile +++ b/gn/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gn -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://gn.googlesource.com/gn.git -PKG_SOURCE_DATE:=2026-06-27 -PKG_SOURCE_VERSION:=8d1b023dec36ab50138d427e807175fd99b5bb57 +PKG_SOURCE_DATE:=2026-09-02 +PKG_SOURCE_VERSION:=356ee8a865882bb3615422539ef262e32b102030 PKG_MIRROR_HASH:=skip PKG_LICENSE:=BSD 3-Clause @@ -43,7 +43,7 @@ define Host/Configure endef define Host/Compile - +$(NINJA) -C $(HOST_BUILD_DIR)/out gn + +$(NINJA) -C $(HOST_BUILD_DIR)/out endef define Host/Install diff --git a/gn/patches/010-gn-fix-old-libstdcxx-ranges-unique.patch b/gn/patches/010-gn-fix-old-libstdcxx-ranges-unique.patch new file mode 100644 index 000000000..42541c2bd --- /dev/null +++ b/gn/patches/010-gn-fix-old-libstdcxx-ranges-unique.patch @@ -0,0 +1,32 @@ +--- a/src/gn/rust_project_writer.cc ++++ b/src/gn/rust_project_writer.cc +@@ -235,8 +235,13 @@ void AddTarget(const BuildSettings* buil + std::ranges::sort(include_dirs, [](const auto& lhs, const auto& rhs) { + return lhs.value() < rhs.value(); + }); ++#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 13 ++ include_dirs.erase(std::unique(include_dirs.begin(), include_dirs.end()), ++ include_dirs.end()); ++#else + include_dirs.erase(std::ranges::unique(include_dirs).begin(), + include_dirs.end()); ++#endif + + Crate crate = Crate(crate_root, include_dirs, crate_id, crate_label, + edition.value_or("2015")); +--- a/src/gn/ninja_binary_target_writer.cc ++++ b/src/gn/ninja_binary_target_writer.cc +@@ -152,8 +152,13 @@ void NinjaBinaryTargetWriter::WritePriva + std::ranges::sort(deps, [](const Target* lhs, const Target* rhs) { + return lhs->module_name() < rhs->module_name(); + }); ++#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 13 ++ auto dirty = std::unique(deps.begin(), deps.end()); ++ deps.erase(dirty, deps.end()); ++#else + auto dirty = std::ranges::unique(deps); + deps.erase(dirty.begin(), dirty.end()); ++#endif + WriteModuleDeps(out, deps, base); + out << "}\n"; + } diff --git a/gn/patches/020-clang-host-compat.patch b/gn/patches/020-clang-host-compat.patch new file mode 100644 index 000000000..3208a6aff --- /dev/null +++ b/gn/patches/020-clang-host-compat.patch @@ -0,0 +1,71 @@ +--- a/build/gen.py ++++ b/build/gen.py +@@ -254,6 +254,23 @@ def is_gcc(cxx): + + return ret.returncode == 0 and "#define __GNUC__" in ret.stdout and not "#define __clang__" in ret.stdout + ++ ++def get_clang_major_version(cxx): ++ """Return Clang's major version, or None when cxx is not Clang.""" ++ ret = subprocess.run( ++ f'{cxx} -dM -E -x c++ -', ++ shell=True, ++ stdin=subprocess.DEVNULL, ++ text=True, ++ capture_output=True) ++ if ret.returncode != 0 or "#define __clang__" not in ret.stdout: ++ return None ++ ++ match = re.search(r'^#define __clang_major__\s+(\d+)$', ++ ret.stdout, re.MULTILINE) ++ return int(match.group(1)) if match else None ++ ++ + def GenerateLastCommitPosition(host, header): + ROOT_TAG = 'initial-commit' + if os.path.isdir(os.path.join(REPO_ROOT, '.git')): +@@ -553,6 +570,12 @@ def WriteGNNinja(path, platform, host, o + libs = [] + + if not platform.is_msvc(): ++ clang_major = get_clang_major_version(cxx) ++ # Clang before 17 uses the draft spelling for C++23. ++ cxx_standard = ('-std=c++2b' ++ if clang_major is not None and clang_major < 17 ++ else '-std=c++23') ++ + if options.debug: + cflags.extend(['-O0', '-g']) + # Enable libc++ or libstdc++ assertions in debug mode. +@@ -625,9 +648,13 @@ def WriteGNNinja(path, platform, host, o + '-Wextra-semi', + '-Wundef', + +- '-std=c++23' ++ cxx_standard + ]) + ++ # Clang gained structured-binding lambda capture support in version 16. ++ if clang_major is not None and clang_major < 16: ++ cflags.append('-DGN_CLANG_BEFORE_16=1') ++ + if is_gcc(cxx): + cflags.append('-Wno-redundant-move') + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336 +--- a/src/gn/command_suggest.cc ++++ b/src/gn/command_suggest.cc +@@ -566,7 +566,14 @@ SuggestResult OutputSuggestions(const st + } + return SuggestResult::kFailure; + } ++#if defined(GN_CLANG_BEFORE_16) ++ const auto& [structured_includer, structured_dep_kind] = ++ includer_targets.front(); ++ const auto includer = structured_includer; ++ const auto dep_kind = structured_dep_kind; ++#else + const auto& [includer, dep_kind] = includer_targets.front(); ++#endif + current_toolchain = includer->label().GetToolchainLabel(); + + std::string_view dep_field = diff --git a/gn/patches/030-fix-clang-18-and-earlier-expected.patch b/gn/patches/030-fix-clang-18-and-earlier-expected.patch new file mode 100644 index 000000000..6b748caf5 --- /dev/null +++ b/gn/patches/030-fix-clang-18-and-earlier-expected.patch @@ -0,0 +1,208 @@ +Subject: [PATCH] gn: support older standard libraries without std::expected + +Provide a Result fallback including constrained value conversion, so lambda +returns can construct Result> in one conversion. + +Signed-off-by: coolsnowwolf + +--- a/src/gn/err.h ++++ b/src/gn/err.h +@@ -5,10 +5,16 @@ + #ifndef TOOLS_GN_ERR_H_ + #define TOOLS_GN_ERR_H_ + +-#include ++#if defined(__has_include) ++# if __has_include() ++# include ++# endif ++#endif + #include + #include ++#include + #include ++#include + #include + + #include "gn/label.h" +@@ -142,6 +148,7 @@ inline Err Ok() { + // std::expected does not allow implicit conversions because you can have + // std::expected. Since that isn't a problem for us, we add the + // implicit conversions. ++#if defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L + template + class Result : public std::expected { + static_assert(!std::is_void_v, "Use Err instead of Result"); +@@ -187,6 +194,146 @@ class Result : public std::expectederror().message(); + } + }; ++#else ++// This is a minimal fallback for GN's Result abstraction. ++// It intentionally implements only the subset of std::expected ++// functionality currently used by GN and is not a general-purpose ++// std::expected replacement. ++template ++class Result { ++ static_assert(!std::is_void_v, "Use Err instead of Result"); ++ static_assert(!std::is_same_v, "Err cannot be the success case"); ++ ++ public: ++ // Implicit conversion from T (always creates a success state). ++ Result(const T& value) : storage_(value) {} ++ ++ Result(T&& value) : storage_(std::move(value)) {} ++ ++ // Match std::expected's converting constructor without requiring two ++ // user-defined conversions (for example, lambda -> std::function -> Result). ++ template ++ requires(!std::is_same_v, Result> && ++ !std::is_same_v, Err> && ++ std::is_constructible_v) ++ explicit(!std::is_convertible_v) Result(U&& value) ++ : storage_(std::in_place_type, std::forward(value)) {} ++ ++ // Implicit conversion from Err (always creates an error state). ++ Result(Err err) : storage_(std::move(err)) { ++ DCHECK(error().has_error()); ++ } ++ ++ bool has_value() const noexcept { ++ return std::holds_alternative(storage_); ++ } ++ ++ bool has_error() const noexcept { ++ return !has_value(); ++ } ++ ++ explicit operator bool() const noexcept { ++ return has_value(); ++ } ++ ++ T& operator*() & { ++ DCHECK(has_value()); ++ return std::get(storage_); ++ } ++ ++ const T& operator*() const& { ++ DCHECK(has_value()); ++ return std::get(storage_); ++ } ++ ++ T&& operator*() && { ++ DCHECK(has_value()); ++ return std::get(std::move(storage_)); ++ } ++ ++ const T&& operator*() const&& { ++ DCHECK(has_value()); ++ return std::get(std::move(storage_)); ++ } ++ ++ T* operator->() { ++ DCHECK(has_value()); ++ return &std::get(storage_); ++ } ++ ++ const T* operator->() const { ++ DCHECK(has_value()); ++ return &std::get(storage_); ++ } ++ ++ T& value() & { ++ DCHECK(has_value()); ++ return std::get(storage_); ++ } ++ ++ const T& value() const& { ++ DCHECK(has_value()); ++ return std::get(storage_); ++ } ++ ++ T&& value() && { ++ DCHECK(has_value()); ++ return std::get(std::move(storage_)); ++ } ++ ++ const T&& value() const&& { ++ DCHECK(has_value()); ++ return std::get(std::move(storage_)); ++ } ++ ++ Err& error() & { ++ DCHECK(has_error()); ++ return std::get(storage_); ++ } ++ ++ const Err& error() const& { ++ DCHECK(has_error()); ++ return std::get(storage_); ++ } ++ ++ Err&& error() && { ++ DCHECK(has_error()); ++ return std::get(std::move(storage_)); ++ } ++ ++ const Err&& error() const&& { ++ DCHECK(has_error()); ++ return std::get(std::move(storage_)); ++ } ++ ++ const std::string& message() const { ++ DCHECK(has_error()); ++ return error().message(); ++ } ++ ++ // Keep the same API provided by the std::expected implementation above. ++ template ++ Result transform_error(F&& f) const& { ++ if (has_value()) ++ return Result(value()); ++ ++ return Result( ++ std::forward(f)(error())); ++ } ++ ++ template ++ Result transform_error(F&& f) && { ++ if (has_value()) ++ return Result(std::move(value())); ++ ++ return Result( ++ std::forward(f)(std::move(error()))); ++ } ++ ++ private: ++ std::variant storage_; ++}; ++#endif + + namespace internal { + +@@ -198,6 +345,7 @@ inline Err GetError(Err&& err) { + return std::move(err); + } + ++#if defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L + template + inline E GetError(const std::expected& exp) { + return exp.error(); +@@ -207,6 +355,17 @@ template + inline E GetError(std::expected&& exp) { + return std::move(exp).error(); + } ++#else ++template ++inline Err GetError(const Result& result) { ++ return result.error(); ++} ++ ++template ++inline Err GetError(Result&& result) { ++ return std::move(result).error(); ++} ++#endif + + } // namespace internal + diff --git a/gn/patches/040-remove-check_all-target.patch b/gn/patches/040-remove-check_all-target.patch new file mode 100644 index 000000000..15a0bf82c --- /dev/null +++ b/gn/patches/040-remove-check_all-target.patch @@ -0,0 +1,15 @@ +--- a/build/gen.py ++++ b/build/gen.py +@@ -490,12 +490,6 @@ + 'check_all', + inputs=[ + ninja.RunBinary( +- 'check_formatter', +- inputs=[ninja.source_file('tools/run_formatter.sh')], +- implicit_inputs=ninja.directory(ninja.source_file('src'), ['target']), +- args='--diff', +- ), +- ninja.RunBinary( + 'check_reference', + inputs=[ninja.source_file('tools/update_reference.sh')], + implicit_inputs=[ diff --git a/gn/src/out/last_commit_position.h b/gn/src/out/last_commit_position.h index 160bbb26a..32319b5f0 100644 --- a/gn/src/out/last_commit_position.h +++ b/gn/src/out/last_commit_position.h @@ -3,7 +3,7 @@ #ifndef OUT_LAST_COMMIT_POSITION_H_ #define OUT_LAST_COMMIT_POSITION_H_ -#define LAST_COMMIT_POSITION_NUM 2434 -#define LAST_COMMIT_POSITION "2434 (8d1b023dec36)" +#define LAST_COMMIT_POSITION_NUM 2552 +#define LAST_COMMIT_POSITION "2552 (356ee8a86588)" #endif // OUT_LAST_COMMIT_POSITION_H_