Files
swift-mirror/test/IRGen/linker_set_low_level_exec.swift
Daniel Rodríguez Troitiño ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00

58 lines
1.3 KiB
Swift

// RUN: %target-run-simple-swift(-parse-as-library -enable-experimental-feature SymbolLinkageMarkers) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_SymbolLinkageMarkers
// https://github.com/apple/swift/issues/73321
// UNSUPPORTED: OS=windows-msvc
@_used
#if canImport(Darwin)
@_section("__TEXT,__mysection")
#else
@_section("__mysection")
#endif
let my_global1: Int = 42
@_used
#if canImport(Darwin)
@_section("__TEXT,__mysection")
#else
@_section("__mysection")
#endif
let my_global2: Int = 46
#if canImport(Darwin)
@_silgen_name(raw: "section$start$__TEXT$__mysection")
#else
@_silgen_name(raw: "__start___mysection")
#endif
var mysection_start: Int
#if canImport(Darwin)
@_silgen_name(raw: "section$end$__TEXT$__mysection")
#else
@_silgen_name(raw: "__stop___mysection")
#endif
var mysection_end: Int
@main
struct Main {
static func main() {
let start = UnsafeRawPointer(&mysection_start)
let end = UnsafeRawPointer(&mysection_end)
let size = end - start
let count = size / (Int.bitWidth / 8)
print("count: \(count)")
let linker_set = UnsafeBufferPointer(start: start.bindMemory(to: Int.self, capacity: count), count: count)
for i in 0 ..< linker_set.count {
print("mysection[\(i)]: \(linker_set[i])")
}
}
}
// CHECK: count: 2
// CHECK: mysection[0]: 42
// CHECK: mysection[1]: 46