Skip to content

Commit

Permalink
builder: use the @ syntax to reduce command line length if needed
Browse files Browse the repository at this point in the history
This is required if the number of object files is too high.

Fix arduino#839
  • Loading branch information
cmaglie committed Sep 21, 2020
1 parent 0ba0309 commit abef32d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions legacy/builder/phases/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
quotedObjectFiles := utils.Map(objectFiles.AsStrings(), wrapWithDoubleQuotes)
objectFileList := strings.Join(quotedObjectFiles, " ")

// If the number of object files is too big, write it down into a file and reference
// it using the @ parameter "@path/to/object_files.txt".
if len(objectFileList) > 500 {

This comment has been minimized.

Copy link
@aureleq

aureleq Sep 28, 2020

This should probably be a lower value. I had roughly 64k characters with ~500 files. To get less than 32k characters something around 200 files should be better (also depends on the filenames)

This comment has been minimized.

Copy link
@cmaglie

cmaglie Oct 5, 2020

Author Owner

This is actually the number of chars and not the number of files, so the @filename trick is enabled when the concatenated list of files is more than >500 chars.

This comment has been minimized.

Copy link
@aureleq

aureleq Oct 5, 2020

Sounds good, I read the code too fast :) Thanks @cmaglie

objectFilesTxt := ctx.BuildPath.Join("object_files.txt")
objectFilesTxt.WriteFile([]byte(strings.Join(quotedObjectFiles, "\n") + "\n"))
objectFileList = "@" + objectFilesTxt.String()
}

properties := buildProperties.Clone()
properties.Set(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_C_ELF_FLAGS))
properties.Set(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS, properties.Get(constants.BUILD_PROPERTIES_COMPILER_WARNING_FLAGS+"."+ctx.WarningsLevel))
Expand Down

0 comments on commit abef32d

Please sign in to comment.