public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore
@ 2023-05-11 15:27 lestofante88 at gmail dot com
  2023-05-11 15:38 ` [Bug libstdc++/109814] " xry111 at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: lestofante88 at gmail dot com @ 2023-05-11 15:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

            Bug ID: 109814
           Summary: freestanding using cmath does not compile anymore
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lestofante88 at gmail dot com
  Target Milestone: ---

My code stop compiling after updating from
arm-none-eabi-gcc (Arch Repository) 12.2.0
to
arm-none-eabi-gcc (Arch Repository) 13.1.0
(cant easily test any version in-between)

My understanding is that I am incorrectly using non-freestand library in
freestand mode (cmath in this case).
The problem with this is i am quite sure in embedded a lot of project does. 
This breakage, even if technically correct, may create a lot of issue in
embedded projects and may deserve a special handling, would that be good
communication of the breaking changes, or revert.

REPRODUCE:
- create a file test.cpp containing

#include <cmath>

- compile with 
arm-none-eabi-g++ --freestanding -c test.cpp

RESULT
On gcc 12.2.0: compilation successful
On gcc 13.1.0:

In file included from /usr/arm-none-eabi/include/c++/13.1.0/cmath:41,
                 from test.cpp:1:
/usr/arm-none-eabi/include/c++/13.1.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 file included from /usr/arm-none-eabi/include/c++/13.1.0/bits/specfun.h:47,
                 from /usr/arm-none-eabi/include/c++/13.1.0/cmath:3716:
/usr/arm-none-eabi/include/c++/13.1.0/tr1/gamma.tcc: In function '_Tp
std::__detail::__log_gamma(_Tp)':
/usr/arm-none-eabi/include/c++/13.1.0/tr1/gamma.tcc:236:18: error:
'__throw_domain_error' is not a member of 'std'; did you mean
'__throw_runtime_error'?
  236 |             std::__throw_domain_error(__N("Argument is nonpositive
integer "
      |                  ^~~~~~~~~~~~~~~~~~~~
      |                  __throw_runtime_error

[...] the error repeat for multiple functions.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
@ 2023-05-11 15:38 ` xry111 at gcc dot gnu.org
  2023-05-11 15:52 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-05-11 15:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
It seems a deliberate change.  See PR103626.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
  2023-05-11 15:38 ` [Bug libstdc++/109814] " xry111 at gcc dot gnu.org
@ 2023-05-11 15:52 ` redi at gcc dot gnu.org
  2023-05-11 15:58 ` [Bug libstdc++/109814] [13/14 Regression] " redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-11 15:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It is a deliberate change, what we didn't consider is that people are using
hosted libstdc++ with -ffreestanding this way (because ... well, it doesn't
really make sense, but apparently it does).

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
  2023-05-11 15:38 ` [Bug libstdc++/109814] " xry111 at gcc dot gnu.org
  2023-05-11 15:52 ` redi at gcc dot gnu.org
@ 2023-05-11 15:58 ` redi at gcc dot gnu.org
  2023-05-11 16:00 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-11 15:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-05-11
      Known to work|                            |12.3.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
            Summary|freestanding using cmath    |[13/14 Regression]
                   |does not compile anymore    |freestanding using cmath
                   |                            |does not compile anymore
      Known to fail|                            |13.1.0, 14.0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The new behaviour is documented at
https://gcc.gnu.org/onlinedocs/gcc-13.1.0/libstdc++/manual/manual/using.html
and
https://gcc.gnu.org/onlinedocs/gcc-13.1.0/libstdc++/manual/manual/using_dynamic_or_shared.html
and I've just added something to the release notes about it:
https://gcc.gnu.org/gcc-13/changes.html#libstdcxx

But that doesn't help anybody affected by this.

Is it just <cmath> that you're using? We could pretty easily remove the
<bits/requires_hosted.h> include from that file, and then you could include
<cmath> with -ffreestanding. But if you have a truly freestanding environment
(i.e. no libm present) then nothing in <cmath> is actually going to work.

If people are using more than just <cmath> with -ffreestanding then things get
harder. Where do we draw the line of what is part of the freestanding subset of
libstdc++? Do we just let people include everything, and it's their fault if
they create dependencies on malloc, __cxa_throw, RTTI etc.? That doesn't seem
nice.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (2 preceding siblings ...)
  2023-05-11 15:58 ` [Bug libstdc++/109814] [13/14 Regression] " redi at gcc dot gnu.org
@ 2023-05-11 16:00 ` redi at gcc dot gnu.org
  2023-05-11 16:48 ` lestofante88 at gmail dot com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-11 16:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to lesto fante from comment #0)
> My code stop compiling after updating from
> arm-none-eabi-gcc (Arch Repository) 12.2.0
> to
> arm-none-eabi-gcc (Arch Repository) 13.1.0
> (cant easily test any version in-between)

Please add the output of 'gcc -v' (as requested by the bug reporting docs), the
info above doesn't tell us much.

Presumably you're using newlib to provide the libm functions that <cmath>
declares?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (3 preceding siblings ...)
  2023-05-11 16:00 ` redi at gcc dot gnu.org
