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

Skip to content

build: compile Node.js with C++20 support #43555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 11, 2024
Merged

build: compile Node.js with C++20 support #43555

merged 2 commits into from
Sep 11, 2024

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Sep 4, 2024

Description of Change

Closes #43580

Refs nodejs/node#45427
Refs nodejs/node#52870

V8 updated their required version of c++ in https://chromium-review.googlesource.com/c/v8/v8/+/55
87859 and we did not accordingly follow suit.

Checklist

Release Notes

Notes: none

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/31-x-y PR should also be added to the "31-x-y" branch. target/32-x-y PR should also be added to the "32-x-y" branch. target/33-x-y PR should also be added to the "33-x-y" branch. labels Sep 4, 2024
@codebytere codebytere requested a review from a team as a code owner September 4, 2024 15:01
@codebytere codebytere changed the title build: compile with C++20 support build: compile Node.js with C++20 support Sep 4, 2024
// but don't clobber any other CXXFLAGS that were passed into spec-runner.js
const CXXFLAGS = ['-std=c++17', process.env.CXXFLAGS].filter(x => !!x).join(' ');
const CXXFLAGS = ['-std=c++20', process.env.CXXFLAGS].filter(x => !!x).join(' ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const CXXFLAGS = ['-std=c++20', process.env.CXXFLAGS].filter(x => !!x).join(' ');
const CXXFLAGS = ['-std=gnu++20', process.env.CXXFLAGS].filter(x => !!x).join(' ');

if the CI uses gcc <= 9 then it would be -std=gnu++2a but no need to make the condition if it passes with the above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new to this PR -- for example, I see we had gnu++17 before -- but does anyone know if the GNU extensions are actually needed here?

Unless we need the GNU extensions, we'd be better off using the standard, i.e. -std=c++20 here and in the patch above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use it but the headers from Node.js could, but I missed this before but we should actually remove the -std argument from this list, it will get set by common.gypi when building the native modules. We were overriding previously when headers had c++14 and we wanted to use c++17.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@deepak1556 deepak1556 removed the target/31-x-y PR should also be added to the "31-x-y" branch. label Sep 4, 2024
@deepak1556
Copy link
Member

V8 change landed first in Chromium 127, removing 31-x-y label.

Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codebytere
Copy link
Member Author

g++: error: unrecognized command line option '-std=gnu++20'; did you mean '-std=gnu++2a'?

some failures - investigating!

@deepak1556
Copy link
Member

@codebytere that is the one I mentioned in #43555 (comment). If the CI uses gcc <= 9 which in this case seems to be we would need to override the CXXFLAGS. You can get the version from g++ -dumpversion.

@codebytere
Copy link
Member Author

@deepak1556 ah understood - i read #43555 (comment) as meaning we should just remove it entirely.

@deepak1556
Copy link
Member

i read #43555 (comment) as meaning we should just remove it entirely.

You are correct, I did mean we could remove it completely if CI passed by using newer gcc which I was not sure when the comment was made. Given the current failure we had to bring this back.

@erickzhao erickzhao added the needs-docs An API or larger change that needs expanded documentation label Sep 10, 2024
@jkleinsc jkleinsc merged commit 90fbf30 into main Sep 11, 2024
50 of 51 checks passed
@jkleinsc jkleinsc deleted the v8-cpp20 branch September 11, 2024 13:01
@release-clerk
Copy link

release-clerk bot commented Sep 11, 2024

No Release Notes

@trop
Copy link
Contributor

trop bot commented Sep 11, 2024

I was unable to backport this PR to "32-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/32-x-y and removed target/32-x-y PR should also be added to the "32-x-y" branch. labels Sep 11, 2024
@trop
Copy link
Contributor

trop bot commented Sep 11, 2024

I have automatically backported this PR to "33-x-y", please check out #43684

@trop trop bot added in-flight/33-x-y merged/33-x-y PR was merged to the "33-x-y" branch. and removed target/33-x-y PR should also be added to the "33-x-y" branch. in-flight/33-x-y labels Sep 11, 2024
@gdavidkov
Copy link

Is it possible to be merged into 32-x-y branch?

@amitparida
Copy link

When is this change expected to be released in an electron version?

ckerr pushed a commit that referenced this pull request Sep 18, 2024
* build: compile with C++20 support

* build: update build-image-sha for gcc 10
@trop
Copy link
Contributor

trop bot commented Sep 18, 2024

@ckerr has manually backported this PR to "32-x-y", please check out #43785

codebytere added a commit that referenced this pull request Sep 19, 2024
build: compile Node.js with C++20 support (#43555)

* build: compile with C++20 support

* build: update build-image-sha for gcc 10

Co-authored-by: Shelley Vohr <[email protected]>
@trop trop bot added merged/32-x-y PR was merged to the "32-x-y" branch. and removed in-flight/32-x-y labels Sep 19, 2024
@Spartan-Hex-Shadow
Copy link

Will there be a new 32-x-y release with this issue fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/32-x-y PR was merged to the "32-x-y" branch. merged/33-x-y PR was merged to the "33-x-y" branch. needs-docs An API or larger change that needs expanded documentation semver/patch backwards-compatible bug fixes
Projects
None yet
8 participants