Skip to content

Commit ad9f316

Browse files
authored
Merge pull request #68613 from kubamracek/embedded-exec-tests-on-x86
[embedded] Build the stdlib for x86_64 too, and run executable tests on x86_64
2 parents e4057a4 + b74da6b commit ad9f316

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13221322
if (Opts.hasFeature(Feature::Embedded)) {
13231323
Opts.UnavailableDeclOptimizationMode = UnavailableDeclOptimization::Complete;
13241324
Opts.DisableImplicitStringProcessingModuleImport = true;
1325+
Opts.DisableImplicitConcurrencyModuleImport = true;
1326+
Opts.EnableObjCInterop = false;
13251327

13261328
if (FrontendOpts.EnableLibraryEvolution) {
13271329
Diags.diagnose(SourceLoc(), diag::evolution_with_embedded);

stdlib/public/core/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,10 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
397397
add_custom_target(embedded-stdlib ALL)
398398
set(EMBEDDED_STDLIB_TARGET_TRIPLES
399399
# arch module_name target triple
400-
"armv7 armv7-apple-none-macho armv7-apple-none-macho"
401-
"arm64 arm64-apple-none-macho arm64-apple-none-macho"
402-
"arm64 arm64-apple-macos arm64-apple-macos11"
400+
"armv7 armv7-apple-none-macho armv7-apple-none-macho"
401+
"arm64 arm64-apple-none-macho arm64-apple-none-macho"
402+
"x86_64 x86_64-apple-macos x86_64-apple-macos10.13"
403+
"arm64 arm64-apple-macos arm64-apple-macos10.13"
403404
)
404405

405406
set(SWIFT_ENABLE_REFLECTION OFF)

test/embedded/Inputs/print.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
4+
void print_long(long n) {
5+
printf("%ld", n);
6+
}

test/embedded/collection.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ \
3-
// RUN: -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
4-
// RUN: %target-clang %t/a.o -o %t/a.out
2+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
3+
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
4+
// RUN: %target-clang %t/a.o %t/print.o -o %t/a.out
55
// RUN: %target-run %t/a.out | %FileCheck %s
66

77
// REQUIRES: executable_test
88
// REQUIRES: VENDOR=apple
9-
// REQUIRES: CPU=arm64
9+
// REQUIRES: OS=macosx
1010

1111
@_silgen_name("putchar")
1212
func putchar(_: UInt8)
@@ -24,14 +24,12 @@ public func print(_ s: StaticString, terminator: StaticString = "\n") {
2424
}
2525
}
2626

27-
@_silgen_name("vprintf")
28-
func vprintf(_: UnsafePointer<UInt8>, _: UnsafeRawPointer)
27+
@_silgen_name("print_long")
28+
func print_long(_: Int)
2929

30-
var global: Int = 0
31-
public func print(_ n: Int) {
32-
let f: StaticString = "%d\n"
33-
global = n
34-
vprintf(f.utf8Start, &global)
30+
public func print(_ n: Int, terminator: StaticString = "\n") {
31+
print_long(n)
32+
print("", terminator: terminator)
3533
}
3634

3735
@_silgen_name("malloc")

test/embedded/custom-print.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ \
3-
// RUN: -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
2+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
43
// RUN: %target-clang %t/a.o -o %t/a.out
54
// RUN: %target-run %t/a.out | %FileCheck %s
65

76
// REQUIRES: executable_test
87
// REQUIRES: VENDOR=apple
9-
// REQUIRES: CPU=arm64
8+
// REQUIRES: OS=macosx
109

1110
@_silgen_name("putchar")
1211
func putchar(_: UInt8)

test/embedded/lto.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ \
3-
// RUN: -lto=llvm-full %s -enable-experimental-feature Embedded -emit-bc -o %t/a.o
2+
// RUN: %target-swift-frontend -lto=llvm-full %s -enable-experimental-feature Embedded -emit-bc -o %t/a.o
43
// RUN: %target-clang %t/a.o -o %t/a.out
54
// RUN: %target-run %t/a.out | %FileCheck %s
65

76
// REQUIRES: executable_test
87
// REQUIRES: VENDOR=apple
9-
// REQUIRES: CPU=arm64
8+
// REQUIRES: OS=macosx
109

1110
@_silgen_name("putchar")
1211
func putchar(_: UInt8)

0 commit comments

Comments
 (0)