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

libatomic for s390x #27377

Closed
nealef opened this issue Apr 24, 2019 · 13 comments
Closed

libatomic for s390x #27377

nealef opened this issue Apr 24, 2019 · 13 comments
Labels
question Issues that look for answers. s390 Issues and PRs related to the s390 architecture. v8 engine Issues and PRs related to the V8 dependency.

Comments

@nealef
Copy link

nealef commented Apr 24, 2019

Is your feature request related to a problem? Please describe.
Building node for s390x requires libatomic as the comment in v8.gyp reports:

       # Platforms that don't have Compare-And-Swap support need to link atomic
       # library to implement atomic memory access

Describe the solution you'd like
s390x has many atomic instructions including a few compare-and-swap instructions (differing on operand size).

Describe alternatives you've considered
I am curious as to which atomic operations are required and where in the code they are. I would look at adding them to eliminate the need for libatomic.

@bnoordhuis bnoordhuis added question Issues that look for answers. s390 Issues and PRs related to the s390 architecture. v8 engine Issues and PRs related to the V8 dependency. labels Apr 24, 2019
@bnoordhuis
Copy link
Member

The file you're interested in is atomicops_internals_portable.h.

It's possible GCC knows how to emit instructions for some __atomic_*() intrinsincs. You can find out by removing -latomic from the link flags and checking the unresolved symbols (or rather: the symbols that are not unresolved.)

@nealef
Copy link
Author

nealef commented Apr 24, 2019

I took out the -latomic for s390x and I didn't get errors linking node.

--- a/tools/v8_gypfiles/v8.gyp  2019/04/24 14:31:16 1.1
+++ b/tools/v8_gypfiles/v8.gyp  2019/04/24 14:31:47
@@ -391,11 +391,11 @@
         }],
         # Platforms that don't have Compare-And-Swap support need to link atomic
         # library to implement atomic memory access
