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

build: enable sse4.2 and ssse3 in zlib #36693

Closed
wants to merge 5 commits into from

Conversation

RaisinTen
Copy link
Contributor

@RaisinTen RaisinTen commented Dec 30, 2020

Fixes: #36678

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the zlib Issues and PRs related to the zlib subsystem. label Dec 30, 2020
@targos
Copy link
Member

targos commented Dec 30, 2020

This is a vendored dependency and we should avoid patching it directly. That said, I'm not sure there's anything to do on our side. In #36678 (comment), compilation is using unsupported GCC 4.8.5 headers, unless I'm misundestanding the directory structure.

@RaisinTen
Copy link
Contributor Author

It's a temporary fix, just like #35679 because #33044 has not landed yet. Should I add a TODO comment to later add -msse4.1 to the build file as a command line option? It sure does look like GCC 4.8.5 to me too, but if the patch passes CI, I think it'll be okay.

@mscdex
Copy link
Contributor

mscdex commented Dec 30, 2020

Should I add a TODO comment to later add -msse4.1 to the build file as a command line option?

That sort of thing (-msse4.1) was actually removed from the gyp file awhile back, so I don't think we should re-add it.

@RaisinTen RaisinTen added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 30, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 30, 2020
@addaleax
Copy link
Member

Should I add a TODO comment to later add -msse4.1 to the build file as a command line option?

That sort of thing (-msse4.1) was actually removed from the gyp file awhile back, so I don't think we should re-add it.

@mscdex This is not “that sort of thing”.

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 30, 2020
@addaleax
Copy link
Member

Should I add a TODO comment to later add -msse4.1 to the build file as a command line option?

Yeah, I think that might be good, as @targos mentioned we don’t want to keep floating patches unless we can avoid it.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 30, 2020
@RaisinTen RaisinTen changed the title build: enable sse4.1 in zlib build: enable sse4.2 in zlib Dec 31, 2020
@RaisinTen
Copy link
Contributor Author

@d-mozulyov can you confirm whether this patch works on your system?

@@ -16,6 +16,9 @@
// clang-format off
#if defined(CRC32_SIMD_SSE42_PCLMUL)
/* Required to make MSVC bot build pass. */
// TODO(raisinten): When https://github.com/nodejs/node/pull/33044 lands,
// remove the next line and add `-msse4.2` to the command line options.
Copy link
Member

Choose a reason for hiding this comment

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

Assuming this lands before #33044, a commit should be added to that PR that resolves this TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CC @richardlau
Please consider adding these options in your PR if you haven't added them already. :)

@d-mozulyov
Copy link

Hello everyone

@RaisinTen,
I tried this patch: RaisinTen@23873bf

In file included from ../deps/zlib/adler32_simd.c:57:0:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/tmmintrin.h:31:3: ошибка: #error "SSSE3 instruction set not enabled"
 # error "SSSE3 instruction set not enabled"

@RaisinTen RaisinTen changed the title build: enable sse4.2 in zlib build: enable sse4.2 and ssse3 in zlib Jan 1, 2021
@RaisinTen
Copy link
Contributor Author

@d-mozulyov I enabled ssse3. Does it work now?

@d-mozulyov
Copy link

@RaisinTen

../deps/zlib/crc32_simd.c:24:0:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/smmintrin.h:31:3: ошибка: #error "SSE4.1 instruction set not enabled"

@RaisinTen
Copy link
Contributor Author

@d-mozulyov how about now?

@d-mozulyov
Copy link

@RaisinTen

In file included from ../deps/zlib/crc_folding.c:24:0:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/wmmintrin.h:34:3: ошибка: #error "AES/PCLMUL instructions not enabled"

Maybe there are some automated tests so that I don't start the build manually?

@RaisinTen
Copy link
Contributor Author

I don't think there is any way to automatically test it out currently because there is no official support for x86 anymore. :/

@RaisinTen
Copy link
Contributor Author

I added the change for this file, does it build now?

@d-mozulyov
Copy link

I would like to clarify a few points

  1. Judging by the logs, version 4.8.5 header files are used. Maybe I installed the GCC incorrectly, but the terminal displays the following:
[osboxes@osboxes node]$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
  1. I am using Linux 64 bit (x86-64 architecture), not x86
  2. Are you sure that it is correct to add a set of supported extensions directly in the code via #pragma?

P.S. Build error:

/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/osboxes/Public/ultra-power/node/out/Release/icupkg)

@RaisinTen
Copy link
Contributor Author

Hmm, that's interesting. What does cc --version produce? Was g++ being used in the last log when the error occurred?
The pragma thing did work for me and that's how I built node 15 on a 32-bit Linux.

@d-mozulyov
Copy link

What does cc --version produce?

[osboxes@osboxes node]$ cc --version
cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.

Was g++ being used in the last log when the error occurred?

It looks like a rebuild is not being called. An error is displayed immediately:

