Skip to content
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

deps: backport ICU-22787 to fix ClangCL on Windows #54502

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

StefanStojanovic
Copy link
Contributor

This is a change I landed in the ICU at unicode-org/icu#3023. It is needed to enable ClangCL compilation for Node.js on Windows and that's why I'm porting it manually now before the next ICU update. After this PR lands, I'll open a follow-up one changing the icu-generic.gyp to take advantage of the ICU changes.

This PR aims to do the same thing as #54448, but in the correct way.

NOTE: Since this is a patch to be made unnecessary by the next ICU release, I fixed issues with #include ... in patch files by copying .h files to the directories that need them (where .c files that include them are), rather than fixing everything cleanly, as that would require bigger changes in configure.py for a feature that was last used in 2019.

cc @richardlau

@StefanStojanovic StefanStojanovic added windows Issues and PRs related to the Windows platform. dependencies Pull requests that update a dependency file. labels Aug 22, 2024
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. i18n-api Issues and PRs related to the i18n implementation. icu Issues and PRs related to the ICU dependency. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. labels Aug 22, 2024
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@StefanStojanovic
Copy link
Contributor Author

The only failure is on SmartOS, and the reason is ld: fatal: symbol 'main' is multiply-defined. It is most likely related to the changes I introduced in the second commit. Since I have no experience with that platform, can someone from the @nodejs/platform-smartos please take a look and help me with this.

The ICU patching hasn't been used recently (and will probably not be used a lot in the future) and if fixing this for SmartOS proves to be hard, I'd probably revisit my initial approach and try to land it.

@bahamat
Copy link

bahamat commented Aug 23, 2024

The only failure is on SmartOS, and the reason is ld: fatal: symbol 'main' is multiply-defined.

@StefanStojanovic We'll take a look at it.

@danmcd
Copy link

danmcd commented Aug 23, 2024

The only failure is on SmartOS, and the reason is ld: fatal: symbol 'main' is multiply-defined.

@StefanStojanovic We'll take a look at it.

I saw an odd use of extern for one program's main. I pointed it as a code comment.

And in general, if you see a multiply-defined error, check every .o file you generate with: nm $OFILE | grep -w main and see if more than one shows GLOB as its scope. That'll help debug things. Some more context (what was being compiled; I see there are multiple program binaries getting generated), surrounding the multiply-defined error would be helpful.

@StefanStojanovic
Copy link
Contributor Author

I saw an odd use of extern for one program's main. I pointed it as a code comment.

I do not see this comment, but I assume you're talking about the main function in genccode.c as that's the only one I see with extern. It is still unclear to me why would it cause problems only on SmartOS.

And in general, if you see a multiply-defined error, check every .o file you generate with: nm $OFILE | grep -w main and see if more than one shows GLOB as its scope. That'll help debug things. Some more context (what was being compiled; I see there are multiple program binaries getting generated), surrounding the multiply-defined error would be helpful.

Thanks for the clarification. As I said I do not have access to SmartOS and this build only fails there (other platforms are fine), so I couldn't debug it, or run any additional commands eg. nm. This is probably related to the way ICU patches are applied when made this way, because if I change code in deps/icu-small directly, SmartOS passes build, like all of the other platforms as seen in my other PR.

@tsoome
Copy link

tsoome commented Aug 23, 2024

The only failure is on SmartOS, and the reason is ld: fatal: symbol 'main' is multiply-defined. It is most likely related to the changes I introduced in the second commit. Since I have no experience with that platform, can someone from the @nodejs/platform-smartos please take a look and help me with this.

The ICU patching hasn't been used recently (and will probably not be used a lot in the future) and if fixing this for SmartOS proves to be hard, I'd probably revisit my initial approach and try to land it.

The multiply defined error is this:

(file /home/tsoome/node/out/Release/obj.target/genccode/tools/icu/patches/75/source/tools/genccode/genccode.o type=FUNC; file /home/tsoome/node/out/Release/obj.target/tools/icu/libicutools.a(pkgdata.o) type=FUNC);

So, it happens because both object files have symbol main, and indeed, this patch did add one into genccode.o. This error depends on compiler version used for linking, the check was introduced in gcc 10 (here, in my example I have gcc 14). The fix is to make sure there is no duplicate version (or you can suppress the warning, but then the question would be, which symbol is actually used to link the binary;)

Copy link
Member

@srl295 srl295 left a comment

Choose a reason for hiding this comment

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

Generally LGTM: it could be helpful to put a comment in the header of the patched files.

