Skip to content
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

Support use of libc++ with LLVM libc in embedded development #84879

Open
petrhosek opened this issue Mar 12, 2024 · 3 comments
Open

Support use of libc++ with LLVM libc in embedded development #84879

petrhosek opened this issue Mar 12, 2024 · 3 comments
Labels
embedded Support for embedded development libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc

Comments

@petrhosek
Copy link
Member

We are trying to migrate existing baremetal projects from libstdc++ and newlib to libc++ with libc and we encountered various issues. Most of them appear to be due to the fact that unlike other C library implementations, LLVM libc does not provide a complete set of headers as defined by the C standard, rather it generates headers that only contain types and functions that are supported in baremetal environments.

For example, the baremetal version of stdio.h does not include printf, fprintf, etc. because in baremetal environments, there is typically no concept of standard output or input. This can be characterized as the "don't provide what shouldn't be used" principle.

While libc++ provides options to disable unnecessary functionality to better support restricted environments, we have still encountered cases where libc++ headers transitively pull in unnecessary dependencies. This is a high-level tracking issue, I intend to file separate issues for each case.

@petrhosek petrhosek added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc embedded Support for embedded development labels Mar 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 12, 2024

@llvm/issue-subscribers-libc

Author: Petr Hosek (petrhosek)

We are trying to migrate existing baremetal projects from libstdc++ and newlib to libc++ with libc and we encountered various issues. Most of them appear to be due to the fact that unlike other C library implementations, LLVM libc does not provide a complete set of headers as defined by the C standard, rather it generates headers that only contain types and functions that are supported in baremetal environments.

For example, the baremetal version of stdio.h does not include printf, fprintf, etc. because in baremetal environments, there is typically no concept of standard output or input. This can be characterized as the "don't provide what shouldn't be used" principle.

While libc++ provides options to disable unnecessary functionality to better support restricted environments, we have still encountered cases where libc++ headers transitively pull in unnecessary dependencies. This is a high-level tracking issue, I intend to file separate issues for each case.

@philnik777
Copy link
Contributor

I think there is a lot of interest in getting things working. Would it be possible to start with a CI config that builds libc++ and LLVM's libc in a freestanding configuration plus some stuff required even though it shouldn't be? Then we could work our way from that configuration to an actual freestanding one without regressing all the time.

CC @jhuber6 in case you are interested in watching any progress

petrhosek added a commit to petrhosek/llvm-project that referenced this issue Mar 12, 2024
These are used unconditionally by libc++ math.h.

This is related to issue llvm#84879.
petrhosek added a commit that referenced this issue Mar 13, 2024
These are used unconditionally by libc++ math.h.

This is related to issue #84879.
@frederick-vs-ja
Copy link
Contributor

#78350 seems related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Support for embedded development libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc
Projects
None yet
Development

No branches or pull requests

4 participants