public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12)
@ 2022-09-17 17:45 Torbjorn SVENSSON
  2022-09-17 20:47 ` Christophe Lyon
  2022-09-19 15:28 ` Sebastian Huber
  0 siblings, 2 replies; 5+ messages in thread
From: Torbjorn SVENSSON @ 2022-09-17 17:45 UTC (permalink / raw)
  To: Newlib

Hello,

I've just tried to run the DejaGNU testsuite on GCC master 
(9ac9fde961f76879f0379ff3b2494a2f9ac915f7) with a rather recent commit 
of newlib (the package was patched by Arm and provided in their 
11.3.rel1 release).
Running the testsuite on arm-none-eabi produces a few hundred UNRESOLVED 
test cases, all related to the absence of an implementation of getentropy.

Looking at the current master of newlib 
(eb5c631ead537ac5640d7e4b1ea0edbef344d6d9), there is still no 
implementation, so I suspect that the same error would be visible if I 
switched to the official newlib tree.

In commit 3439657b02869299685d259c3a77aa38714565b7, the use of 
getentropy was introduced in GCC and the changeset enables the use after 
checking that the getentropy function is defined in unistd.h. In the 
case of newlib, the definition exists in unistd.h, but there is no 
common implementation for it. There are 2 specific implementations for 
RTEMS and cygwin, but nothing common.


I suppose the origin of the problem is the definition of the getentropy 
function in the newlib provided unistd.h, but what is the appropriate 
fix for it?
- Create a stub function that just returns -1 and sets errno=ENOSYS?
- Remove the getentropy definition from common unistd.h and place it in 
a fragment for cygwin and RTEMS?
- Any other solution that I've overlooked?



Here is an example of how the error looks like for the GCC testsuite:
Testing g++.robertl/eb77.C,  -std=c++20
doing compile
Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ 
  /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C  -mthumb 
-march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft 
-fdiagnostics-plain-output   -fmessage-length=0  -std=c++20 
-pedantic-errors -Wno-long-long        -Wl,--start-group -lc -lm 
-Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition 
-Wl,-u,_isatty,-u,_fstat   -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main 
-Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe    (timeout = 800)
spawn -ignore SIGHUP 
/build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ 
/build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb 
-march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft 
-fdiagnostics-plain-output -fmessage-length=0 -std=c++20 
-pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm 
-Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition 
-Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main 
-Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
pid is 28414 -28414
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): 
in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined 
reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): 
in function 
`std::random_device::_M_init(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): 
undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): 
in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
pid is -1
close result is 28414 exp6 0 1
output is 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): 
in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined 
reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): 
in function 
`std::random_device::_M_init(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): 
undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: 
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): 
in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
  status 1
compiler exited with status 1
FAIL: g++.old-deja/g++.robertl/eb77.C  -std=c++20 (test for excess errors)
Excess errors:
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined 
reference to `getentropy'
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): 
undefined reference to `getentropy'
(.text._rs_stir+0x8): undefined reference to `getentropy'
UNRESOLVED: g++.old-deja/g++.robertl/eb77.C  -std=c++20 compilation 
failed to produce executable


Kind regards,
Torbjörn

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

* Re: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12)
  2022-09-17 17:45 Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12) Torbjorn SVENSSON
@ 2022-09-17 20:47 ` Christophe Lyon
  2022-09-18  8:53   ` Torbjorn SVENSSON
  2022-09-19 15:28 ` Sebastian Huber
  1 sibling, 1 reply; 5+ messages in thread
From: Christophe Lyon @ 2022-09-17 20:47 UTC (permalink / raw)
  To: Torbjorn SVENSSON; +Cc: Newlib

