From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7819) id CC25C3858C66; Tue, 24 Oct 2023 07:36:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC25C3858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698132964; bh=oRTZBg2yrjM6/KHMo1uqwIau+DOWF27VSxHidFTHt6I=; h=From:To:Subject:Date:From; b=EB+ST9ongWaK+vD6rOOyZnbiHSz5ft7BM94gy2kIq3Wi8U07trwqQhu1SFiz3pSYO RdLgQOpvVLJNwynf8OCdaM8lD77QHdPbzWNcBtCPAlQ1asaApv+4WJVTn3SSCm8wZx 26bkbJmsaOZopaVC6ynGmmMjODyyCWaD6hZH9Ugg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Sergei Trofimovich To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4878] libgcc: make heap-based trampolines conditional on libc presence X-Act-Checkin: gcc X-Git-Author: Sergei Trofimovich X-Git-Refname: refs/heads/master X-Git-Oldrev: 724badcadf889b5798321620aeed16b61e91fe72 X-Git-Newrev: eaf75155f38a51b2d9d49c6c1b1e1639e3d0591a Message-Id: <20231024073604.CC25C3858C66@sourceware.org> Date: Tue, 24 Oct 2023 07:36:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:eaf75155f38a51b2d9d49c6c1b1e1639e3d0591a commit r14-4878-geaf75155f38a51b2d9d49c6c1b1e1639e3d0591a Author: Sergei Trofimovich Date: Mon Oct 23 13:32:55 2023 +0100 libgcc: make heap-based trampolines conditional on libc presence 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. An example failure on `x86_64-unknown-linux-gnu`: $ mkdir -p /tmp/empty $ ../gcc/configure \ --disable-multilib \ --without-headers \ --with-newlib \ --enable-languages=c \ --disable-bootstrap \ --disable-gcov \ --disable-threads \ --disable-shared \ --disable-libssp \ --disable-libquadmath \ --disable-libgomp \ --disable-libatomic \ --with-build-sysroot=/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=/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=hidden -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 The change inhibits any heap-based trampoline code. libgcc/ * config/aarch64/heap-trampoline.c: Disable when libc is not present. * config/i386/heap-trampoline.c: Ditto. Diff: --- libgcc/config/aarch64/heap-trampoline.c | 5 +++++ libgcc/config/i386/heap-trampoline.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c index c8b83681ed7e..f22233987ca5 100644 --- a/libgcc/config/aarch64/heap-trampoline.c +++ b/libgcc/config/aarch64/heap-trampoline.c @@ -1,5 +1,8 @@ /* Copyright The GNU Toolchain Authors. */ +/* 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 = prev; } } + +#endif /* !inhibit_libc */ diff --git a/libgcc/config/i386/heap-trampoline.c b/libgcc/config/i386/heap-trampoline.c index 96e13bf828ea..4b9f43658689 100644 --- a/libgcc/config/i386/heap-trampoline.c +++ b/libgcc/config/i386/heap-trampoline.c @@ -1,5 +1,8 @@ /* Copyright The GNU Toolchain Authors. */ +/* 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 = prev; } } + +#endif /* !inhibit_libc */