[osboxes@osboxes node]$ make -j4
make -C out BUILDTYPE=Release V=0
make[1]: Вход в каталог `/home/osboxes/Public/ultra-power/node/out'
  LD_LIBRARY_PATH=/home/osboxes/Public/ultra-power/node/out/Release/lib.host:/home/osboxes/Public/ultra-power/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /home/osboxes/Public/ultra-power/node/out/Release/obj/gen; "/home/osboxes/Public/ultra-power/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt68l.dat "/home/osboxes/Public/ultra-power/node/out/Release/obj/gen/icudt68l.dat"
/home/osboxes/Public/ultra-power/node/out/Release/icupkg: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/osboxes/Public/ultra-power/node/out/Release/icupkg)
make[1]: *** [/home/osboxes/Public/ultra-power/node/out/Release/obj/gen/icudt68l.dat] Ошибка 1
make[1]: Выход из каталога `/home/osboxes/Public/ultra-power/node/out'
make: *** [node] Ошибка 2

@RaisinTen
Copy link
Contributor Author

cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

That's where the problem is. Symlinking it to gcc (GCC) 9.2.0 might work.

It looks like a rebuild is not being called. An error is displayed immediately:

Perhaps run a make clean first?

@d-mozulyov
Copy link

d-mozulyov commented Jan 4, 2021

@RaisinTen,

Thank you very much for helping to draw attention to the cc symlink.
Fixed

But now the following error is thrown (original master branch). I don't know yet what to do about it.

  LD_LIBRARY_PATH=/home/osboxes/Public/ultra-power/node/out/Release/lib.host:/home/osboxes/Public/ultra-power/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /home/osboxes/Public/ultra-power/node/out/Release/obj/gen; "/home/osboxes/Public/ultra-power/node/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt68l.dat "/home/osboxes/Public/ultra-power/node/out/Release/obj/gen/icudt68l.dat"
/home/osboxes/Public/ultra-power/node/out/Release/icupkg: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/osboxes/Public/ultra-power/node/out/Release/icupkg)
make[1]: *** [/home/osboxes/Public/ultra-power/node/out/Release/obj/gen/icudt68l.dat] Ошибка 1
make[1]: *** Ожидание завершения заданий...
rm d7aaab5d72533b4e5b426649701051c55476756a.intermediate
make[1]: Выход из каталога `/home/osboxes/Public/ultra-power/node/out'
make: *** [node] Ошибка 2
[osboxes@osboxes node]$ 

@RaisinTen
Copy link
Contributor Author

/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found

It can't find the shared standard C++ library.

What does g++ --version produce? I think that too needs to be symlinked to an appropriate version of g++.

@d-mozulyov
Copy link

@RaisinTen

[osboxes@osboxes ~]$ g++ --version
g++ (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.

@RaisinTen
Copy link
Contributor Author

ls -l $(g++ -print-file-name=libstdc++.so)

Does this print a symlink pointing to /lib64/libstdc++.so.6?

@d-mozulyov
Copy link

@RaisinTen

[osboxes@osboxes ~]$ ls -l $(g++ -print-file-name=libstdc++.so)
lrwxrwxrwx. 1 root root 19 дек 29 05:21 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib64/libstdc++.so -> libstdc++.so.6.0.27

@RaisinTen
Copy link
Contributor Author

RaisinTen commented Jan 7, 2021

Did you add this earlier in your ~/.bashrc?

LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

The gcc documentation mentions it here: https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths

@RaisinTen
Copy link
Contributor Author

@d-mozulyov is the problem solved?

@d-mozulyov
Copy link

@d-mozulyov is the problem solved?

Yep
Thank you so much :)

@RaisinTen
Copy link
Contributor Author

@d-mozulyov awesome! 🎉

@nodejs-github-bot
Copy link
Collaborator

@RaisinTen
Copy link
Contributor Author

cc @addaleax @jasnell
I think this could do another review because I had added changes after your last reviews. PTAL.

@RaisinTen RaisinTen added the review wanted PRs that need reviews. label Feb 4, 2021
@targos
Copy link
Member

targos commented Feb 5, 2021

I the problem is solved, we don't need this change, do we ?

@RaisinTen
Copy link
Contributor Author

@targos I'm not really sure about that. @d-mozulyov could you please confirm that the master branch builds successfully on your machine or is my patch necessary for building Node.js on your tool chain?

@d-mozulyov
Copy link

@targos @RaisinTen
I confirm that the master branch is built without any Pull Requests. Thanks for explaining the problems on my side!

@RaisinTen
Copy link
Contributor Author

@d-mozulyov Thanks for confirming. :)
Closing this as the issue is solved.

@RaisinTen RaisinTen closed this Feb 6, 2021
@RaisinTen RaisinTen deleted the build/enable-sse4.1 branch February 6, 2021 14:01
@RaisinTen RaisinTen removed the review wanted PRs that need reviews. label Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCC make: SSE4.1 instruction set not enabled
7 participants