Skip to content

Commit 5ea9b7d

Browse files
authored
Merge pull request #81857 from kubamracek/embedded-builtin-float
[embedded] Resolve a circular dependency problem in SwiftShims when using pico-libc
2 parents 38d89f1 + 544251b commit 5ea9b7d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ void importer::getNormalInvocationArguments(
513513
"-isystem", searchPathOpts.RuntimeResourcePath,
514514
});
515515

516+
if (LangOpts.hasFeature(Feature::Embedded)) {
517+
invocationArgStrs.insert(invocationArgStrs.end(), {"-D__swift_embedded__"});
518+
}
519+
516520
// Enable Position Independence. `-fPIC` is not supported on Windows, which
517521
// is implicitly position independent.
518522
if (!triple.isOSWindows())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
// Clang has been defining __INTxx_TYPE__ macros for a long time.
2626
// __UINTxx_TYPE__ are defined only since Clang 3.5.
27-
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__)
27+
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__) && !defined(__swift_embedded__)
2828
#include <stdint.h>
2929
typedef int64_t __swift_int64_t;
3030
typedef uint64_t __swift_uint64_t;

test/embedded/builtin-float.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/include
3+
// RUN: %{python} %utils/split_file.py -o %t %s
4+
5+
// RUN: %target-swift-frontend -target armv7em-none-none-eabi -emit-ir %t/Main.swift -enable-experimental-feature Embedded -module-cache-path %t/ModuleCache -Xcc -I%t/include
6+
7+
// REQUIRES: swift_in_compiler
8+
// REQUIRES: optimized_stdlib
9+
// REQUIRES: CODEGENERATOR=ARM
10+
// REQUIRES: embedded_stdlib_cross_compiling
11+
// REQUIRES: swift_feature_Embedded
12+
13+
// BEGIN Main.swift
14+
15+
print("hello")
16+
17+
// BEGIN include/stdint.h
18+
19+
#include <float.h>
20+
typedef __INTPTR_TYPE__ intptr_t;
21+
typedef __UINTPTR_TYPE__ uintptr_t;
22+
typedef __INT64_TYPE__ int64_t;
23+
typedef __UINT64_TYPE__ uint64_t;
24+
typedef __INT32_TYPE__ int32_t;
25+
typedef __UINT32_TYPE__ uint32_t;
26+
typedef __INT16_TYPE__ int16_t;
27+
typedef __UINT16_TYPE__ uint16_t;
28+
typedef __INT8_TYPE__ int8_t;
29+
typedef __UINT8_TYPE__ uint8_t;

0 commit comments

Comments
 (0)