From 1e1adef9b6aeab136ba58b5e8004f04161a2b4d3 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 29 Jun 2018 13:48:56 -0700 Subject: [PATCH] build: [gn] use clang and custom stdlib when building node on linux --- build/node/BUILD.gn | 3 +++ build/node/node_override.gypi | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/build/node/BUILD.gn b/build/node/BUILD.gn index df7ac48af51a..e231e98c5f75 100644 --- a/build/node/BUILD.gn +++ b/build/node/BUILD.gn @@ -72,6 +72,9 @@ action("gyp_node") { # This has _gn suffixed otherwise it gets overridden by a shlib_suffix # that's set in node's gyp files. Don't ask me 🤷 "-D", "shlib_suffix_gn=" + shlib_suffix, + "-D", "llvm_dir=" + rebase_path("//third_party/llvm-build/Release+Asserts"), + "-D", "libcxx_dir=" + rebase_path("//buildtools/third_party/libc++"), + "-D", "libcxxabi_dir=" + rebase_path("//buildtools/third_party/libc++abi"), "-Goutput_dir=./$target_out_dir", # bizarrely, gyp generates from the build root instead of from cwd "-fninja", rebase_path("//third_party/electron_node/node.gyp", root_build_dir), diff --git a/build/node/node_override.gypi b/build/node/node_override.gypi index 25aaf2c2b179..d1e68131dee7 100644 --- a/build/node/node_override.gypi +++ b/build/node/node_override.gypi @@ -6,6 +6,34 @@ 'shlib_suffix': '<(shlib_suffix_gn)', }, + 'conditions': [ + ['OS=="linux"', { + 'make_global_settings': [ + ['CC', '<(llvm_dir)/bin/clang'], + ['CXX', '<(llvm_dir)/bin/clang++'], + ['CC.host', '$(CC)'], + ['CXX.host', '$(CXX)'], + ], + 'target_defaults': { + 'target_conditions': [ + ['_toolset=="target"', { + 'cflags_cc': [ + '-std=gnu++14', + '-nostdinc++', + '-isystem<(libcxx_dir)/trunk/include', + '-isystem<(libcxxabi_dir)/trunk/include', + ], + 'ldflags': [ + '-nostdlib++', + ], + 'libraries': [ + '../../../../../../libc++.so', + ], + }] + ] + } + }] + ], 'target_defaults': { 'target_conditions': [ ['_target_name=="node_lib"', {