-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathlto.swift
35 lines (30 loc) · 1010 Bytes
/
lto.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-experimental-feature Extern -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
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_Extern
@_extern(c, "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!