node icon indicating copy to clipboard operation
node copied to clipboard

please allow the use of the simdjson library provided by the distribution

Open williamh opened this issue 9 months ago • 6 comments

Hi, I am the primary maintainer of nodejs on Gentoo linux. nodejs 22.1.0 bundles an old version of simdjson which causes it to not build with gcc-14.x. see this bug for more information. Can you please allow nodejs to build using the distribution provided libsimdjson maybe by allowing a configure toggle? Thanks much for your time.

williamh avatar May 09 '24 04:05 williamh

@anonrig @lemire

benjamingr avatar May 09 '24 11:05 benjamingr

nodejs 22.1.0 bundles an old version of simdjson which causes it to not build with gcc-14.x.

I think that Node.js 22.1.0 released with recent dependencies. I don't think that's a fault in Node.js.

A timeline might be useful (reverse chronological order).

  • We are May 9 2024. You can grab gentoo and build Node 22.1.0 with the bleeding edge compiler GCC 14 opted in. It always worked with default compiler (GCC 13).
  • Gentoo included GCC 14 in its tree on May 7, as an opt in. Trivially, gentoo could check that this would break some builds, but my understanding is that gentoo did this opt-in move to allow testing. That is, nobody should be using GCC 14 for production systems. This release of GCC 14 triggered an issue with gentoo users who had opted in for GCC 14 and wanted to build Node.js from source. This affected not just the latest release of Node.js, but also previous releases: the key ingredient being the breaking change introduced by GCC 14. A patch was applied on May 7 (same day) to the gentoo tree, fixing the issue.
  • The first GCC 14 public release (14.1) is dated from May 6 2024. It introduced a breaking change which affected the simdjson library with respect to releases prior to that of April 5 2024.
  • Node 22.1.0 was released May 2nd 2024. GCC 14 was not part of its CI testing at the time. It did not include the very latest versions from simdjson (although it did include a recent release, it missed the latest patch by a week or so).
  • On April 5, an issue was identified with a breaking change introduced by GCC 14 by RedHat: macros like __AVX2__ used to be constant within the compilation of a given unit, but was changed so that they reflect the current set of the enabled/disabled ISAs in the region. Once the issue had been identified and characterized, patched releases were produced from simdjson and simdutf (the same day). I believe that gentoo immediately adopted the newly patched version (same day).

I submit to you that the system works as it should. Currently, Node.js is still at simdjson 3.8, but 3.9 will eventually be folded in and be part of future releases.

I do not object to the unbundling.

lemire avatar May 09 '24 14:05 lemire

I understand there are situations where bundling the library is helpful, but bundling has significant drawbacks as well, so Gentoo prefers using unbundled libraries when possible. This is our documentation on the subject. Please let me know what you think.

williamh avatar May 09 '24 16:05 williamh

I understand there are situations where bundling the library is helpful, but bundling has significant drawbacks as well, so Gentoo prefers using unbundled libraries when possible.

The issue, as you raised it, as to do with unbundling simdjson specifically. It is also the specific subject of the gentoo bug. I submit to you that the argument should apply to ada, simdutf, ngtcp2, and possibly other bundled dependencies.

Correct?

lemire avatar May 09 '24 17:05 lemire

Currently, Node.js can be built with...

                --shared-brotli
		--shared-cares
		--shared-libuv
		--shared-nghttp2
		--shared-zlib

The flag...

               --shared-ngtcp2

is present but unused by Gentoo.

I think it might be possible to add...

                --shared-ada
		--shared-simdutf
		--shared-simdjson

It appears that both ada and simdutf are missing in gentoo, but ngtcp2 and simdjson are present:

  • https://packages.gentoo.org/packages/net-libs/ngtcp2
  • https://packages.gentoo.org/packages/dev-libs/simdjson

I might be missing some dependencies.

lemire avatar May 09 '24 17:05 lemire

You are correct; I will fix those dependencies. Thanks for pointing that out.

williamh avatar May 09 '24 17:05 williamh