Skip to content

Commit abef32d

Browse files
committed
builder: use the @ syntax to reduce command line length if needed
This is required if the number of object files is too high. Fix arduino#839
1 parent 0ba0309 commit abef32d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: legacy/builder/phases/linker.go

+8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
6060
quotedObjectFiles := utils.Map(objectFiles.AsStrings(), wrapWithDoubleQuotes)
6161
objectFileList := strings.Join(quotedObjectFiles, " ")
6262

63+
// If the number of object files is too big, write it down into a file and reference
64+
// it using the @ parameter "@path/to/object_files.txt".
65+
if len(objectFileList) > 500 {
66+
objectFilesTxt := ctx.BuildPath.Join("object_files.txt")
67+
objectFilesTxt.WriteFile([]byte(strings.Join(quotedObjectFiles, "\n") + "\n"))
68+
objectFileList = "@" + objectFilesTxt.String()
69+
}
70+
6371
properties := buildProperties.Clone()
6472
properties.Set(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS))
6573
properties.Set(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+ctx.WarningsLevel))

0 commit comments

Comments
 (0)