Skip to content

Commit 6c97736

Browse files
[Caching] Do not embed extra ClangTarget in swiftmodule
When direct cc1 mode is used, the cc1 arguments are generated from extra clang targets so there is no need to add this extra argument. Furthermore, the `--target=` is a clang driver argument and is not valid under cc1 mode. Needed for: rdar://134090397
1 parent 5490886 commit 6c97736

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
233233
} else {
234234
serializationOpts.ExtraClangOptions = getClangImporterOptions().ExtraArgs;
235235
}
236-
if (LangOpts.ClangTarget) {
236+
if (LangOpts.ClangTarget &&
237+
!getClangImporterOptions().DirectClangCC1ModuleBuild) {
237238
serializationOpts.ExtraClangOptions.push_back("--target=" +
238239
LangOpts.ClangTarget->str());
239240
}

test/CAS/embedded-Xcc.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -module-cache-path %t/clang-module-cache -O -g \
5+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
6+
// RUN: %t/main.swift -o %t/deps.json -swift-version 5 -cache-compile-job -cas-path %t/cas -Xcc -DTEST=1
7+
8+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
9+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
10+
11+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
12+
13+
// RUN: echo %t/main.swift > %t/inputs.FileList
14+
// RUN: %target-swift-frontend -emit-module -o %t/Test.swiftmodule -g -O \
15+
// RUN: -cache-compile-job -cas-path %t/cas -swift-version 5 \
16+
// RUN: -disable-implicit-swift-modules -swift-version 5 -enable-cross-import-overlays \
17+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
18+
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
19+
// RUN: -filelist %t/inputs.FileList @%t/MyApp.cmd
20+
21+
// RUN: llvm-bcanalyzer --dump %t/Test.swiftmodule | %FileCheck %s
22+
23+
// CHECK: <XCC abbrevid=6/> blob data = '-cc1'
24+
// CHECK: <XCC abbrevid=6/> blob data = '-D'
25+
// CHECK: <XCC abbrevid=6/> blob data = 'TEST=1'
26+
// CHECK-NOT: <XCC abbrevid=6/> blob data = '--target=
27+
28+
//--- main.swift
29+
public func test() {}

0 commit comments

Comments
 (0)