I'm trying to port libc++ and libc++abi from LLVM to my OS. I doesn't build because many of the headers #include_next the same header. For example, stddef.h has #include_next <stddef.h>.
I've tried searching their docs, but can't find anything. I've read on mailing lists people are saying it's trying to import the compiler's headers (so it knows the definition of things such as size_t), while others say the C++ standard library depends on the C standard library.
Has anyone has success porting libc++ that may clear this up?
If all I need to do is define a few arch/OS specific constants, I'm fine with creating blank dummy headers and then implementing what's missing.
But, I will rethink my approach (such as port newlib) if the end result will be reimplementing the C standard library.
Does libc++ require a C standard library?
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Does libc++ require a C standard library?
I recently did the same thing, so hopefully I can help. LLVM's libc++ does depend on libc. I actually documented most of what I need to implement in my libc earlier this year.
As far as the arch/OS specific constants, that's more of a minefield that I'm currently navigating. You can see in an older file (Warning: read on an empty stomach) that I really had to carefully pick and choose definitions, looking through each header and determine the right combination of things to define just to get going, even masquerading as Windows for some parts like -D_LIBCPP_USING_WIN32_RANDOM. To be clear: that was *very* hacky and disgusting and I know more experienced members will rightfully call me out on it; part of the major overhaul I'm doing is to perform that correctly this time.
Basically that's what I did. There's a whole lot of things that must be defined (looking at you wchar.h), but if you just want to get up and running you can just write stubs (return 0/nullptr where appropriate). I haven't yet found a use for wcsncmp, wcsxfrm, wcscspn, wcslen, wcsspn, wcswtfhwmnylttrscniaddhr, but as long as the linker sees the definition, libc++ is happy. EDIT: Actually spoke too soon, you can even get away with omitting the definitions and just have declarations for a fair bit of that stuff.If all I need to do is define a few arch/OS specific constants, I'm fine with creating blank dummy headers and then implementing what's missing.
As far as the arch/OS specific constants, that's more of a minefield that I'm currently navigating. You can see in an older file (Warning: read on an empty stomach) that I really had to carefully pick and choose definitions, looking through each header and determine the right combination of things to define just to get going, even masquerading as Windows for some parts like -D_LIBCPP_USING_WIN32_RANDOM. To be clear: that was *very* hacky and disgusting and I know more experienced members will rightfully call me out on it; part of the major overhaul I'm doing is to perform that correctly this time.
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Does libc++ require a C standard library?
Thanks for the response. I think I might take your approach and stub out the C standard library headers and attempt to build libc++ and see what the linker complains is missing.
This will help me:
http://www.schweikhardt.net/identifiers.html
https://www-s.acm.illinois.edu/webmonke ... index.html
This will help me:
http://www.schweikhardt.net/identifiers.html
https://www-s.acm.illinois.edu/webmonke ... index.html
My OS is Perception.
Re: Does libc++ require a C standard library?
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)