Skip to content

Commit 7226450

Browse files
committed
Should not be needed anymore
1 parent 1071a17 commit 7226450

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

internal/arduino/builder/libraries.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ func (b *Builder) compileLibrary(library *libraries.Library, includes []string)
234234
}
235235

236236
if len(objectFiles) > 0 {
237+
238+
// TODO: We must create an object file for each visited directory: this is required because gcc-ar checks
239+
// if an object file is already in the archive by looking ONLY at the filename WITHOUT the path, so
240+
// it may happen that a subdir/spi.o inside the archive may be overwritten by a anotherdir/spi.o
241+
// because thery are both named spi.o.
242+
// This means that we may need to make multiple .a and cache all of them.
243+
237244
archiveFile, err := b.archiveCompiledFiles(libraryBuildPath.Join("lib.a"), objectFiles)
238245
if err != nil {
239246
return nil, err

internal/arduino/builder/linker.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,6 @@ func (b *Builder) link() error {
4545
wrapWithDoubleQuotes := func(value string) string { return "\"" + value + "\"" }
4646
objectFileList := strings.Join(f.Map(objectFiles.AsStrings(), wrapWithDoubleQuotes), " ")
4747

48-
// If command line length is too big (> 30000 chars), try to collect the object files into archives
49-
// and use that archives to complete the build.
50-
if len(objectFileList) > 30000 {
51-
52-
// We must create an object file for each visited directory: this is required because gcc-ar checks
53-
// if an object file is already in the archive by looking ONLY at the filename WITHOUT the path, so
54-
// it may happen that a subdir/spi.o inside the archive may be overwritten by a anotherdir/spi.o
55-
// because thery are both named spi.o.
56-
57-
// Put all the existing archives apart from the other object files
58-
existingArchives := objectFiles.Clone()
59-
existingArchives.FilterSuffix(".a")
60-
objectFiles.FilterOutSuffix(".a")
61-
62-
// Generate an archive for each directory from the remaining object files
63-
newArchives := paths.NewPathList()
64-
for _, object := range objectFiles {
65-
archive := object.Parent().Join("objs.a")
66-
newArchives.AddIfMissing(archive)
67-
}
68-
for _, archive := range newArchives {
69-
archiveDir := archive.Parent()
70-
relatedObjectFiles := objectFiles.Clone()
71-
relatedObjectFiles.Filter(func(object *paths.Path) bool {
72-
// extract all the object files that are in the same directory of the archive
73-
return object.Parent().EquivalentTo(archiveDir)
74-
})
75-
b.archiveCompiledFiles(archive, relatedObjectFiles)
76-
}
77-
78-
// Put everything together
79-
allArchives := existingArchives.Clone()
80-
allArchives.AddAll(newArchives)
81-
objectFileList = strings.Join(f.Map(allArchives.AsStrings(), wrapWithDoubleQuotes), " ")
82-
objectFileList = "-Wl,--whole-archive " + objectFileList + " -Wl,--no-whole-archive"
83-
}
84-
8548
properties := b.buildProperties.Clone()
8649
properties.Set("compiler.c.elf.flags", properties.Get("compiler.c.elf.flags"))
8750
properties.Set("compiler.warning_flags", properties.Get("compiler.warning_flags."+b.logger.WarningsLevel()))

0 commit comments

Comments
 (0)