What's freestanding mode for libstdc++?
Asked Answered
E

2

9
--disable-hosted-libstdcxx
                          only build freestanding C++ runtime support

from the <gcc>/libstdc++-v3/configure --help .

What is this freestanding mode and what are the limits and the benefits ?

For the very little that I know about it looks like it's equivalent to some static linkage of the libstdc++ but then what is the point of this "mode" if you can just build your *.a library ? It doesn't sound like a good explanation.

Evidential answered 24/4, 2014 at 1:56 Comment(0)
A
8

"freestanding" is a minimal configuration for a c++ program, as opposed to "hosted" (full standard library support making use of advanced platform OS features). In theory, "freestanding" c++ program can be made to run on bare iron.

In "freestanding" mode only the following headers can be safely used:

  • cstdarg
  • cstddef
  • cstdlib
  • exception
  • limits
  • new
  • exception
  • typeinfo

With optional:

  • cxxabi.h.

And C++11 ones:

  • initializer_list
  • type_traits

Applications must link to "libsupc++.a" library for limited runtime features support.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html

This is supposed to conform to section 17.6.1.3 of the c++ standard (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf)

Aldercy answered 24/4, 2014 at 3:9 Comment(2)
can you elaborate a little bit more ? how the "run on bare iron" part differs from the usual dynamic or static linking ? It means "really bare iron" even without a kernel/OS ? Can you offer an example ? This is the only part that I still don't get, the practical differences.Evidential
I think its fairly straightforward. In freestanding mode, gcc would not provide you with stuff which requires non-trivial system interactions: no containers (those rely on ability to always be able to allocate more memory and depend on presence of locking primitives, even in c++03), no iostreams, no fancy stuff like smart pointers, regexes and threads. It would not emit code using built-in functions either. And yes, bare iron means no OS.Aldercy
V
1

Freestanding is used if you are making an operating system, or if you are using an operating system that may not support the standard libraries.

Venicevenin answered 9/3, 2016 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.