But you need to completely backout the .gyp changes relating to pkgdata. We setup node.js to not need pkgdata (and that's a good thing). Please don't re-add it, especially not adding the tool's main to the utility library. I've made requested changes.

@@ -371,6 +371,7 @@
'<@(icu_src_common)',
'<@(icu_src_i18n)',
'<@(icu_src_stubdata)',
'<@(icu_src_pkgdata)',
Copy link
Member

Choose a reason for hiding this comment

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

No, pkgdata is a tool, it may not be part of this library.

Suggested change
'<@(icu_src_pkgdata)',

configure.py Outdated
@@ -2048,6 +2048,7 @@ def icu_download(path):
'genccode': 'tools/genccode',
'genrb': 'tools/genrb',
'icupkg': 'tools/icupkg',
'pkgdata': 'tools/pkgdata',
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
'pkgdata': 'tools/pkgdata',

maybe unneeded

Copy link
Member

Choose a reason for hiding this comment

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

pkgdata is not used by Node.js. It's fine to add this file for completeness, but please don't try to build pkgdata from Node.js (unless you have some other reason for doing so?)

@srl295
Copy link
Member

srl295 commented Aug 26, 2024

NOTE: Since this is a patch to be made unnecessary by the next ICU release, I fixed issues with #include ... in patch files by copying .h files to the directories that need them (where .c files that include them are), rather than fixing everything cleanly, as that would require bigger changes in configure.py for a feature that was last used in 2019.

Let's not disparage a feature last used in 2019. (Edit: I think part of why it's not used as much is because people are doing a better job of upstreaming changes to ICU ahead of time. Also because of v8/icu/ecma402 changes, it's very likely that we could have critical things to patch with a v8 update when expectations change. )

Can you give an example of what you are talking about with the .h and .c files because I'm not following?

@srl295 srl295 requested a review from targos August 26, 2024 15:19
@srl295 srl295 assigned srl295 and unassigned srl295 Aug 26, 2024
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 27, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 27, 2024
@nodejs-github-bot
Copy link
Collaborator

@StefanStojanovic
Copy link
Contributor Author

Thanks a lot @srl295 both for reviewing here and our discussion in DM yesterday! Based on your suggestions, I made the changes you asked for and the CI is now green.

@bahamat
Copy link

bahamat commented Aug 27, 2024

@StefanStojanovic The GitHub status check for SmartOS is passing now. So it looks like our part, at least, is done. Let me know if there's anything else you need from me on this issue.

Thanks for getting us involved to help out.

@StefanStojanovic
Copy link
Contributor Author

@StefanStojanovic The GitHub status check for SmartOS is passing now. So it looks like our part, at least, is done. Let me know if there's anything else you need from me on this issue.

Thanks for getting us involved to help out.

I apologize for forgetting this, but big thanks to the @nodejs/platform-smartos team and everyone else who helped as well for looking into the problem. As it turns out only SmartOS reported something that should be caught thus helping in debugging this issue.

@StefanStojanovic StefanStojanovic added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 27, 2024
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Aug 27, 2024
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/54502
✔  Done loading data for nodejs/node/pull/54502
----------------------------------- PR info ------------------------------------
Title      deps: backport ICU-22787 to fix ClangCL on Windows (#54502)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     StefanStojanovic:mefi-icu-2 -> nodejs:main
Labels     windows, build, tools, i18n-api, needs-ci, dependencies, icu
Commits    2
 - deps: backport ICU-22787 to fix ClangCL on Windows
 - build: add required ICU patch changes
Committers 1
 - StefanStojanovic <stefan.stojanovic@janeasystems.com>
PR-URL: https://github.com/nodejs/node/pull/54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Thu, 22 Aug 2024 16:48:15 GMT
   ✔  Approvals: 2
   ✔  - Steven R Loomis (@srl295): https://github.com/nodejs/node/pull/54502#pullrequestreview-2264008268
   ✔  - Richard Lau (@richardlau) (TSC): https://github.com/nodejs/node/pull/54502#pullrequestreview-2264011747
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-08-27T08:22:34Z: https://ci.nodejs.org/job/node-test-pull-request/61530/
- Querying data for job/node-test-pull-request/61530/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 54502
From https://github.com/nodejs/node
 * branch                  refs/pull/54502/merge -> FETCH_HEAD
✔  Fetched commits as d813634424fb..b2555ae36158
--------------------------------------------------------------------------------
[main 77dc502056] deps: backport ICU-22787 to fix ClangCL on Windows
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Wed Aug 21 13:38:41 2024 +0200
 5 files changed, 4906 insertions(+)
 create mode 100644 tools/icu/patches/75/source/common/unicode/platform.h
 create mode 100644 tools/icu/patches/75/source/tools/genccode/genccode.c
 create mode 100644 tools/icu/patches/75/source/tools/pkgdata/pkgdata.cpp
 create mode 100644 tools/icu/patches/75/source/tools/toolutil/pkg_genc.cpp
 create mode 100644 tools/icu/patches/75/source/tools/toolutil/pkg_genc.h
[main ead39e8b86] build: add required ICU patch changes
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Thu Aug 22 15:18:06 2024 +0200
 1 file changed, 111 insertions(+)
 create mode 100644 tools/icu/patches/75/source/tools/genccode/pkg_genc.h
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
Rebasing (2/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
deps: backport ICU-22787 to fix ClangCL on Windows

  • Floating patch for ICU 75.x

ICU Bug: https://unicode-org.atlassian.net/browse/ICU-22787
Backport of: unicode-org/icu#3023

PR-URL: #54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>

[detached HEAD 44e735b145] deps: backport ICU-22787 to fix ClangCL on Windows
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Wed Aug 21 13:38:41 2024 +0200
5 files changed, 4906 insertions(+)
create mode 100644 tools/icu/patches/75/source/common/unicode/platform.h
create mode 100644 tools/icu/patches/75/source/tools/genccode/genccode.c
create mode 100644 tools/icu/patches/75/source/tools/pkgdata/pkgdata.cpp
create mode 100644 tools/icu/patches/75/source/tools/toolutil/pkg_genc.cpp
create mode 100644 tools/icu/patches/75/source/tools/toolutil/pkg_genc.h
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build: add required ICU patch changes

Copied .h file to a patched folder to fix include issues.

PR-URL: #54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>

[detached HEAD fd9ac6f4c2] build: add required ICU patch changes
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Thu Aug 22 15:18:06 2024 +0200
1 file changed, 111 insertions(+)
create mode 100644 tools/icu/patches/75/source/tools/genccode/pkg_genc.h

Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/10583839162

@StefanStojanovic StefanStojanovic added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Aug 27, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 27, 2024
@nodejs-github-bot nodejs-github-bot merged commit ebaabf6 into nodejs:main Aug 27, 2024
62 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in ebaabf6

StefanStojanovic added a commit to JaneaSystems/node that referenced this pull request Aug 30, 2024
This uses the previously backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
StefanStojanovic added a commit to JaneaSystems/node that referenced this pull request Aug 30, 2024
This uses the previously backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
Fixes: nodejs#34201
StefanStojanovic added a commit to JaneaSystems/node that referenced this pull request Aug 30, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
Fixes: nodejs#34201
StefanStojanovic added a commit to JaneaSystems/node that referenced this pull request Aug 30, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
Fixes: nodejs#34201
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
- Floating patch for ICU 75.x

ICU Bug: https://unicode-org.atlassian.net/browse/ICU-22787
Backport of: unicode-org/icu#3023

PR-URL: #54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
- Floating patch for ICU 75.x

ICU Bug: https://unicode-org.atlassian.net/browse/ICU-22787
Backport of: unicode-org/icu#3023

PR-URL: #54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
StefanStojanovic added a commit to JaneaSystems/node that referenced this pull request Aug 30, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
Fixes: nodejs#34201
@RafaelGSS RafaelGSS mentioned this pull request Aug 30, 2024
nodejs-github-bot pushed a commit that referenced this pull request Sep 9, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: #54502
Fixes: #34201
PR-URL: #54655
Refs: #52809
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Steven R Loomis <srl295@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Sep 16, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: #54502
Fixes: #34201
PR-URL: #54655
Refs: #52809
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Steven R Loomis <srl295@gmail.com>
@targos targos added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label Sep 22, 2024
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
- Floating patch for ICU 75.x

ICU Bug: https://unicode-org.atlassian.net/browse/ICU-22787
Backport of: unicode-org/icu#3023

PR-URL: nodejs#54502
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
This uses the backported ICU fix needed for compiling with ClangCL.

Refs: nodejs#54502
Fixes: nodejs#34201
PR-URL: nodejs#54655
Refs: nodejs#52809
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Steven R Loomis <srl295@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. dependencies Pull requests that update a dependency file. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. i18n-api Issues and PRs related to the i18n implementation. icu Issues and PRs related to the ICU dependency. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants