From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 704A93857C72 for ; Sat, 17 Sep 2022 20:47:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 704A93857C72 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42f.google.com with SMTP id h8so34314797wrf.3 for ; Sat, 17 Sep 2022 13:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=VMnUE8YEj8qqglXkp/V/GZHyp0Ip4y2Y4CJUHWoBYUw=; b=JKBjodm/NQsj13bVEAa4YqPojdUF0KPsM2TG6lXTJdr8IHTHOU4x/C9Epfzs+8TWc5 0PjdQySYVstTYtxRWD/FZf1qt6T3c2t83eTiK5uGSOstfibsRthf0ka6sUZId+Dcu2F4 sOtRe9YN1PIOeMMlG58vnaUoB6H/jONb94hRChlfKmHjpS4Gy+Pk16u0JKzOVaZhz4zs pcgfX5lNLwbtilAA5QKIyatJZGPBJ8nMva3pMUyLuEE8ERH/FWV5NUE3HbVU/QCJb8DE SKJWEzac7uIP2ijmLHzwUFUWTf9nFTBwMQkcN8ByRO2KrdtyxohHtC3rX2djSvqfXig0 Gk0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=VMnUE8YEj8qqglXkp/V/GZHyp0Ip4y2Y4CJUHWoBYUw=; b=Y6KptpjtXv6Hlo9pNTaLDhgrPcLhag16bErL2KVov/6h8JdQuDf5LleY1upAe3Euba XWjyjol/3BkTKiX2lQBBP88QDXVfMcpLRNbyl15aMJH9b47mHQZ17mBgR3p/u/v3ZMb2 y4Dw0xHuzeoBPV+kxPraGIvg8WMP9muqlUwDJHzbRF6LjTfJhk710hTaJ+cD8Q2AFce5 nwPABxIscmfxBErgWvvvGPf/Gvc8IEnEqicKbu/05/8ZQrZyNcOYv7oNKrp2Vovx+idr DmzdxkPtjps7Cc7/29AQCkU3e3hG0uXYzE/X7o1Y5x5iNZir/EQK/3PRKRdnzNeHiGND bD7g== X-Gm-Message-State: ACrzQf1grs/ibcCFC1Pk217NCtX6Dr01YWqLNH1cIGa5vbW2Pw80ULKh WmUL78f6gqKxptivjSUCoSqJa+sR81JgBS5/wbmQbxtP X-Google-Smtp-Source: AMsMyM5rsAasgtyx6bZ+T5xwgp+jdMdsxWGiq8MhntW/HOHWcQ76/lTbpexBmk4xFP+4zlxIkJgnlJ3P3MTR61qc//A= X-Received: by 2002:a5d:424a:0:b0:228:811f:c1a2 with SMTP id s10-20020a5d424a000000b00228811fc1a2mr6289769wrr.262.1663447641830; Sat, 17 Sep 2022 13:47:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Christophe Lyon Date: Sat, 17 Sep 2022 22:47:11 +0200 Message-ID: Subject: Re: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12) To: Torbjorn SVENSSON Cc: Newlib Content-Type: multipart/alternative; boundary="000000000000cb3bcf05e8e5951d" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,KAM_LOTSOFHASH,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000cb3bcf05e8e5951d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Torbjorn, I think there's additional context in: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103166 Le sam. 17 sept. 2022, 19:45, Torbjorn SVENSSON < torbjorn.svensson@foss.st.com> a =C3=A9crit : > 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=3DENOSYS? > - 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=3Dc++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=3Darmv6s-m -mcpu=3Dcortex-m0 -mfloat-abi=3Dsoft > -fdiagnostics-plain-output -fmessage-length=3D0 -std=3Dc++20 > -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm > -Wl,--end-group --specs=3Dnosys.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 =3D 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=3Darmv6s-m -mcpu=3Dcortex-m0 -mfloat-abi=3Dsoft > -fdiagnostics-plain-output -fmessage-length=3D0 -std=3Dc++20 > -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm > -Wl,--end-group --specs=3Dnosys.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 std::char_traits, std::allocator > 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 std::char_traits, std::allocator > 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=3Dc++20 (test for excess erro= rs) > 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=3Dc++20 compilation > failed to produce executable > > > Kind regards, > Torbj=C3=B6rn > --000000000000cb3bcf05e8e5951d--