|
| 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 | +} |
0 commit comments