[-- Attachment #1: Type: text/plain, Size: 6196 bytes --]

Hi Torbjorn,
I think there's additional context in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103166


Le sam. 17 sept. 2022, 19:45, Torbjorn SVENSSON <
torbjorn.svensson@foss.st.com> a écrit :

> Hello,
>
> I've just tried to run the DejaGNU testsuite on GCC master
> (9ac9fde961f76879f0379ff3b2494a2f9ac915f7) with a rather recent commit
> of newlib (the package was patched by Arm and provided in their
> 11.3.rel1 release).
> Running the testsuite on arm-none-eabi produces a few hundred UNRESOLVED
> test cases, all related to the absence of an implementation of getentropy.
>
> Looking at the current master of newlib
> (eb5c631ead537ac5640d7e4b1ea0edbef344d6d9), there is still no
> implementation, so I suspect that the same error would be visible if I
> switched to the official newlib tree.
>
> In commit 3439657b02869299685d259c3a77aa38714565b7, the use of
> getentropy was introduced in GCC and the changeset enables the use after
> checking that the getentropy function is defined in unistd.h. In the
> case of newlib, the definition exists in unistd.h, but there is no
> common implementation for it. There are 2 specific implementations for
> RTEMS and cygwin, but nothing common.
>
>
> I suppose the origin of the problem is the definition of the getentropy
> function in the newlib provided unistd.h, but what is the appropriate
> fix for it?
> - Create a stub function that just returns -1 and sets errno=ENOSYS?
> - Remove the getentropy definition from common unistd.h and place it in
> a fragment for cygwin and RTEMS?
> - Any other solution that I've overlooked?
>
>
>
> Here is an example of how the error looks like for the GCC testsuite:
> Testing g++.robertl/eb77.C,  -std=c++20
> doing compile
> Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++
>   /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C  -mthumb
> -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft
> -fdiagnostics-plain-output   -fmessage-length=0  -std=c++20
> -pedantic-errors -Wno-long-long        -Wl,--start-group -lc -lm
> -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition
> -Wl,-u,_isatty,-u,_fstat   -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main
> -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe    (timeout = 800)
> spawn -ignore SIGHUP
> /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++
> /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb
> -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft
> -fdiagnostics-plain-output -fmessage-length=0 -std=c++20
> -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm
> -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition
> -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main
> -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
> pid is 28414 -28414
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>
> in function `std::(anonymous namespace)::__libc_getentropy(void*)':
> (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
> reference to `getentropy'
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>
> in function
> `std::random_device::_M_init(std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)':
> (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>
> undefined reference to `getentropy'
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o):
>
> in function `_rs_stir':
> (.text._rs_stir+0x8): undefined reference to `getentropy'
> collect2: error: ld returned 1 exit status
> pid is -1
> close result is 28414 exp6 0 1
> output is
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>
> in function `std::(anonymous namespace)::__libc_getentropy(void*)':
> (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
> reference to `getentropy'
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>
> in function
> `std::random_device::_M_init(std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)':
> (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>
> undefined reference to `getentropy'
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>
> /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o):
>
> in function `_rs_stir':
> (.text._rs_stir+0x8): undefined reference to `getentropy'
> collect2: error: ld returned 1 exit status
>   status 1
> compiler exited with status 1
> FAIL: g++.old-deja/g++.robertl/eb77.C  -std=c++20 (test for excess errors)
> Excess errors:
> (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
> reference to `getentropy'
> (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>
> undefined reference to `getentropy'
> (.text._rs_stir+0x8): undefined reference to `getentropy'
> UNRESOLVED: g++.old-deja/g++.robertl/eb77.C  -std=c++20 compilation
> failed to produce executable
>
>
> Kind regards,
> Torbjörn
>

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

* Re: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12)
  2022-09-17 20:47 ` Christophe Lyon
@ 2022-09-18  8:53   ` Torbjorn SVENSSON
  0 siblings, 0 replies; 5+ messages in thread
From: Torbjorn SVENSSON @ 2022-09-18  8:53 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Newlib

Hi Christophe,

Thanks for the fast reply! :)

Looking at one of the the config.log, it appears that the 
GCC_TRY_COMPILE_OR_LINK trick does not do AC_TRY_LINK for the 
arm-none-eabi build that I'm trying, but instead just does the 
AC_TRY_COMPILE that would succeed due to that the unistd.h file contains 
the definition...

Here is a snippet from on of the config.log related to getentropy and 
arc4random:

configure:69582: checking for getentropy
configure:69601:  /build/src/build-native/gcc-final/./gcc/xgcc 
-shared-libgcc -B/build/src/build-native/gcc-final/./gcc -nostdinc++ 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/src 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/src/.libs 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/libsupc++/.libs 
-B/build/src/install-native/arm-none-eabi/bin/ 
-B/build/src/install-native/arm-none-eabi/lib/ -isystem 
/build/src/install-native/arm-none-eabi/include -isystem 
/build/src/install-native/arm-none-eabi/sys-include    -c -g -O2 
conftest.cpp >&5
configure:69601: $? = 0
configure:69633: result: yes
configure:69657: checking for arc4random
configure:69675:  /build/src/build-native/gcc-final/./gcc/xgcc 
-shared-libgcc -B/build/src/build-native/gcc-final/./gcc -nostdinc++ 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/src 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/src/.libs 
-L/build/src/build-native/gcc-final/arm-none-eabi/libstdc++-v3/libsupc++/.libs 
-B/build/src/install-native/arm-none-eabi/bin/ 
-B/build/src/install-native/arm-none-eabi/lib/ -isystem 
/build/src/install-native/arm-none-eabi/include -isystem 
/build/src/install-native/arm-none-eabi/sys-include    -c -g -O2 
conftest.cpp >&5
configure:69675: $? = 0
configure:69706: result: yes
configure:69737: checking for unistd.h
configure:69737: result: yes



Based on this snippet, I think there is not much that can be done in the 
GCC end on this issue, but rather that newlib should not provide the 
definition _or_ it should provide a basic implementation of the function.
I'm just not sure what is the prefered solution here...


Kind regards,
Torbjörn


On 2022-09-17 22:47, Christophe Lyon wrote:
> Hi Torbjorn,
> I think there's additional context in:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103166 
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103166>
> 
> 
> Le sam. 17 sept. 2022, 19:45, Torbjorn SVENSSON 
> <torbjorn.svensson@foss.st.com <mailto:torbjorn.svensson@foss.st.com>> a 
> écrit :
> 
>     Hello,
> 
>     I've just tried to run the DejaGNU testsuite on GCC master
>     (9ac9fde961f76879f0379ff3b2494a2f9ac915f7) with a rather recent commit
>     of newlib (the package was patched by Arm and provided in their
>     11.3.rel1 release).
>     Running the testsuite on arm-none-eabi produces a few hundred
>     UNRESOLVED
>     test cases, all related to the absence of an implementation of
>     getentropy.
> 
>     Looking at the current master of newlib
>     (eb5c631ead537ac5640d7e4b1ea0edbef344d6d9), there is still no
>     implementation, so I suspect that the same error would be visible if I
>     switched to the official newlib tree.
> 
>     In commit 3439657b02869299685d259c3a77aa38714565b7, the use of
>     getentropy was introduced in GCC and the changeset enables the use
>     after
>     checking that the getentropy function is defined in unistd.h. In the
>     case of newlib, the definition exists in unistd.h, but there is no
>     common implementation for it. There are 2 specific implementations for
>     RTEMS and cygwin, but nothing common.
> 
> 
>     I suppose the origin of the problem is the definition of the getentropy
>     function in the newlib provided unistd.h, but what is the appropriate
>     fix for it?
>     - Create a stub function that just returns -1 and sets errno=ENOSYS?
>     - Remove the getentropy definition from common unistd.h and place it in
>     a fragment for cygwin and RTEMS?
>     - Any other solution that I've overlooked?
> 
> 
> 
>     Here is an example of how the error looks like for the GCC testsuite:
>     Testing g++.robertl/eb77.C,  -std=c++20
>     doing compile
>     Executing on host:
>     /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++
>        /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C 
>     -mthumb
>     -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft
>     -fdiagnostics-plain-output   -fmessage-length=0  -std=c++20
>     -pedantic-errors -Wno-long-long        -Wl,--start-group -lc -lm
>     -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition
>     -Wl,-u,_isatty,-u,_fstat   -Wl,-wrap,exit -Wl,-wrap,_exit
>     -Wl,-wrap,main
>     -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe    (timeout = 800)
>     spawn -ignore SIGHUP
>     /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++
>     /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb
>     -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft
>     -fdiagnostics-plain-output -fmessage-length=0 -std=c++20
>     -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm
>     -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition
>     -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main
>     -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
>     pid is 28414 -28414
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>     in function `std::(anonymous namespace)::__libc_getentropy(void*)':
>     (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
>     reference to `getentropy'
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>     in function
>     `std::random_device::_M_init(std::__cxx11::basic_string<char,
>     std::char_traits<char>, std::allocator<char> > const&)':
>     (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>     undefined reference to `getentropy'
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o):
>     in function `_rs_stir':
>     (.text._rs_stir+0x8): undefined reference to `getentropy'
>     collect2: error: ld returned 1 exit status
>     pid is -1
>     close result is 28414 exp6 0 1
>     output is
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>     in function `std::(anonymous namespace)::__libc_getentropy(void*)':
>     (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
>     reference to `getentropy'
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o):
>     in function
>     `std::random_device::_M_init(std::__cxx11::basic_string<char,
>     std::char_traits<char>, std::allocator<char> > const&)':
>     (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>     undefined reference to `getentropy'
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld:
>     /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o):
>     in function `_rs_stir':
>     (.text._rs_stir+0x8): undefined reference to `getentropy'
>     collect2: error: ld returned 1 exit status
>        status 1
>     compiler exited with status 1
>     FAIL: g++.old-deja/g++.robertl/eb77.C  -std=c++20 (test for excess
>     errors)
>     Excess errors:
>     (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined
>     reference to `getentropy'
>     (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58):
>     undefined reference to `getentropy'
>     (.text._rs_stir+0x8): undefined reference to `getentropy'
>     UNRESOLVED: g++.old-deja/g++.robertl/eb77.C  -std=c++20 compilation
>     failed to produce executable
> 
> 
>     Kind regards,
>     Torbjörn
> 

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

* Re: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12)
  2022-09-17 17:45 Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12) Torbjorn SVENSSON
  2022-09-17 20:47 ` Christophe Lyon
@ 2022-09-19 15:28 ` Sebastian Huber
  2022-09-19 16:07   ` Torbjorn SVENSSON
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Huber @ 2022-09-19 15:28 UTC (permalink / raw)
  To: Torbjorn SVENSSON, Newlib

On 17/09/2022 19:45, Torbjorn SVENSSON wrote:
> I suppose the origin of the problem is the definition of the getentropy 
> function in the newlib provided unistd.h, but what is the appropriate 
> fix for it?
> - Create a stub function that just returns -1 and sets errno=ENOSYS?

This should be fine.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

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

* Re: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12)
  2022-09-19 15:28 ` Sebastian Huber
@ 2022-09-19 16:07   ` Torbjorn SVENSSON
  0 siblings, 0 replies; 5+ messages in thread
From: Torbjorn SVENSSON @ 2022-09-19 16:07 UTC (permalink / raw)
  To: Sebastian Huber, Newlib

On 2022-09-19 17:28, Sebastian Huber wrote:
> On 17/09/2022 19:45, Torbjorn SVENSSON wrote:
>> I suppose the origin of the problem is the definition of the 
>> getentropy function in the newlib provided unistd.h, but what is the 
>> appropriate fix for it?
>> - Create a stub function that just returns -1 and sets errno=ENOSYS?
> 
> This should be fine.
> 

What library should contain this? libnosys.a?

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

end of thread, other threads:[~2022-09-19 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-17 17:45 Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12) Torbjorn SVENSSON
2022-09-17 20:47 ` Christophe Lyon
2022-09-18  8:53   ` Torbjorn SVENSSON
2022-09-19 15:28 ` Sebastian Huber
2022-09-19 16:07   ` Torbjorn SVENSSON

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).