@ 2023-05-11 16:48 ` lestofante88 at gmail dot com
  2023-05-11 17:43 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: lestofante88 at gmail dot com @ 2023-05-11 16:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #5 from lesto fante <lestofante88 at gmail dot com> ---
> Presumably you're using newlib to provide the libm functions that <cmath> declares?

newlib-nano, trough the "-specs=nano.specs". 
Removing -ffreestanding in my project caused a decrease(!) in code size (42008
vs 41328), but an increase of max function stack usage (better inlining?)


> If people are using more than just <cmath> with -ffreestanding then things get harder

I personally like this breakage, i would have never known this build script had
this error if i would have never used with this compiler version, so big plus
for me.
Maybe a warning instead of an error?

I looked a bit online and it seems to be relatively common, considering how
hard can be finding stuff about linking in embedded.
Even ST's IDE * seems to be doing it, and if this is default, that means a lot
of people like me are just using forbitten lib in freestanding without
realizing :(

(*
https://community.st.com/s/question/0D50X0000AkShGlSQK/cannot-compile-release-configuration-no-rule-to-make-syscallso)

----

arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/13.1.0/lto-wrapper
Target: arm-none-eabi
Configured with: /build/arm-none-eabi-gcc/src/gcc-13.1.0/configure
--target=arm-none-eabi --prefix=/usr --with-sysroot=/usr/arm-none-eabi
--with-native-system-header-dir=/include --libexecdir=/usr/lib
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-system-zlib
--with-newlib --with-headers=/usr/arm-none-eabi/include
--with-python-dir=share/gcc-arm-none-eabi --with-gmp --with-mpfr --with-mpc
--with-isl --with-libelf --enable-gnu-indirect-function
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='Arch Repository' --with-bugurl=https://bugs.archlinux.org/
--with-multilib-list=rmprofile
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.0 (Arch Repository)

----

arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/12.2.0/lto-wrapper
Target: arm-none-eabi
Configured with: /build/arm-none-eabi-gcc/src/gcc-12.2.0/configure
--target=arm-none-eabi --prefix=/usr --with-sysroot=/usr/arm-none-eabi
--with-native-system-header-dir=/include --libexecdir=/usr/lib
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-system-zlib
--with-newlib --with-headers=/usr/arm-none-eabi/include
--with-python-dir=share/gcc-arm-none-eabi --with-gmp --with-mpfr --with-mpc
--with-isl --with-libelf --enable-gnu-indirect-function
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='Arch Repository' --with-bugurl=https://bugs.archlinux.org/
--with-multilib-list=rmprofile
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Arch Repository)

----

arm-none-eabi-g++ -v                    
Using built-in specs.
COLLECT_GCC=/home/mauro/compilers/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/home/mauro/compilers/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/lto-wrapper
Target: arm-none-eabi
Configured with:
/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/src/gcc/configure
--target=arm-none-eabi
--prefix=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native
--libexecdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/lib
--infodir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/share/doc/gcc-arm-none-eabi/info
--mandir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/share/doc/gcc-arm-none-eabi/man
--htmldir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/share/doc/gcc-arm-none-eabi/html
--pdfdir=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/share/doc/gcc-arm-none-eabi/pdf
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib
--with-headers=yes --with-python-dir=share/gcc-arm-none-eabi
--with-sysroot=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/install-native/arm-none-eabi
--build=x86_64-linux-gnu --host=x86_64-linux-gnu
--with-gmp=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/build-native/host-libs/usr
--with-mpfr=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/build-native/host-libs/usr
--with-mpc=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/build-native/host-libs/usr
--with-isl=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/build-native/host-libs/usr
--with-libelf=/tmp/jenkins/jenkins-GCC-8-build_toolchain_docker-519_20181216_1544945247/build-native/host-libs/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='GNU Tools for Arm Embedded Processors 8-2018-q4-major'
--with-multilib-list=rmprofile
Thread model: single
gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074] (GNU Tools
for Arm Embedded Processors 8-2018-q4-major)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (4 preceding siblings ...)
  2023-05-11 16:48 ` lestofante88 at gmail dot com
