Skip to content

Commit 1c887a8

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents e85f4ca + 3a788a4 commit 1c887a8

File tree

5 files changed

+88
-9
lines changed

5 files changed

+88
-9
lines changed

lib/AST/Decl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575

7676
#include "clang/Basic/CharInfo.h"
7777
#include "clang/Basic/Module.h"
78+
#include "clang/Basic/TargetInfo.h"
7879
#include "clang/AST/Attr.h"
7980
#include "clang/AST/DeclObjC.h"
8081

@@ -1468,9 +1469,9 @@ AvailabilityRange Decl::getAvailabilityForLinkage() const {
14681469

14691470
bool Decl::isAlwaysWeakImported() const {
14701471
// For a Clang declaration, trust Clang.
1471-
if (auto clangDecl = getClangDecl()) {
1472-
return clangDecl->isWeakImported();
1473-
}
1472+
if (auto clangDecl = getClangDecl())
1473+
return clangDecl->isWeakImported(
1474+
getASTContext().LangOpts.getMinPlatformVersion());
14741475

14751476
if (getAttrs().hasAttribute<WeakLinkedAttr>())
14761477
return true;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "clang/Basic/FileEntry.h"
6767
#include "clang/Basic/IdentifierTable.h"
6868
#include "clang/Basic/LangStandard.h"
69+
#include "clang/Basic/MacroBuilder.h"
6970
#include "clang/Basic/Module.h"
7071
#include "clang/Basic/Specifiers.h"
7172
#include "clang/Basic/TargetInfo.h"
@@ -1464,8 +1465,14 @@ ClangImporter::create(ASTContext &ctx,
14641465
importer.get(), importerOpts, VFS, *swiftTargetClangArgs);
14651466
if (!swiftTargetClangInvocation)
14661467
return nullptr;
1467-
importer->Impl.setSwiftTargetInfo(clang::TargetInfo::CreateTargetInfo(
1468-
clangDiags, swiftTargetClangInvocation->TargetOpts));
1468+
auto targetInfo = clang::TargetInfo::CreateTargetInfo(
1469+
clangDiags, swiftTargetClangInvocation->TargetOpts);
1470+
// Ensure the target info has configured target-specific defines
1471+
std::string defineBuffer;
1472+
llvm::raw_string_ostream predefines(defineBuffer);
1473+
clang::MacroBuilder builder(predefines);
1474+
targetInfo->getTargetDefines(instance.getLangOpts(), builder);
1475+
importer->Impl.setSwiftTargetInfo(targetInfo);
14691476
importer->Impl.setSwiftCodeGenOptions(new clang::CodeGenOptions(
14701477
swiftTargetClangInvocation->getCodeGenOpts()));
14711478
} else {

lib/SIL/IR/SILFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ bool SILFunction::isWeakImported(ModuleDecl *module) const {
619619

620620
// For imported functions check the Clang declaration.
621621
if (ClangNodeOwner)
622-
return ClangNodeOwner->getClangDecl()->isWeakImported();
622+
return ClangNodeOwner->getClangDecl()->isWeakImported(
623+
getASTContext().LangOpts.getMinPlatformVersion());
623624

624625
// For native functions check a flag on the SILFunction
625626
// itself.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// REQUIRES: objc_interop
2+
// REQUIRES: OS=macosx
3+
// RUN: %empty-directory(%t)
4+
// RUN: %empty-directory(%t/module-cache)
5+
// RUN: %empty-directory(%t/inputs)
6+
// RUN: %empty-directory(%t/cheaders)
7+
8+
// RUN: split-file %s %t
9+
// RUN: sed -e "s|INPUTSDIR|%/t/inputs|g" %t/map.json.template > %t/map.json.template1
10+
// RUN: sed -e "s|STDLIBMOD|%/stdlib_module|g" %t/map.json.template1 > %t/map.json.template2
11+
// RUN: sed -e "s|ONONEMOD|%/ononesupport_module|g" %t/map.json.template2 > %t/map.json.template3
12+
// RUN: sed -e "s|CHEADERSDIR|%t/cheaders|g" %t/map.json.template3 > %t/map.json.template4
13+
// RUN: sed -e "s|SWIFTLIBDIR|%swift-lib-dir|g" %t/map.json.template4 > %t/map.json
14+
15+
// RUN: %target-swift-emit-pcm -module-name Bar -o %t/inputs/Bar.pcm %t/cheaders/module.modulemap -target %target-cpu-apple-macosx15.0
16+
// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm -target %target-cpu-apple-macosx15.0
17+
18+
// RUN: %target-swift-frontend -c -disable-implicit-swift-modules -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -module-cache-path %t/module-cache -explicit-swift-module-map-file %t/map.json -primary-file %t/test.swift -o %t/test.o -target %target-cpu-apple-macosx14.0 -clang-target %target-cpu-apple-macosx15.0
19+
20+
// RUN: %llvm-nm -m %t/test.o | %FileCheck %s
21+
// CHECK: (undefined) weak external _funcBar
22+
// CHECK: (undefined) external _funcBarButOlder
23+
24+
//--- map.json.template
25+
[
26+
{
27+
"moduleName": "Bar",
28+
"clangModulePath": "INPUTSDIR/Bar.pcm",
29+
"clangModuleMapPath": "CHEADERSDIR/module.modulemap"
30+
},
31+
{
32+
"moduleName": "Swift",
33+
"modulePath": "STDLIBMOD",
34+
"isFramework": false
35+
},
36+
{
37+
"moduleName": "SwiftOnoneSupport",
38+
"modulePath": "ONONEMOD",
39+
"isFramework": false
40+
},
41+
{
42+
"moduleName": "SwiftShims",
43+
"isFramework": false,
44+
"clangModuleMapPath": "SWIFTLIBDIR/swift/shims/module.modulemap",
45+
"clangModulePath": "INPUTSDIR/SwiftShims.pcm"
46+
}]
47+
48+
//--- cheaders/module.modulemap
49+
module Bar {
50+
header "Bar.h"
51+
export *
52+
}
53+
54+
//--- cheaders/Bar.h
55+
#pragma clang attribute push (__attribute__((availability(macOS, introduced=15.0))), apply_to=function)
56+
extern int funcBar(void);
57+
#pragma clang attribute pop
58+
59+
#pragma clang attribute push (__attribute__((availability(macOS, introduced=14.0))), apply_to=function)
60+
extern int funcBarButOlder(void);
61+
#pragma clang attribute pop
62+
63+
//--- test.swift
64+
import Bar
65+
public func foo() {
66+
let _ = funcBarButOlder()
67+
if #available(macOS 15.0, *), funcBar() != 0 {
68+
print("Hello, World!")
69+
}
70+
}

utils/update_checkout/update-checkout-config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
"swift-nio": "2.65.0",
173173
"swift-experimental-string-processing": "swift/main",
174174
"swift-sdk-generator": "main",
175-
"wasi-libc": "wasi-sdk-24",
175+
"wasi-libc": "wasi-sdk-25",
176176
"wasmkit": "0.1.2",
177177
"curl": "curl-8_9_1",
178178
"libxml2": "v2.11.5",
@@ -489,7 +489,7 @@
489489
"swift-nio": "2.65.0",
490490
"swift-experimental-string-processing": "swift/main",
491491
"swift-sdk-generator": "main",
492-
"wasi-libc": "wasi-sdk-24",
492+
"wasi-libc": "wasi-sdk-25",
493493
"wasmkit": "0.1.2",
494494
"curl": "curl-8_9_1",
495495
"libxml2": "v2.11.5",
@@ -539,7 +539,7 @@
539539
"swift-installer-scripts": "main",
540540
"swift-nio": "2.65.0",
541541
"swift-experimental-string-processing": "swift/main",
542-
"wasi-libc": "wasi-sdk-24",
542+
"wasi-libc": "wasi-sdk-25",
543543
"wasmkit": "0.1.2",
544544
"curl": "curl-8_9_1",
545545
"libxml2": "v2.11.5",

0 commit comments

Comments
 (0)