diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go index 441030251..9c543990f 100644 --- a/cc/library_sdk_member.go +++ b/cc/library_sdk_member.go @@ -380,7 +380,11 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte // Make sure that the include directories are unique. p.ExportedIncludeDirs = android.FirstUniquePaths(exportedIncludeDirs) p.exportedGeneratedIncludeDirs = android.FirstUniquePaths(exportedGeneratedIncludeDirs) - p.ExportedSystemIncludeDirs = android.FirstUniquePaths(ccModule.ExportedSystemIncludeDirs()) + + // Take a copy before filtering out duplicates to avoid changing the slice owned by the + // ccModule. + dirs := append(android.Paths(nil), ccModule.ExportedSystemIncludeDirs()...) + p.ExportedSystemIncludeDirs = android.FirstUniquePaths(dirs) p.ExportedFlags = ccModule.ExportedFlags() if ccModule.linker != nil {