mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
34 lines
906 B
Swift
34 lines
906 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -lto=llvm-full %s -enable-experimental-feature Embedded -emit-bc -o %t/a.o
|
|
// RUN: %target-clang %t/a.o -o %t/a.out
|
|
// RUN: %target-run %t/a.out | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: OS=macosx
|
|
|
|
// For LTO, the linker dlopen()'s the libLTO library, which is a scenario that
|
|
// ASan cannot work in ("Interceptors are not working, AddressSanitizer is
|
|
// loaded too late").
|
|
// REQUIRES: no_asan
|
|
|
|
@_silgen_name("putchar")
|
|
@discardableResult
|
|
func putchar(_: CInt) -> CInt
|
|
|
|
public func print(_ s: StaticString, terminator: StaticString = "\n") {
|
|
var p = s.utf8Start
|
|
while p.pointee != 0 {
|
|
putchar(CInt(p.pointee))
|
|
p += 1
|
|
}
|
|
p = terminator.utf8Start
|
|
while p.pointee != 0 {
|
|
putchar(CInt(p.pointee))
|
|
p += 1
|
|
}
|
|
}
|
|
|
|
print("Hello, Embedded Swift!")
|
|
// CHECK: Hello, Embedded Swift!
|