@ 2023-05-11 17:43 ` redi at gcc dot gnu.org
  2023-05-11 19:22 ` arsen at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-11 17:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks for the extra info.

I don't think it's really _forbidden_, but not a use case I was really aware
of, and didn't realise it's something we might need to support.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (5 preceding siblings ...)
  2023-05-11 17:43 ` redi at gcc dot gnu.org
@ 2023-05-11 19:22 ` arsen at gcc dot gnu.org
  2023-05-11 19:29 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: arsen at gcc dot gnu.org @ 2023-05-11 19:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arsen at gcc dot gnu.org

--- Comment #7 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
the thing with newlib in particular is that it's not really freestanding..  it
lives in an odd limbo between a full hosted OS and 'real' freestanding with
absolutely no (or minimal, e.g. libgcc and crti/n) runtime.

luckily, -ffreestanding doesn't do much, so it might be the case that you can
just drop it.

I'm currently in the process of getting together a toolchain I can test this
on.

I'm of the opinion it makes sense to treat newlib targets as hosted, even if it
isn't the fully featured OS library; what do you think?  and what kind of
usecase are you working with?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (6 preceding siblings ...)
  2023-05-11 19:22 ` arsen at gcc dot gnu.org
@ 2023-05-11 19:29 ` pinskia at gcc dot gnu.org
  2023-05-12 20:04 ` lestofante88 at gmail dot com
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-11 19:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Arsen Arsenović from comment #7)
> the thing with newlib in particular is that it's not really freestanding.. 
> it lives in an odd limbo between a full hosted OS and 'real' freestanding
> with absolutely no (or minimal, e.g. libgcc and crti/n) runtime.
> 

Right and a lot of people call newlib as being semi-hosted env.

> I'm of the opinion it makes sense to treat newlib targets as hosted, even if
> it isn't the fully featured OS library; what do you think?  and what kind of
> usecase are you working with?

I am in the same opinion.
I wonder how things like zephyr rtos are considered by themselves. They have
their own libc which makes using libstdc++ a bit complex as almost always the
libstdc++ is compiled for being with newlib ...

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (7 preceding siblings ...)
  2023-05-11 19:29 ` pinskia at gcc dot gnu.org
@ 2023-05-12 20:04 ` lestofante88 at gmail dot com
  2023-05-12 22:34 ` arsen at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: lestofante88 at gmail dot com @ 2023-05-12 20:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #9 from lesto fante <lestofante88 at gmail dot com> ---
To be fair I have no idea what would be the impact of removing freestanding,
from a quick test does not seems to have a realistic impact.

I guess what happen here is that the freestanding option should remove as much
as possible, and the -specs=nano.specs should re-enable only the minimum
necessary.

Seems like the proper way to do so is to just specify -specs=nano.specs, or go
full freestanding?

My user case is industrial robot that have to be as reliable as possible.

Being able to write embedded code using C++ give me RAII, constexpr,
templating, function overload, runtime and compile time polymorphism. 

Generally the manufacturer IDE disable allocation and exception, so I pretty
much avoid STL as it is a mine field.

In pure freestanding, I would expect smart pointer and at least parts cmath to
work; the compiler offer me only the FPU accelerated functionality, and is up
to me to implement the remaining.

Unofficial AVR-gcc used the trick of making double into float, i would prefer
compilation error than those switcheroo under the hoods.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (8 preceding siblings ...)
  2023-05-12 20:04 ` lestofante88 at gmail dot com
@ 2023-05-12 22:34 ` arsen at gcc dot gnu.org
  2023-05-16 20:44 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: arsen at gcc dot gnu.org @ 2023-05-12 22:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #10 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
(In reply to lesto fante from comment #9)
> To be fair I have no idea what would be the impact of removing freestanding,
> from a quick test does not seems to have a realistic impact.
> 
> I guess what happen here is that the freestanding option should remove as
> much as possible, and the -specs=nano.specs should re-enable only the
> minimum necessary.
> 
> Seems like the proper way to do so is to just specify -specs=nano.specs, or
> go full freestanding?

I was hinting at the former.  -ffreestanding doesn't do much (grep for
flag_hosted in gcc/), so it *should* be safe to drop.

(it changes __STDC_HOSTED__, and hence _GLIBCXX_HOSTED, and silences some
main-related warnings)

-specs=nano.specs is a newlib thing - I'm not sure how it's meant to be used
(but it seems fine to keep it from a quick read)

