Re: std::chrono: g++ 12.4 vs 13+ on bare metal

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

 



On Wed, 28 Aug 2024 at 20:22, Georg Gast <georg-gcc@xxxxxxxxxxxxxxxx> wrote:
>
> Hi gcc,
> i used until recent gcc 12.4 on a STM32F103RBT6 MCU. There i can
> include <chrono>.
>
> The follwing work here:
> #include <chrono>
>
> namespace STM32F103
> {
> struct SysTickClock
> {
>         typedef std::chrono::duration<int64_t,
> std::ratio<1,SysTickDriver::IncPerSecond>> duration;
>         typedef duration::rep rep;
>         typedef duration::period period;
>         typedef std::chrono::time_point<SysTickClock> time_point;
>
>         static const bool is_steady = true;
>
>         static time_point now() noexcept;
> };
> static_assert(std::chrono::is_clock_v<SysTickClock>);
>
> With 13+ i get this error:
> In file included from /opt/arm-none-eabi/13.3/arm-none-
> eabi/include/c++/13.3.0/chrono:35,
>                  from
> /home/georg/Dokumente/Entwicklung/01_Projects/EmbeddedCMake/src/RT/STM3
> 2F103/include/Hardware/Clock.h:3,
>                  from
> /home/georg/Dokumente/Entwicklung/01_Projects/EmbeddedCMake/src/RT/STM3
> 2F103/Clock.cpp:1:
> /opt/arm-none-eabi/13.3/arm-none-
> eabi/include/c++/13.3.0/bits/requires_hosted.h:34:4: error: #error
> "This header is not available in freestanding mode."
>    34 | #  error "This header is not available in freestanding mode."
>
> In my case i use a chrono clock to get a steady clock from the systick
> and the systick value register. I set the ratio depending on the
> frequency that triggers the systick.
>
> Is this an intended change on g++ (or better libstd++), a bug or what
> else?

It was intentional, to clean up and formalise which headers are usable
in freestanding mode.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.freestanding
for details on the support in GCC 13 and 14.

However, I think we need to revisit the decision and relax some of the
new headers so they work for freestanding again.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814 and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113398
Most of <chrono> is in the same category and would Just Work if we
removed the #error


>
> The compiler got compiled with the log in my post
> "Build Gcc 14.2 for arm-none-eabi: Gcc git or source from ARM
> developer?"
>
> Bye
>
> Georg
>
>



[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