|
| 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/deps) |
| 6 | +// RUN: %empty-directory(%t/inputs) |
| 7 | +// RUN: split-file %s %t |
| 8 | + |
| 9 | +// - Prepare the explicit input map |
| 10 | +// RUN: sed -e "s|INPUTSDIR|%/t/inputs|g" %t/map.json.template > %t/map.json.template1 |
| 11 | +// RUN: sed -e "s|STDLIBMOD|%/stdlib_module|g" %t/map.json.template1 > %t/map.json.template2 |
| 12 | +// RUN: sed -e "s|ONONEMOD|%/ononesupport_module|g" %t/map.json.template2 > %t/map.json.template3 |
| 13 | +// RUN: sed -e "s|CHEADERSDIR|%t/deps|g" %t/map.json.template3 > %t/map.json.template4 |
| 14 | +// RUN: sed -e "s|SWIFTLIBDIR|%swift-lib-dir|g" %t/map.json.template4 > %t/map.json |
| 15 | + |
| 16 | +// - Set up explicit dependencies for the client |
| 17 | +// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm -target %target-cpu-apple-macosx26.0 -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules |
| 18 | +// RUN: %target-swift-emit-pcm -module-name Foo %t/deps/module.modulemap -o %t/inputs/Foo.pcm -target %target-cpu-apple-macosx26.0 -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules |
| 19 | + |
| 20 | +// - Build the client |
| 21 | +// RUN: %target-swift-frontend -c %t/client.swift -explicit-swift-module-map-file %t/map.json -disable-implicit-swift-modules -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -o %t/client.o -target %target-cpu-apple-macosx15.5 -clang-target %target-cpu-apple-macosx26.0 -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules |
| 22 | + |
| 23 | +// - Ensure that the client's code-gen treats 'brandNewInteger' as a weak external symbol |
| 24 | +// RUN: %llvm-nm -m %t/client.o | %FileCheck %s |
| 25 | +// CHECK: (undefined) weak external _brandNewInteger |
| 26 | + |
| 27 | +//--- deps/Foo.h |
| 28 | +__attribute__((availability(macosx,introduced=26.0))) |
| 29 | +__attribute__((visibility("default"))) |
| 30 | +const extern void* __nonnull brandNewInteger; |
| 31 | + |
| 32 | +//--- deps/module.modulemap |
| 33 | +module Foo { |
| 34 | + header "Foo.h" |
| 35 | + export * |
| 36 | +} |
| 37 | + |
| 38 | +//--- map.json.template |
| 39 | +[ |
| 40 | + { |
| 41 | + "moduleName": "Foo", |
| 42 | + "clangModulePath": "INPUTSDIR/Foo.pcm", |
| 43 | + "clangModuleMapPath": "CHEADERSDIR/module.modulemap" |
| 44 | + }, |
| 45 | + { |
| 46 | + "moduleName": "Swift", |
| 47 | + "modulePath": "STDLIBMOD", |
| 48 | + "isFramework": false |
| 49 | + }, |
| 50 | + { |
| 51 | + "moduleName": "SwiftOnoneSupport", |
| 52 | + "modulePath": "ONONEMOD", |
| 53 | + "isFramework": false |
| 54 | + }, |
| 55 | + { |
| 56 | + "moduleName": "SwiftShims", |
| 57 | + "isFramework": false, |
| 58 | + "clangModuleMapPath": "SWIFTLIBDIR/swift/shims/module.modulemap", |
| 59 | + "clangModulePath": "INPUTSDIR/SwiftShims.pcm" |
| 60 | +}] |
| 61 | + |
| 62 | + |
| 63 | +//--- client.swift |
| 64 | +import Foo |
| 65 | +func f() { |
| 66 | + if #available(macOS 26.0, *) { |
| 67 | + print(brandNewInteger) |
| 68 | + } |
| 69 | +} |
0 commit comments