> My user case is industrial robot that have to be as reliable as possible.
> 
> Being able to write embedded code using C++ give me RAII, constexpr,
> templating, function overload, runtime and compile time polymorphism. 
> 
> Generally the manufacturer IDE disable allocation and exception, so I pretty
> much avoid STL as it is a mine field.

libstdc++ ought to work without those.  std::allocator isn't part of the
freestanding subset, but many bits of the STL work regardless of that.

> In pure freestanding, I would expect smart pointer and at least parts cmath
> to work; the compiler offer me only the FPU accelerated functionality, and
> is up to me to implement the remaining.

a good bit is, but not cmath, as a large part of it required a runtime.  you
should be able to use it in your configuration without -ffreestanding, probably

> Unofficial AVR-gcc used the trick of making double into float, i would
> prefer compilation error than those switcheroo under the hoods.

arm-none-eabi-gcc seems to be built with a hosted libstdc++ configuration, so
my guess is (without trying) that removing -ffreestanding should recover
<cmath>

I want to add more code to the freestanding subset to GCC 14, but have not had
time for such experimentation yet.  cmath is on that list.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (9 preceding siblings ...)
  2023-05-12 22:34 ` arsen at gcc dot gnu.org
@ 2023-05-16 20:44 ` pinskia at gcc dot gnu.org
  2023-07-27  9:26 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-16 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.2

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (10 preceding siblings ...)
  2023-05-16 20:44 ` pinskia at gcc dot gnu.org
@ 2023-07-27  9:26 ` rguenth at gcc dot gnu.org
  2023-07-27 10:54 ` redi at gcc dot gnu.org
  2023-07-28 10:54 ` arsen at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27  9:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.2                        |13.3

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (11 preceding siblings ...)
  2023-07-27  9:26 ` rguenth at gcc dot gnu.org
@ 2023-07-27 10:54 ` redi at gcc dot gnu.org
  2023-07-28 10:54 ` arsen at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-27 10:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Arsen Arsenović from comment #10)
> (In reply to lesto fante from comment #9)
> > In pure freestanding, I would expect smart pointer and at least parts cmath
> > to work; the compiler offer me only the FPU accelerated functionality, and
> > is up to me to implement the remaining.
> 
> a good bit is, but not cmath, as a large part of it required a runtime.  you
> should be able to use it in your configuration without -ffreestanding,
> probably

I suppose we could enable <cmath> if hosted || newlib, but that wouldn't always
be right because (IIUC) you can configure newlib without any of the libm
functions. I suppose if you use such a newlib and then include <cmath> that's
your own fault and you get to keep both pieces.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug libstdc++/109814] [13/14 Regression] freestanding using cmath does not compile anymore
  2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
                   ` (12 preceding siblings ...)
  2023-07-27 10:54 ` redi at gcc dot gnu.org
@ 2023-07-28 10:54 ` arsen at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: arsen at gcc dot gnu.org @ 2023-07-28 10:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109814

--- Comment #13 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #12)

> I suppose we could enable <cmath> if hosted || newlib, but that wouldn't
> always be right because (IIUC) you can configure newlib without any of the
> libm functions. I suppose if you use such a newlib and then include <cmath>
> that's your own fault and you get to keep both pieces.

that seems reasonable, though my thinking is that maybe we can bring newlib
closer to hosted in general.  it even features C buffered IO (AFAIU) and
malloc, so it could provide the stuff that 'blocks' other features from working
on freestanding (besides threading, presumably?  I'd need to check what exactly
newlib provides)

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-07-28 10:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 15:27 [Bug libstdc++/109814] New: freestanding using cmath does not compile anymore lestofante88 at gmail dot com
2023-05-11 15:38 ` [Bug libstdc++/109814] " xry111 at gcc dot gnu.org
2023-05-11 15:52 ` redi at gcc dot gnu.org
2023-05-11 15:58 ` [Bug libstdc++/109814] [13/14 Regression] " redi at gcc dot gnu.org
2023-05-11 16:00 ` redi at gcc dot gnu.org
2023-05-11 16:48 ` lestofante88 at gmail dot com
2023-05-11 17:43 ` redi at gcc dot gnu.org
2023-05-11 19:22 ` arsen at gcc dot gnu.org
2023-05-11 19:29 ` pinskia at gcc dot gnu.org
2023-05-12 20:04 ` lestofante88 at gmail dot com
2023-05-12 22:34 ` arsen at gcc dot gnu.org
2023-05-16 20:44 ` pinskia at gcc dot gnu.org
2023-07-27  9:26 ` rguenth at gcc dot gnu.org
2023-07-27 10:54 ` redi at gcc dot gnu.org
2023-07-28 10:54 ` arsen at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).