-        [ 'v8_current_cpu in ["mips", "mipsel", "mips64", "mips64el", "ppc", "ppc64", "s390", "s390x"]', {
+        [ 'v8_current_cpu in ["mips", "mipsel", "mips64", "mips64el", "ppc", "ppc64"]', {
             'link_settings': {
               'libraries': [ '-latomic', ],
             },
           },
         ],
         ['OS=="win"', {
           'msvs_precompiled_header': '<(V8_ROOT)/../../tools/msvs/pch/v8_pch.h',

However, I am getting these errors when I use devtoolset-6 and devtoolset-8 during the %install part of the RPM build.

DEBUG:   g++ -o /builddir/build/BUILD/node-v12.0.0/out/Release/mksnapshot -pthread -rdynamic -m64 -march=z196 -m64 -lstdc++ -Wl,--start-group /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/mksnapshot/deps/v8/src/snapshot/embedded-file-writer.o /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_base.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_init.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_libbase.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_nosnapshot.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/icu/libicui18n.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_libsampler.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/icu/libicuucx.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/icu/libicudata.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/icu/libicustubdata.a /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/tools/v8_gypfiles/libv8_initializers.a -ldl -lrt -Wl,--end-group
DEBUG: /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/v8_base/deps/v8/src/compiler/verifier.o: In function `v8::internal::compiler::ScheduleVerifier::Run(v8::internal::compiler::Schedule*)':
DEBUG: (.text._ZN2v88internal8compiler16ScheduleVerifier3RunEPNS1_8ScheduleE+0x216): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
DEBUG: (.text._ZN2v88internal8compiler16ScheduleVerifier3RunEPNS1_8ScheduleE+0xc28): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
DEBUG: /builddir/build/BUILD/node-v12.0.0/out/Release/obj.target/v8_base/deps/v8/src/elements.o: In function `v8::internal::(anonymous namespace)::FastPackedSmiElementsAccessor::~FastPackedSmiElementsAccessor()':
DEBUG: (.text._ZN2v88internal12_GLOBAL__N_129FastPackedSmiElementsAccessorD0Ev+0x12): undefined reference to `operator delete(void*, unsigned long)'

@mhdawson
Copy link
Member

@sam-github can you comment as I know you ran into issues with libatomic.

@mhdawson
Copy link
Member

@john-yan in case you can shed any additional insight as well.

@sam-github
Copy link
Contributor

@nealef what compiler toolchain are you using when you don't get errors?

you may find select-compiler interesting, it shows how we build node for the various branches:

https://github.com/nodejs/build/blob/0aaa408e1816b55bf4ec75e4e79dbdf0e215dab3/jenkins/scripts/select-compiler.sh#L52-L80

I found libatomic necessary on centos7 ppc64, see nodejs/build@c6e9433

@nealef
Copy link
Author

nealef commented Apr 24, 2019

@sam-github I haven't built 12 cleanly yet as I was on a system with a gcc 4.8.5 toolchain so I tried both devtoolset-6 and devtoolset-8 where I got the same type of errors. I will check that link you provided.

@nealef
Copy link
Author

nealef commented Apr 24, 2019

@sam-github I think I found the problem. The RPM spec file has a . /opt/rh/devtoolset-8/enable in the %build but not in the %install.

@nealef
Copy link
Author

nealef commented Apr 24, 2019

@sam-github Confirm a clean build with devtoolset-8

@sam-github
Copy link
Contributor

sam-github commented Apr 24, 2019

So, @nealef, you are finding that -latomic is not needed with devtoolset-8 on linux-s390x?

FYI, node builds with devtoolset-6 (EDIT: on 12.x), so it would have to be reconfirmed with that.

Also, while we are moving to using devtoolset when we can, it creates slightly more portable binaries, I'm not sure if we require people building from source to use it, we might also want to support gcc-6 (EDIT: on 12.x).

All of which is to say, does having -latomic on the link line cause problems? Are you requesting it be removed? If so, on what release lines, for what platforms?

@sam-github
Copy link
Contributor

wrt.

The RPM spec file has a . /opt/rh/devtoolset-8/enable in the %build but not in the %install.

That sounds a bit like there might be an oddity elsewhere, either in node's install target, or in the rpm specfile. IIRC, the intention with rpm specfiles is that all building occur in the %build, so %install shouldn't require the toolset to be enabled. A workaround of always enabling the toolset doesn't seem so bad, but if something is broken, feel free to open a bug. Also, again just FYI, even though we use devtoolset, distro packagers aren't required to do so, they might have othe ways of dealing with binary compatibility. Also, when a binary is built for a specific distro, its not usual to want to copy it to another older version of the distro (or a completely different distroy), and run it. There has even been some cricism of devtoolset because it links code into the executable that is usually provided by shared libaries, preventing that code from being upgradeable by the distro in cases of bugs or sec problems. At a micro scale, this is similar to why distros link against shared openssl usually, instead of allowing node ot statically link its own. I don't know exactly what you are doing, so maybe none of this applies to you. YMMV.

@nealef
Copy link
Author

nealef commented Apr 24, 2019

@sam-github Confirm that -latomic is not required for s390/s390x.

The %install section does a make install that results in building stuff that is used by %check. devtoolset-8-libstdc++ uses the 4.8.5 shared object for most things but will statically link in specific functions that have been added.

Hopefully with RHEL 8 and then CentOS 8 the need to use devtoolset will be eliminated.

@sam-github
Copy link
Contributor

Does %build do a make all?

@nealef
Copy link
Author

nealef commented Apr 25, 2019

No. The spec file came from the source tarball so I hadn't touched that bit.

sam-github referenced this issue in v8/v8 Sep 26, 2019
MIPS architecture doesn't have support for 64-bit atomics.
It is possible to implement them using 32-bit atomics,
but the process is involved and takes time. For the time
being support 64-bit atomics using runtime.

Bug: v8:8100
Change-Id: I8c732ea9975c46be70643a1e722d78938c8a70de
Reviewed-on: https://chromium-review.googlesource.com/1251521
Commit-Queue: Ivica Bogosavljevic <ibogosavljevic@wavecomp.com>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56331}
sam-github added a commit to sam-github/node that referenced this issue Oct 1, 2019
The library is not necessary for ppc64 or s390x. It does no harm with
some linkers, but devtoolset-6 creates runtime dependencies on all link
libraries, even unused ones.

Fixes: nodejs#27377
Fixes: nodejs#29718
sam-github added a commit that referenced this issue Oct 1, 2019
PR-URL: #29727
Fixes: #27377
Fixes: #29718
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR pushed a commit that referenced this issue Oct 9, 2019
The library is not necessary for ppc64 or s390x. It does no harm with
some linkers, but devtoolset-6 creates runtime dependencies on all link
libraries, even unused ones.

Fixes: #27377
Fixes: #29718

PR-URL: #29727
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR pushed a commit that referenced this issue Oct 9, 2019
PR-URL: #29727
Fixes: #27377
Fixes: #29718
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers. s390 Issues and PRs related to the s390 architecture. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants