Merge pull request #54 from woodruffw-forks/ww/dedupe-bitcode-paths

extractor, utils: dedupe bitcode paths before linking
This commit is contained in:
Ian A Mason 2021-07-23 09:55:42 -07:00 committed by GitHub
commit c240a4fef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -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) {

View File

@ -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]
}