From d6c39cd360f856c5ac3baf130bce339619c269be Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Fri, 7 Nov 2025 10:57:55 -0800 Subject: [PATCH] [CAS] Don't leak `-iapinotes-modules` clang flag in caching build The search paths for apinotes are leaked when using compilation caching but they are not needed like other search path because the apinotes are found and stored inside include-tree. rdar://164205657 --- lib/ClangImporter/ClangImporter.cpp | 3 +++ test/CAS/apinotes.swift | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/CAS/apinotes.swift diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 6694955b31392..c3b747062d53e 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -4363,6 +4363,9 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args() const { FEOpts.IncludeTimestamps = false; FEOpts.ModuleMapFiles.clear(); + // APINotesOptions. + instance.getAPINotesOpts().ModuleSearchPaths.clear(); + // IndexStorePath is forwarded from swift. FEOpts.IndexStorePath.clear(); diff --git a/test/CAS/apinotes.swift b/test/CAS/apinotes.swift new file mode 100644 index 0000000000000..144ea3dbd2855 --- /dev/null +++ b/test/CAS/apinotes.swift @@ -0,0 +1,29 @@ +// REQUIRES: objc_interop + +// RUN: %empty-directory(%t) +// RUN: split-file %s %t + +// RUN: %target-swift-frontend -scan-dependencies -module-name Test -module-cache-path %t/clang-module-cache -O \ +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \ +// RUN: %t/main.swift -o %t/deps.json -swift-version 5 -cache-compile-job -cas-path %t/cas -I %t + +// RUN: %FileCheck --input-file=%t/deps.json %s + +// CHECK-NOT: -iapinotes-modules + +//--- main.swift +import A + +//--- module.modulemap +module A { header "A.h" export *} + +//--- A.h +#pragma once +void a(void); + +//--- A.apinotes +Name: A +Functions: + - Name: a + Availability: none + AvailabilityMsg: "don't use this"