From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 1FA5C3858D39 for ; Mon, 23 Oct 2023 12:54:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FA5C3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sandoe.co.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1FA5C3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=85.119.248.222 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698065644; cv=none; b=uWBV169ODpHMK4g85EX7Ss/jvnNK9TetUBR1vbq9c2TSFdSAqtqTvdDod86eR23VV7lv23TVjdyDKiBOCw5x3zaT7rDnZZZjEbK9bGO2LgvC7UaiH54P86+qy+mDMOzfCscjMNhm1PZxlptUK6JtNSB/SFKPs7RrZegzAD1P8jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698065644; c=relaxed/simple; bh=bziFOcf8u8meDuW82eGrchyQDUpn6oMZsZYUP739fsI=; h=Mime-Version:Subject:From:Date:Message-Id:To; b=LY4oY7GUYMjNqKyW/4zEFNO182hH1Q5GSu64df2H5giIJ3aqsoLHqgqmclahy3pTpYeQ1f741HTY5z/CU4jf/a8+Ta0K9NIQLQ03OEspkaOp5hf2HjN5kTSMU0TJmypBB4OQiTMKIod4Xp4NGhW4AOUmtxhNbQ+gkcX9Z5Pc3vg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: (qmail 76893 invoked from network); 23 Oct 2023 12:54:01 -0000 X-APM-Out-ID: 16980656417689 X-APM-Authkey: 257869/1(257869/1) 4 Received: from unknown (HELO smtpclient.apple) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 23 Oct 2023 12:54:01 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: [PATCH] libgcc: make heap-based trampolines conditional on libc presence From: Iain Sandoe In-Reply-To: <20231023124350.432036-1-slyich@gmail.com> Date: Mon, 23 Oct 2023 13:54:01 +0100 Cc: GCC Patches , Francois-Xavier Coudert , Sergei Trofimovich Content-Transfer-Encoding: quoted-printable Message-Id: <128A8A56-A735-4A61-AEC5-BD23B5B8112E@sandoe.co.uk> References: <20231023124350.432036-1-slyich@gmail.com> To: Sergei Trofimovich X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_COUK,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,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: hi Sergei, > On 23 Oct 2023, at 13:43, Sergei Trofimovich wrote: >=20 > From: Sergei Trofimovich >=20 > To build `libc` for a target one needs to build `gcc` without `libc` > support first. Commit r14-4823-g8abddb187b3348 "libgcc: support > heap-based trampolines" added unconditional `libc` dependency and = broke > libc-less `gcc` builds. >=20 > An example failure on `x86_64-unknown-linux-gnu`: >=20 > $ mkdir -p /tmp/empty > $ ../gcc/configure \ > --disable-multilib \ > --without-headers \ > --with-newlib \ > --enable-languages=3Dc \ > --disable-bootstrap \ > --disable-gcov \ > --disable-threads \ > --disable-shared \ > --disable-libssp \ > --disable-libquadmath \ > --disable-libgomp \ > --disable-libatomic \ > --with-build-sysroot=3D/tmp/empty > $ make > ... > /tmp/gb/./gcc/xgcc -B/tmp/gb/./gcc/ = -B/usr/local/x86_64-pc-linux-gnu/bin/ = -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem = /usr/local/x86_64-pc-linux-gnu/include -isystem = /usr/local/x86_64-pc-linux-gnu/sys-include --sysroot=3D/tmp/empty -g = -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings = -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes = -Wold-style-definition -isystem ./include -fpic -mlong-double-80 = -DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 = -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -fpic = -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. = -I../.././gcc -I/home/slyfox/dev/git/gcc/libgcc = -I/home/slyfox/dev/git/gcc/libgcc/. = -I/home/slyfox/dev/git/gcc/libgcc/../gcc = -I/home/slyfox/dev/git/gcc/libgcc/../include -DHAVE_CC_TLS -DUSE_TLS = -o heap-trampoline.o -MT heap-trampoline.o -MD -MP -MF = heap-trampoline.dep -c .../gcc/libgcc/config/i386/heap-trampoline.c = -fvisibility=3Dhidden -DHIDE_EXPORTS > ../gcc/libgcc/config/i386/heap-trampoline.c:3:10: fatal error: = unistd.h: No such file or directory > 3 | #include > | ^~~~~~~~~~ > compilation terminated. > make[2]: *** [.../gcc/libgcc/static-object.mk:17: = heap-trampoline.o] Error 1 > make[2]: Leaving directory '/tmp/gb/x86_64-pc-linux-gnu/libgcc' > make[1]: *** [Makefile:13307: all-target-libgcc] Error 2 >=20 > The change inhibits any heap-based trampoline code. That looks reasonable to me (I was considering using __has_include(), = but the inhibit_libc is neater). The fact that this first compiler is buit without heap-trampoline = support, would become relevant, I guess if libc wanted to use them, it = would need another iteration. so, it looks fine, but I cannot actually approve it. Iain >=20 > libgcc/ >=20 > * libgcc/config/aarch64/heap-trampoline.c: Disable when libc is > not present. > --- > libgcc/config/aarch64/heap-trampoline.c | 5 +++++ > libgcc/config/i386/heap-trampoline.c | 5 +++++ > 2 files changed, 10 insertions(+) >=20 > diff --git a/libgcc/config/aarch64/heap-trampoline.c = b/libgcc/config/aarch64/heap-trampoline.c > index c8b83681ed7..f22233987ca 100644 > --- a/libgcc/config/aarch64/heap-trampoline.c > +++ b/libgcc/config/aarch64/heap-trampoline.c > @@ -1,5 +1,8 @@ > /* Copyright The GNU Toolchain Authors. */ >=20 > +/* libc is required to allocate trampolines. */ > +#ifndef inhibit_libc > + > #include > #include > #include > @@ -170,3 +173,5 @@ __builtin_nested_func_ptr_deleted (void) > tramp_ctrl_curr =3D prev; > } > } > + > +#endif /* !inhibit_libc */ > diff --git a/libgcc/config/i386/heap-trampoline.c = b/libgcc/config/i386/heap-trampoline.c > index 96e13bf828e..4b9f4365868 100644 > --- a/libgcc/config/i386/heap-trampoline.c > +++ b/libgcc/config/i386/heap-trampoline.c > @@ -1,5 +1,8 @@ > /* Copyright The GNU Toolchain Authors. */ >=20 > +/* libc is required to allocate trampolines. */ > +#ifndef inhibit_libc > + > #include > #include > #include > @@ -170,3 +173,5 @@ __builtin_nested_func_ptr_deleted (void) > tramp_ctrl_curr =3D prev; > } > } > + > +#endif /* !inhibit_libc */ > --=20 > 2.42.0 >=20