You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support use of libc++ with LLVM libc in embedded development #84879
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.
Details
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.
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
Activity
llvmbot commentedon Mar 12, 2024
@llvm/issue-subscribers-libc
Author: Petr Hosek (petrhosek)
Details
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.hdoes not includeprintf,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 commentedon Mar 12, 2024
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
[libc] Include FP_* macros in math.h
[libc] Include FP_* macros in math.h (#84996)
frederick-vs-ja commentedon Mar 15, 2024
#78350 seems related.
[libcxx] Support for using timespec_get (#117362)
Provide stdio EOF and remove declarations by GBL libc
[libc] Include FP_* macros in math.h (llvm#84996)
[libcxx] Support for using timespec_get (llvm#117362)