Skip to content

build: allow unbundling of Node.js dependencies #55903

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions node.gni
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ declare_args() {

# Build with Amaro (TypeScript utils).
node_use_amaro = true

# Allows downstream packagers (eg. Linux distributions) to build against system shared libraries.
use_system_cares = false
Copy link
Member

Choose a reason for hiding this comment

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

What about Ada?

Choose a reason for hiding this comment

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

I'd say it's a small user group because Ada uses C++ types that are not ABI-compatible between LLVM libc++ (linked statically by Chromium as default) and libstdc++ (used as the system one by most distros). use_custom_libcxx=false is very broken, and pretty much the only distros I know of using it currently are Chimera Linux (which uses libc++ as system, and patches libc++ to keep Chromium working), Debian, and openSUSE

Copy link
Member

Choose a reason for hiding this comment

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

That's educational. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify: openSUSE uses use_custom_libcxx=false for Electron (which i maintain), but not for Chromium (which i don't, and don't have resources to).

It's much more important that it stays usable for Electron, since requiring a custom C++ implementation would also require changes in packaging every Electron application we ship that has native modules.

use_system_nghttp2 = false
use_system_llhttp = false
use_system_histogram = false
}

assert(!node_enable_inspector || node_use_openssl,
Expand Down
29 changes: 24 additions & 5 deletions unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ template("node_gn_build") {
]
deps = [
":run_node_js2c",
"deps/brotli",
"deps/cares",
"deps/histogram",
"deps/llhttp",
"deps/nbytes",
"deps/nghttp2",
"deps/ngtcp2",
Expand All @@ -179,7 +175,17 @@ template("node_gn_build") {
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [ "//build/config/gcc:symbol_visibility_default" ]
}

if (use_system_llhttp) {
libs += [ "llhttp" ]

Choose a reason for hiding this comment

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

This passes -lllhttp to the linker, but does not add its header location to include_dirs - pkg-config can resolve it under the name libllhttp

Copy link
Member Author

Choose a reason for hiding this comment

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

selfisekai - to clarify, should this instead be:

if (use_system_llhttp) {
   if (is_linux) {
      pkg_config("llhttp") {
        packages = [ "libllhttp" ]
      }
   }
   libs += [ "llhttp" ]
}

Choose a reason for hiding this comment

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

libs += [ ":llhttp" ], LGTM otherwise

Copy link
Contributor

Choose a reason for hiding this comment

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

should be pkg_config on libllhttp

} else {
deps += [ "deps/llhttp" ]
}
if (use_system_histogram) {
libs += [ "hdr_histogram" ]
include_dirs += [ "/usr/include/hdr" ]
Comment on lines +184 to +185

Choose a reason for hiding this comment

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

This also should be pkg_config on hdr_histogram

} else {
deps += [ "deps/histogram" ]
}
if (v8_enable_i18n_support) {
deps += [ "//third_party/icu" ]
}
Expand All @@ -206,6 +212,19 @@ template("node_gn_build") {
sources += node_inspector.node_inspector_sources +
node_inspector.node_inspector_generated_sources
}
if (is_linux) {
import("//build/config/linux/pkg_config.gni")
if (use_system_cares) {
pkg_config("cares") {
packages = [ "libcares" ]
}
}
if (use_system_nghttp2) {
pkg_config("nghttp2") {
packages = [ "libnghttp2" ]
}
}
}
}

executable(target_name) {
Expand Down
Loading