-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from andrey-konovalov/gyp-fix-node-build-fail…
…ure-with-long-build-directory-path-on-linux create nodejs_%.bbappend to fix build failure with long build directo…
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
...ls/nodejs/nodejs/gyp-fix-node-build-failure-with-long-build-directory-path-on-Linux.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
From 56342b1d56e4270d1587e2e92f74a88e3802e866 Mon Sep 17 00:00:00 2001 | ||
From: Matthias Schiffer <[email protected]> | ||
Date: Mon, 17 Oct 2016 23:33:02 +0200 | ||
Subject: [PATCH] gyp: fix node build failure with long build directory path on | ||
Linux | ||
|
||
Some build targets (especially the embedded OpenSSL) would use very long | ||
ar command lines (in the case of OpenSSL, containing more than 600 object | ||
files). This would often exceed the argument list limit for common stack | ||
size settings when building in directories with long paths. | ||
|
||
Fix this by writing the object list to a file first and referring to it in | ||
the ar command. | ||
|
||
Based-on-patch-by: Amy Fong <[email protected]> | ||
Fixes: https://github.com/nodejs/node/issues/9137 | ||
--- | ||
tools/gyp/pylib/gyp/generator/make.py | 64 ++++++++++++++++++++++++++++++++--- | ||
1 file changed, 60 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py | ||
index 4a6b283f152..f476a5ead64 100644 | ||
--- a/tools/gyp/pylib/gyp/generator/make.py | ||
+++ b/tools/gyp/pylib/gyp/generator/make.py | ||
@@ -146,6 +146,31 @@ def CalculateGeneratorInputInfo(params): | ||
quiet_cmd_link = LINK($(TOOLSET)) $@ | ||
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) | ||
|
||
+# Note: this does not handle spaces in paths | ||
+define xargs | ||
+ $(1) $(word 1,$(2)) | ||
+$(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2)))) | ||
+endef | ||
+ | ||
+define write-to-file | ||
+ @: >$(1) | ||
+$(call xargs,@printf "%s\\n" >>$(1),$(2)) | ||
+endef | ||
+ | ||
+OBJ_FILE_LIST := ar-file-list | ||
+ | ||
+define create_archive | ||
+ rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)` | ||
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) | ||
+ $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST) | ||
+endef | ||
+ | ||
+define create_thin_archive | ||
+ rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)` | ||
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) | ||
+ $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST) | ||
+endef | ||
+ | ||
# We support two kinds of shared objects (.so): | ||
# 1) shared_library, which is just bundling together many dependent libraries | ||
# into a link line. | ||
@@ -190,6 +215,31 @@ def CalculateGeneratorInputInfo(params): | ||
quiet_cmd_alink_thin = AR($(TOOLSET)) $@ | ||
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) | ||
|
||
+# Note: this does not handle spaces in paths | ||
+define xargs | ||
+ $(1) $(word 1,$(2)) | ||
+$(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2)))) | ||
+endef | ||
+ | ||
+define write-to-file | ||
+ @: >$(1) | ||
+$(call xargs,@printf "%s\\n" >>$(1),$(2)) | ||
+endef | ||
+ | ||
+OBJ_FILE_LIST := ar-file-list | ||
+ | ||
+define create_archive | ||
+ rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)` | ||
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) | ||
+ $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST) | ||
+endef | ||
+ | ||
+define create_thin_archive | ||
+ rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)` | ||
+ $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) | ||
+ $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST) | ||
+endef | ||
+ | ||
# Due to circular dependencies between libraries :(, we wrap the | ||
# special "figure out circular dependencies" flags around the entire | ||
# input list during linking. | ||
@@ -1583,11 +1633,17 @@ def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, | ||
"Spaces in alink input filenames not supported (%s)" % link_dep) | ||
if (self.flavor not in ('mac', 'openbsd', 'win') and not | ||
self.is_standalone_static_library): | ||
- self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin', | ||
- part_of_all, postbuilds=postbuilds) | ||
+ if self.flavor in ('linux', 'android'): | ||
+ self.WriteMakeRule([self.output_binary], link_deps, actions = ['$(call create_thin_archive,$@,$^)']) | ||
+ else: | ||
+ self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin', | ||
+ part_of_all, postbuilds=postbuilds) | ||
else: | ||
- self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, | ||
- postbuilds=postbuilds) | ||
+ if self.flavor in ('linux', 'android'): | ||
+ self.WriteMakeRule([self.output_binary], link_deps, actions = ['$(call create_archive,$@,$^)']) | ||
+ else: | ||
+ self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, | ||
+ postbuilds=postbuilds) | ||
elif self.type == 'shared_library': | ||
self.WriteLn('%s: LD_INPUTS := %s' % ( | ||
QuoteSpaces(self.output_binary), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
|
||
SRC_URI += " \ | ||
file://gyp-fix-node-build-failure-with-long-build-directory-path-on-Linux.patch \ | ||
" |