Re: How to support C++ in a new OS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you all so much!

Our target OS will use the same hardware architecture (x86_32) and
object format.
I do not want to run gcc on the target OS.
Our OS has thread and lock support.
Currently we have outdated dietlibc in our system, and we maybe going
to port musl libc.
Are those C libraries sufficient? If not, which C library are needed?

I have some further questions.
1. What is the functionality of libstdc++ and libsupc++? What is the
relationship between them? I see libsupc++ is a sub-directory of
libstdc++, this confuses me a bit.
2. It looks like libgcc and libsupc++ are important. In order to port
them to our OS, how much and where do I have to modify? And after
porting them, can I guide gcc to link them properly just using command
line options without recompile gcc?
3. For somethings such as vectors, which library they depend on?

Sorry for the tons of questions. I indeed know very little about this area.
Thank all again!
Yuxin

On Tue, Jun 23, 2015 at 3:55 AM, Mikhail Maltsev <maltsevm@xxxxxxxxx> wrote:
> On 23.06.2015 1:07, Yuxin Ren wrote:
>> In general, what steps do I need?
>> I am very confused about the relationship among compiler (gcc),
> If you are not planning to run the compiler itself on your new OS, then
> it will not need to interact with that OS (anyway, if you are planning
> to run GCC on your OS, you'll first need to be able to cross-compile
> it). So, for now let's assume that you only want a C++ cross-compiler
> for some new target OS.
>
>> libraries (libgcc, libstdc++, libc and so on) and OS.
> You mentioned C++, so I suppose that you already have a working C
> compiler. What kind of C library does it use? newlib-based?
>
> Basically the language itself (I mean the semantics of programs which
> can be written in C++ even without using any libraries) requires some
> support from OS/libraries. In GCC the support library implementation can
> be found in libstdc++-v3/libsupc++. See
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/internals.html.
>
> For example, operators new and delete need some implementation. By
> default they rely on malloc/free provided by the C library. RTTI
> (typeid, dynamic_cast) is also implemented in libsupc++.
>
> Throwing an exception requires some mechanism which will unwind the
> stack and pass control to the handler. Different mechanisms are
> implemented in libgcc (they may require support from OS, like SEH in
> Windows, or some library, e.g. setjmp/longjmp functions).
>
> If your OS supports threads, you will probably need to provide some
> locking mechanism (mutex) to support construction of local static objects.
>
> libstdc++ uses some (well, probably quite a lot of) library functions to
> work with console, files (ifstream/ofstream), system time, locales, threads.
>
> And I almost certainly missed something important :)
>
> --
> Regards,
>     Mikhail Maltsev



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux