Skip to content

Commit a5ac6aa

Browse files
Merge pull request #74755 from cachemeifyoucan/eng/PR-13054769-alternative
[ExplicitModule] Fix codegen target when using direct cc1 mode
2 parents e3a5d13 + eacb045 commit a5ac6aa

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,10 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
11501150
if (ctx.CASOpts.EnableCaching)
11511151
CI->getCASOpts() = ctx.CASOpts.CASOpts;
11521152

1153+
// If clang target is ignored, using swift target.
1154+
if (ignoreClangTarget)
1155+
CI->getTargetOpts().Triple = ctx.LangOpts.Target.str();
1156+
11531157
// Forward the index store path. That information is not passed to scanner
11541158
// and it is cached invariant so we don't want to re-scan if that changed.
11551159
CI->getFrontendOpts().IndexStorePath = ctx.ClangImporterOpts.IndexStorePath;

test/CAS/clang-target-codegen.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// REQUIRES: OS=macosx
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: split-file %s %t
5+
6+
// RUN: %target-swift-frontend -scan-dependencies -target arm64-apple-macos11 -module-name Test -module-cache-path %t/clang-module-cache -O \
7+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
8+
// RUN: %t/test.swift -o %t/deps.json -swift-version 5 -cache-compile-job -cas-path %t/cas \
9+
// RUN: -I %t/include -clang-target arm64-apple-macos13
10+
11+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/a.cmd
12+
// RUN: %swift_frontend_plain @%t/a.cmd
13+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Foo > %t/foo.cmd
14+
// RUN: %swift_frontend_plain @%t/foo.cmd
15+
16+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
17+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
18+
19+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
20+
21+
// RUN: %target-swift-frontend -c -o %t/test.o -target arm64-apple-macos11 \
22+
// RUN: -clang-target arm64-apple-macos13 -cache-compile-job -cas-path %t/cas \
23+
// RUN: -disable-implicit-swift-modules -swift-version 5 -parse-stdlib -O \
24+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
25+
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
26+
// RUN: %t/test.swift @%t/MyApp.cmd
27+
28+
// RUN: llvm-objdump --macho --all-headers %t/test.o | %FileCheck %s
29+
30+
// CHECK: cmd LC_BUILD_VERSION
31+
// CHECK-NEXT: cmdsize
32+
// CHECK-NEXT: platform macos
33+
// CHECK-NEXT: sdk
34+
// CHECK-NEXT: minos 11.0
35+
36+
//--- include/module.modulemap
37+
module A {
38+
header "a.h"
39+
export *
40+
}
41+
//--- include/a.h
42+
void a(void);
43+
44+
//--- include/Foo.swiftinterface
45+
// swift-interface-format-version: 1.0
46+
// swift-module-flags: -target arm64-apple-macos13 -enable-library-evolution -swift-version 5 -O -module-name Foo -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib
47+
import A
48+
public func foo()
49+
50+
//--- test.swift
51+
import Foo

0 commit comments

Comments
 (0)