Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90fbf30

Browse files
authored
build: compile Node.js with C++20 support (#43555)
* build: compile with C++20 support * build: update build-image-sha for gcc 10
1 parent 5580349 commit 90fbf30

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
id: set-output
5454
run: |
5555
if [ -z "${{ inputs.build-image-sha }}" ]; then
56-
echo "build-image-sha=cf814a4d2501e8e843caea071a6b70a48e78b855" >> "$GITHUB_OUTPUT"
56+
echo "build-image-sha=77262e58c37631ab082482f42c33cdf68c6c394b" >> "$GITHUB_OUTPUT"
5757
else
5858
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
5959
fi

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ src_account_for_openssl_unexpected_version.patch
5252
src_stop_using_deprecated_fields_of_fastapicallbackoptions.patch
5353
src_use_supported_api_to_get_stalled_tla_messages.patch
5454
build_don_t_redefine_win32_lean_and_mean.patch
55+
build_compile_with_c_20_support.patch
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <[email protected]>
3+
Date: Wed, 4 Sep 2024 16:39:23 +0200
4+
Subject: build: compile with C++20 support
5+
6+
Refs https://github.com/nodejs/node/pull/45427
7+
8+
V8 requires C++20 support as of https://chromium-review.googlesource.com/c/v8/v8/+/5587859.
9+
10+
This can be removed when Electron upgrades to a version of Node.js containing the required V8 version.
11+
12+
diff --git a/common.gypi b/common.gypi
13+
index 8736ad12eec294070a5160a64248044cd16347c9..216200c279c599f6dee228120ff5f3943fa52ffd 100644
14+
--- a/common.gypi
15+
+++ b/common.gypi
16+
@@ -307,7 +307,7 @@
17+
'VCCLCompilerTool': {
18+
'AdditionalOptions': [
19+
'/Zc:__cplusplus',
20+
- '-std:c++17'
21+
+ '-std:c++20'
22+
],
23+
'BufferSecurityCheck': 'true',
24+
'DebugInformationFormat': 1, # /Z7 embed info in .obj files
25+
@@ -489,7 +489,7 @@
26+
}],
27+
[ 'OS in "linux freebsd openbsd solaris android aix os400 cloudabi"', {
28+
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
29+
- 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++17' ],
30+
+ 'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++20' ],
31+
'defines': [ '__STDC_FORMAT_MACROS' ],
32+
'ldflags': [ '-rdynamic' ],
33+
'target_conditions': [
34+
@@ -660,7 +660,7 @@
35+
['clang==1', {
36+
'xcode_settings': {
37+
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
38+
- 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++17', # -std=gnu++17
39+
+ 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++20', # -std=gnu++20
40+
'CLANG_CXX_LIBRARY': 'libc++',
41+
},
42+
}],

script/spec-runner.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,9 @@ async function runMainProcessElectronTests () {
186186
}
187187

188188
async function installSpecModules (dir) {
189-
// v8 headers use c++17 so override the gyp default of -std=c++14,
190-
// but don't clobber any other CXXFLAGS that were passed into spec-runner.js
191-
const CXXFLAGS = ['-std=c++17', process.env.CXXFLAGS].filter(x => !!x).join(' ');
192-
193189
const env = {
194190
...process.env,
195-
CXXFLAGS,
191+
CXXFLAGS: process.env.CXXFLAGS,
196192
npm_config_msvs_version: '2019',
197193
npm_config_yes: 'true'
198194
};

0 commit comments

Comments
 (0)