Skip to content

Revert "[embedded] Start building embedded support on Linux/ELF, expand archs of the embedded stdlib to cover common embedded targets" #70058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cmake/modules/SwiftSetIfArchBitness.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ function(set_if_arch_bitness var_name)
"${SIA_ARCH}" STREQUAL "x86" OR
"${SIA_ARCH}" STREQUAL "armv5" OR
"${SIA_ARCH}" STREQUAL "armv6" OR
"${SIA_ARCH}" STREQUAL "armv6m" OR
"${SIA_ARCH}" STREQUAL "armv7" OR
"${SIA_ARCH}" STREQUAL "armv7k" OR
"${SIA_ARCH}" STREQUAL "arm64_32" OR
"${SIA_ARCH}" STREQUAL "armv7m" OR
"${SIA_ARCH}" STREQUAL "armv7em" OR
"${SIA_ARCH}" STREQUAL "armv7s" OR
"${SIA_ARCH}" STREQUAL "riscv32" OR
"${SIA_ARCH}" STREQUAL "wasm32" OR
"${SIA_ARCH}" STREQUAL "powerpc")
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)
Expand Down
32 changes: 4 additions & 28 deletions stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ option(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB
"Enable build of the embedded Swift standard library and runtime"
TRUE)

if((NOT SWIFT_HOST_VARIANT STREQUAL "macosx") AND (NOT SWIFT_HOST_VARIANT STREQUAL "linux"))
if(NOT SWIFT_HOST_VARIANT STREQUAL "macosx")
set(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB FALSE)
elseif(NOT SWIFT_INCLUDE_TOOLS)
# Temporarily, only build embedded stdlib when building the compiler, to
Expand All @@ -151,36 +151,12 @@ endif()
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
set(EMBEDDED_STDLIB_TARGET_TRIPLES
# arch module_name target triple
"armv6 armv6-apple-none-macho armv6-apple-none-macho"
"armv6m armv6m-apple-none-macho armv6m-apple-none-macho"
"armv7 armv7-apple-none-macho armv7-apple-none-macho"
"armv7em armv7em-apple-none-macho armv7em-apple-none-macho"
"arm64 arm64-apple-none-macho arm64-apple-none-macho"

# the following are all ELF targets
"armv6 armv6-none-none-eabi armv6-none-none-eabi"
"armv6m armv6m-none-none-eabi armv6-none-none-eabi"
"armv7 armv7-none-none-eabi armv7-none-none-eabi"
"armv7em armv7em-none-none-eabi armv7em-none-none-eabi"
"aarch64 aarch64-none-none-elf aarch64-none-none-elf"
"riscv32 riscv32-none-none-eabi riscv32-none-none-eabi"
"riscv64 riscv64-none-none-eabi riscv64-none-none-eabi"
"x86_64 x86_64-apple-macos x86_64-apple-macos10.13"
"arm64 arm64-apple-macos arm64-apple-macos10.13"
"arm64e arm64e-apple-macos arm64e-apple-macos10.13"
)

if (SWIFT_HOST_VARIANT STREQUAL "linux")
set(EMBEDDED_STDLIB_TARGET_TRIPLES ${EMBEDDED_STDLIB_TARGET_TRIPLES}
"${SWIFT_HOST_VARIANT_ARCH} ${SWIFT_HOST_VARIANT_ARCH}-unknown-linux-gnu ${SWIFT_HOST_VARIANT_ARCH}-unknown-linux-gnu"
# In practice this expands to either:
# "x86_64 x86_64-unknown-linux-gnu x86_64-unknown-linux-gnu"
# "aarch64 aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu"
)
elseif (SWIFT_HOST_VARIANT STREQUAL "macosx")
set(EMBEDDED_STDLIB_TARGET_TRIPLES ${EMBEDDED_STDLIB_TARGET_TRIPLES}
"x86_64 x86_64-apple-macos x86_64-apple-macos10.13"
"arm64 arm64-apple-macos arm64-apple-macos10.13"
"arm64e arm64e-apple-macos arm64e-apple-macos10.13"
)
endif()
endif()

if(SWIFT_BUILD_STDLIB)
Expand Down
20 changes: 6 additions & 14 deletions stdlib/public/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,9 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
list(GET list 1 mod)
list(GET list 2 triple)

if (SWIFT_HOST_VARIANT STREQUAL "linux")
if(NOT "${mod}" MATCHES "-linux-gnu$")
continue()
endif()
set(extra_c_compile_flags)
set(extra_swift_compile_flags)
elseif (SWIFT_HOST_VARIANT STREQUAL "macosx")
if(NOT "${mod}" MATCHES "-macos$")
continue()
endif()
set(extra_c_compile_flags -D__MACH__ -D__APPLE__ -ffreestanding)
set(extra_swift_compile_flags -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding)
# TODO: Only build embedded Swift Concurrency for macOS, for now.
if(NOT "${mod}" MATCHES "-macos$")
continue()
endif()

set(SWIFT_SDK_embedded_ARCH_${mod}_MODULE "${mod}")
Expand Down Expand Up @@ -251,11 +242,12 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
TaskCancellation.swift

