mirror of
https://github.com/danog/gllvm.git
synced 2024-11-26 17:34:45 +01:00
extractor, utils: dedupe bitcode paths before linking
This commit is contained in:
parent
d01ecad84b
commit
1ac1afd3dc
@ -286,6 +286,9 @@ func handleExecutable(ea ExtractionArgs) (success bool) {
|
||||
sort.Strings(artifactPaths)
|
||||
}
|
||||
|
||||
// Deduplicate any files to link
|
||||
dedupeStrings(&filesToLink)
|
||||
|
||||
// Write manifest
|
||||
if ea.WriteManifest {
|
||||
if !writeManifest(ea, filesToLink, artifactPaths) {
|
||||
|
@ -75,3 +75,17 @@ func runCmd(cmdExecName string, args []string) (output string, err error) {
|
||||
output = outb.String()
|
||||
return
|
||||
}
|
||||
|
||||
// Deduplicate a potentially unsorted list of strings in-place without changing their order
|
||||
func dedupeStrings(strings *[]string) {
|
||||
seen := make(map[string]bool)
|
||||
count := 0
|
||||
for _, s := range *strings {
|
||||
if _, exists := seen[s]; !exists {
|
||||
seen[s] = true
|
||||
(*strings)[count] = s
|
||||
count++
|
||||
}
|
||||
}
|
||||
*strings = (*strings)[:count]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user