-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libc] Add support for std::cout on embedded #156330
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
base: main
Are you sure you want to change the base?
Conversation
Fixes an bug with external linkage in stdout/stderr. Adds the required entrypoints for std::cout.
@llvm/pr-subscribers-libc Author: William Huynh (saturn691) ChangesFixes an bug with external linkage in stdout/stderr. Adds the required entrypoints for std::cout. Full diff: https://github.com/llvm/llvm-project/pull/156330.diff 5 Files Affected:
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 90d0a7a9adc6a..31449e0c8b831 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index d838a485b6c89..d61ca2c7faa7a 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index db65d6115cdbb..53cb61faf50d3 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/src/__support/File/baremetal/stderr.cpp b/libc/src/__support/File/baremetal/stderr.cpp
index 0a67771f034aa..bca866a73120b 100644
--- a/libc/src/__support/File/baremetal/stderr.cpp
+++ b/libc/src/__support/File/baremetal/stderr.cpp
@@ -14,10 +14,10 @@
namespace LIBC_NAMESPACE_DECL {
-cookie_io_functions_t io_func = {.read = nullptr,
- .write = __llvm_libc_stdio_write,
- .seek = nullptr,
- .close = nullptr};
+static cookie_io_functions_t io_func = {.read = nullptr,
+ .write = __llvm_libc_stdio_write,
+ .seek = nullptr,
+ .close = nullptr};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
// Buffering is implementation defined. Therefore to save RAM, we use no
diff --git a/libc/src/__support/File/baremetal/stdin.cpp b/libc/src/__support/File/baremetal/stdin.cpp
index 569d924749eec..e0bc0ec6a6378 100644
--- a/libc/src/__support/File/baremetal/stdin.cpp
+++ b/libc/src/__support/File/baremetal/stdin.cpp
@@ -14,10 +14,10 @@
namespace LIBC_NAMESPACE_DECL {
-cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
- .write = nullptr,
- .seek = nullptr,
- .close = nullptr};
+static cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
+ .write = nullptr,
+ .seek = nullptr,
+ .close = nullptr};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
// Buffering is implementation defined. Therefore to save RAM, we use no
|
@llvm/pr-subscribers-backend-risc-v Author: William Huynh (saturn691) ChangesFixes an bug with external linkage in stdout/stderr. Adds the required entrypoints for std::cout. Full diff: https://github.com/llvm/llvm-project/pull/156330.diff 5 Files Affected:
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 90d0a7a9adc6a..31449e0c8b831 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index d838a485b6c89..d61ca2c7faa7a 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index db65d6115cdbb..53cb61faf50d3 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
# stdio.h entrypoints
libc.src.stdio.asprintf
+ libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fprintf
+ libc.src.stdio.fwrite
+ libc.src.stdio.getc
libc.src.stdio.getchar
libc.src.stdio.printf
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.snprintf
libc.src.stdio.sprintf
libc.src.stdio.sscanf
+ libc.src.stdio.stderr
+ libc.src.stdio.stdin
+ libc.src.stdio.stdout
+ libc.src.stdio.ungetc
libc.src.stdio.vasprintf
+ libc.src.stdio.vfprintf
libc.src.stdio.vprintf
libc.src.stdio.vscanf
libc.src.stdio.vsnprintf
diff --git a/libc/src/__support/File/baremetal/stderr.cpp b/libc/src/__support/File/baremetal/stderr.cpp
index 0a67771f034aa..bca866a73120b 100644
--- a/libc/src/__support/File/baremetal/stderr.cpp
+++ b/libc/src/__support/File/baremetal/stderr.cpp
@@ -14,10 +14,10 @@
namespace LIBC_NAMESPACE_DECL {
-cookie_io_functions_t io_func = {.read = nullptr,
- .write = __llvm_libc_stdio_write,
- .seek = nullptr,
- .close = nullptr};
+static cookie_io_functions_t io_func = {.read = nullptr,
+ .write = __llvm_libc_stdio_write,
+ .seek = nullptr,
+ .close = nullptr};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
// Buffering is implementation defined. Therefore to save RAM, we use no
diff --git a/libc/src/__support/File/baremetal/stdin.cpp b/libc/src/__support/File/baremetal/stdin.cpp
index 569d924749eec..e0bc0ec6a6378 100644
--- a/libc/src/__support/File/baremetal/stdin.cpp
+++ b/libc/src/__support/File/baremetal/stdin.cpp
@@ -14,10 +14,10 @@
namespace LIBC_NAMESPACE_DECL {
-cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
- .write = nullptr,
- .seek = nullptr,
- .close = nullptr};
+static cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
+ .write = nullptr,
+ .seek = nullptr,
+ .close = nullptr};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
// Buffering is implementation defined. Therefore to save RAM, we use no
|
This is required for std::cout. This patch relies on the following: llvm/llvm-project#156330 llvm/llvm-project#156331
This is required for std::cout. This patch relies on the following: llvm/llvm-project#156330 llvm/llvm-project#156331
Fixes an bug with external linkage in stdout/stderr. Adds the required entrypoints for std::cout.
Full support requires #156331.