SWIFT_COMPILE_FLAGS
${extra_swift_compile_flags} -enable-experimental-feature Embedded
-Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -enable-experimental-feature Embedded
-parse-stdlib -DSWIFT_CONCURRENCY_EMBEDDED
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS}
C_COMPILE_FLAGS
${extra_c_compile_flags} ${SWIFT_RUNTIME_CONCURRENCY_C_FLAGS} -DSWIFT_CONCURRENCY_EMBEDDED=1
-D__MACH__ -D__APPLE__ -ffreestanding
${SWIFT_RUNTIME_CONCURRENCY_C_FLAGS} -DSWIFT_CONCURRENCY_EMBEDDED=1
MODULE_DIR "${CMAKE_BINARY_DIR}/lib/swift/embedded"
SDK "embedded"
ARCHITECTURE "${mod}"
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/array-builtins-exec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

import Builtin

Expand Down
3 changes: 2 additions & 1 deletion test/embedded/array-to-pointer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@_silgen_name("putchar")
func putchar(_: UInt8)
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/array-zero-size-struct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public struct MyStruct {
}
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/arrays.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@_silgen_name("putchar")
func putchar(_: UInt8)
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/class-func.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@main
struct Main {
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/classes-arrays.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

class MyClass {
init() { print("MyClass.init") }
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/classes-stack-promotion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public class MyClass {
public init() { print("MyClass.init") }
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

class MyClass {
init() { print("MyClass.init") }
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/closures-heap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public class MyClass {
var handler: (()->())? = nil
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@_silgen_name("putchar")
func putchar(_: UInt8)
Expand Down
1 change: 1 addition & 0 deletions test/embedded/concurrency-actors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

import _Concurrency
Expand Down
1 change: 1 addition & 0 deletions test/embedded/concurrency-async-let.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

import _Concurrency
Expand Down
1 change: 1 addition & 0 deletions test/embedded/concurrency-builtins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

import Builtin
Expand Down
1 change: 1 addition & 0 deletions test/embedded/concurrency-simple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

import _Concurrency
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/custom-print.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@_silgen_name("putchar")
func putchar(_: UInt8)
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/debuginfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public func foo<T>(_ array: inout [T]) {
array.withUnsafeMutableBytes {
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/deserialize-vtables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@main
struct Main {
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/dynamic-self.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RUN: %target-swift-emit-ir %s -enable-experimental-feature Embedded -parse-as-library -module-name main | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

class MyClass {
init() {
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/fno-builtin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public func foo() -> [Int] {
var a = [1, 2, 3]
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/generic-classes-debuginfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

struct User {
let o: BaseClass
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/generic-classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

protocol Fooable {
func foo()
Expand Down
1 change: 1 addition & 0 deletions test/embedded/lto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// For LTO, the linker dlopen()'s the libLTO library, which is a scenario that
Expand Down
3 changes: 2 additions & 1 deletion test/embedded/metatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public func sink<T>(t: T) {}

Expand Down
3 changes: 2 additions & 1 deletion test/embedded/modules-classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// BEGIN MyModule.swift

Expand Down
3 changes: 2 additions & 1 deletion test/embedded/modules-globals-exec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// BEGIN MyModule.swift

Expand Down
5 changes: 3 additions & 2 deletions test/embedded/modules-globals-many.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// RUN: %target-swift-frontend -emit-ir -I %t %t/Main.swift -enable-experimental-feature Embedded -parse-as-library | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// Dependencies look like this:
//
Expand Down Expand Up @@ -43,4 +44,4 @@ public func main() {
MyModuleC.foo()
}

// CHECK: @"$s9MyModuleA6globalSivp" = {{.*}}global %TSi zeroinitializer
// CHECK: @"$s9MyModuleA6globalSivp" = global %TSi zeroinitializer
11 changes: 6 additions & 5 deletions test/embedded/modules-globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// RUN: %target-swift-frontend -emit-ir -I %t %t/Main.swift -enable-experimental-feature Embedded -parse-as-library | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// BEGIN MyModule.swift

Expand All @@ -30,7 +31,7 @@ public func main() {
foo()
}

// CHECK: @"$s4Main022global_in_client_used_c1_D0Sivp" = {{.*}}global %TSi zeroinitializer
// CHECK: @"$s4Main024global_in_client_unused_c1_D0Sivp" = {{.*}}global %TSi zeroinitializer
// CHECK: @"$s8MyModule022global_in_module_used_d1_E0Sivp" = {{.*}}global %TSi zeroinitializer
// CHECK: @"$s8MyModule024global_in_module_unused_d1_E0Sivp" = {{.*}}global %TSi zeroinitializer
// CHECK: @"$s4Main022global_in_client_used_c1_D0Sivp" = global %TSi zeroinitializer
// CHECK: @"$s4Main024global_in_client_unused_c1_D0Sivp" = global %TSi zeroinitializer
// CHECK: @"$s8MyModule022global_in_module_used_d1_E0Sivp" = global %TSi zeroinitializer
// CHECK: @"$s8MyModule024global_in_module_unused_d1_E0Sivp" = global %TSi zeroinitializer
3 changes: 2 additions & 1 deletion test/embedded/modules-print-exec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// BEGIN MyModule.swift

Expand Down
3 changes: 2 additions & 1 deletion test/embedded/no-autolink.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

public func staticstring() -> StaticString {
return "hello"
Expand Down
Loading