diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 3c84bb95180f0..939c8626f4a17 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -631,6 +631,14 @@ importer::getNormalInvocationArguments( }); } + // To support -apple-none, -apple-none-macho, -unknown-none-wasm triples. + if (triple.getVendor() == llvm::Triple::VendorType::Apple) { + invocationArgStrs.insert(invocationArgStrs.end(), {"-D__APPLE__"}); + } + if (triple.isOSBinFormatMachO()) { + invocationArgStrs.insert(invocationArgStrs.end(), {"-D__MACH__"}); + } + if (triple.isOSWindows()) { switch (triple.getArch()) { default: llvm_unreachable("unsupported Windows architecture"); diff --git a/stdlib/public/Concurrency/CMakeLists.txt b/stdlib/public/Concurrency/CMakeLists.txt index 760b54703d8f1..1442ceaee733e 100644 --- a/stdlib/public/Concurrency/CMakeLists.txt +++ b/stdlib/public/Concurrency/CMakeLists.txt @@ -218,8 +218,8 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC 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) + set(extra_c_compile_flags -ffreestanding) + set(extra_swift_compile_flags -Xcc -ffreestanding) endif() set(SWIFT_SDK_embedded_ARCH_${mod}_MODULE "${mod}") diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt index aba1e0c6745fa..5d309a03236bc 100644 --- a/stdlib/public/Platform/CMakeLists.txt +++ b/stdlib/public/Platform/CMakeLists.txt @@ -113,9 +113,9 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB) Darwin.swift.gyb SWIFT_COMPILE_FLAGS - -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -enable-experimental-feature Embedded + -Xcc -ffreestanding -enable-experimental-feature Embedded C_COMPILE_FLAGS - -D__MACH__ -D__APPLE__ -ffreestanding + -ffreestanding MODULE_DIR "${CMAKE_BINARY_DIR}/lib/swift/embedded" SDK "embedded" ARCHITECTURE "${arch}" diff --git a/stdlib/public/SwiftShims/swift/shims/Visibility.h b/stdlib/public/SwiftShims/swift/shims/Visibility.h index 5792a455ff048..1e734bf2705b6 100644 --- a/stdlib/public/SwiftShims/swift/shims/Visibility.h +++ b/stdlib/public/SwiftShims/swift/shims/Visibility.h @@ -134,7 +134,7 @@ // right for Windows, we have everything set up to get it right on // other targets as well, and doing so lets the compiler use more // efficient symbol access patterns. -#if defined(__MACH__) || defined(__wasi__) +#if defined(__MACH__) || defined(__wasm__) // On Mach-O and WebAssembly, we use non-hidden visibility. We just use // default visibility on both imports and exports, both because these diff --git a/stdlib/public/core/CMakeLists.txt b/stdlib/public/core/CMakeLists.txt index 89e2e60dc5bbf..f078006057197 100644 --- a/stdlib/public/core/CMakeLists.txt +++ b/stdlib/public/core/CMakeLists.txt @@ -422,7 +422,7 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB) ${SWIFTLIB_EMBEDDED_SOURCES} GYB_SOURCES ${SWIFTLIB_EMBEDDED_GYB_SOURCES} SWIFT_COMPILE_FLAGS - ${swift_stdlib_compile_flags} -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -enable-experimental-feature Embedded + ${swift_stdlib_compile_flags} -Xcc -ffreestanding -enable-experimental-feature Embedded -Xfrontend -enable-ossa-modules MODULE_DIR "${CMAKE_BINARY_DIR}/lib/swift/embedded" SDK "embedded" diff --git a/test/embedded/fragile-reference.swift b/test/embedded/fragile-reference.swift index 2ec55e2b3b307..dcc2304f580cd 100644 --- a/test/embedded/fragile-reference.swift +++ b/test/embedded/fragile-reference.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -module-name main -parse-as-library -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -module-name main -parse-as-library -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -module-name main -parse-as-library -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -module-name main -parse-as-library -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: OS=macosx || OS=linux-gnu // REQUIRES: CODEGENERATOR=ARM diff --git a/test/embedded/ouroboros-bug.swift b/test/embedded/ouroboros-bug.swift index f28b7954e127d..142548ae1169b 100644 --- a/test/embedded/ouroboros-bug.swift +++ b/test/embedded/ouroboros-bug.swift @@ -3,8 +3,8 @@ // code, but in the embedded Swift's runtime that's somewhat reasonable thing // to do (but is to be avoided because of this). -// RUN: %target-swift-frontend -target armv7-apple-none-macho -assert-config Debug -Osize -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -assert-config Debug -Osize -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -assert-config Debug -Osize -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -assert-config Debug -Osize -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib diff --git a/test/embedded/stdlib-array.swift b/test/embedded/stdlib-array.swift index a7612060c2176..4d2bf2133d38f 100644 --- a/test/embedded/stdlib-array.swift +++ b/test/embedded/stdlib-array.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib diff --git a/test/embedded/stdlib-basic.swift b/test/embedded/stdlib-basic.swift index d808c711e0f9f..59c21a1125f7c 100644 --- a/test/embedded/stdlib-basic.swift +++ b/test/embedded/stdlib-basic.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: CODEGENERATOR=ARM diff --git a/test/embedded/stdlib-dictionary.swift b/test/embedded/stdlib-dictionary.swift index e5c1d6b24c3a3..320741872a05b 100644 --- a/test/embedded/stdlib-dictionary.swift +++ b/test/embedded/stdlib-dictionary.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib diff --git a/test/embedded/stdlib-random.swift b/test/embedded/stdlib-random.swift index 5804101618e5a..39751d8c68548 100644 --- a/test/embedded/stdlib-random.swift +++ b/test/embedded/stdlib-random.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib diff --git a/test/embedded/stdlib-set.swift b/test/embedded/stdlib-set.swift index 02f60b29129f4..cf54217c39dd0 100644 --- a/test/embedded/stdlib-set.swift +++ b/test/embedded/stdlib-set.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib diff --git a/test/embedded/stdlib-types.swift b/test/embedded/stdlib-types.swift index 705c25e45a574..d959d3ef4e1a7 100644 --- a/test/embedded/stdlib-types.swift +++ b/test/embedded/stdlib-types.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -target armv7-apple-none-macho -Xcc -D__MACH__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s -// RUN: %target-swift-frontend -target arm64-apple-none-macho -Xcc -D__MACH__ -Xcc -D__arm64__ -Xcc -D__APPLE__ -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s +// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s // REQUIRES: swift_in_compiler // REQUIRES: optimized_stdlib