Skip to content

Commit d579c62

Browse files
committed
[embedded] Resolve empty -sdk path warning in embedded stdlib build, take 3
1 parent 8605da8 commit d579c62

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function(_add_target_variant_swift_compile_flags
230230
${ARGN})
231231

232232
# On Windows, we don't set SWIFT_SDK_WINDOWS_PATH_ARCH_{ARCH}_PATH, so don't include it.
233-
if (NOT "${sdk}" STREQUAL "WINDOWS")
233+
if ((NOT "${sdk}" STREQUAL "WINDOWS") AND NOT ("${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}" STREQUAL ""))
234234
list(APPEND result "-sdk" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}")
235235
endif()
236236

stdlib/public/SwiftShims/swift/shims/LibcShims.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ __swift_size_t _swift_stdlib_fwrite_stdout(const void *ptr, __swift_size_t size,
4040

4141
// General utilities <stdlib.h>
4242
// Memory management functions
43-
extern int posix_memalign(void *_Nullable *_Nonnull memptr, __swift_size_t alignment, __swift_size_t size);
4443
static inline void _swift_stdlib_free(void *_Nullable ptr) {
4544
extern void free(void *_Nullable);
4645
free(ptr);

stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,15 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
420420

421421
set(SWIFT_SDK_embedded_ARCH_${arch}_MODULE "${mod}")
422422
set(SWIFT_SDK_embedded_LIB_SUBDIR "embedded")
423+
set(SWIFT_SDK_embedded_ARCH_${arch}_TRIPLE "${triple}")
423424
add_swift_target_library_single(
424425
embedded-stdlib-${triple}
425426
swiftCore
426427
ONLY_SWIFTMODULE
427428
IS_STDLIB IS_STDLIB_CORE
428429
${SWIFTLIB_EMBEDDED_SOURCES}
429430
GYB_SOURCES ${SWIFTLIB_EMBEDDED_GYB_SOURCES}
430-
SWIFT_COMPILE_FLAGS -target "${triple}" -Xcc -D__MACH__ -enable-experimental-feature Embedded
431+
SWIFT_COMPILE_FLAGS -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -enable-experimental-feature Embedded
431432
MODULE_DIR "${CMAKE_BINARY_DIR}/lib/swift/embedded"
432433
SDK "embedded"
433434
ARCHITECTURE "${arch}"

stdlib/public/core/EmbeddedRuntime.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public struct HeapObject {
4343

4444

4545

46+
/// Forward declarations of C functions
47+
48+
@_silgen_name("posix_memalign")
49+
func posix_memalign(_: UnsafeMutablePointer<UnsafeMutableRawPointer?>, _: Int, _: Int) -> CInt
50+
51+
@_silgen_name("free")
52+
func free(_ p: UnsafeMutableRawPointer?)
53+
54+
55+
4656
/// Allocations
4757

4858
func alignedAlloc(size: Int, alignment: Int) -> UnsafeMutableRawPointer? {

0 commit comments

Comments
 (0)