From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 35E543832D14 for ; Sat, 17 Sep 2022 17:45:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 35E543832D14 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28H7tN8c010086 for ; Sat, 17 Sep 2022 19:45:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : from : subject : to : content-type : content-transfer-encoding; s=selector1; bh=BTGDjfa9XP6sYaVlvAzqv0+98579r4uwlgjznVp2GuM=; b=3WJx82H0nxPmE4YJ7+L+O9bYn5iA2xBF1cJuJ3yzwXypOJYbINFmCXc/hnUmTllB6Kad ldrAtu2THwF3M1xhQ9LA+ppX36SthZeGvaj8V6Bocd53e+5ppGaNy6RriirbUOs++mvx kk9k7ce61D3JyzdLWnJh+Gb8Vxli3F+nTnpbuWOKvoo0gD7kLejmVIv96etnagqSXyGO QjM15TklaHKNEoL9dhg1Tw7meuxmW6DBuPtNBT12VYSI1gucbenNEFvdrH9s5jL0VQfe Ux+pUw4xL2rS4ZA0fdGwYf8/LU+i7jG7bWEnHWLOK4tlVo9LeuziUUfICDn/xHqeoZ/v kA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3jn6g4t2db-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 17 Sep 2022 19:45:44 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4E31110002A for ; Sat, 17 Sep 2022 19:45:44 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0957723C699 for ; Sat, 17 Sep 2022 19:45:44 +0200 (CEST) Received: from [10.252.18.27] (10.75.127.121) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Sat, 17 Sep 2022 19:45:43 +0200 Message-ID: Date: Sat, 17 Sep 2022 19:45:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Content-Language: en-US From: Torbjorn SVENSSON Subject: Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12) To: Newlib Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.121] X-ClientProxiedBy: GPXDAG2NODE4.st.com (10.75.127.68) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-17_09,2022-09-16_01,2022-06-22_01 X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,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: 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, 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::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=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