Bug#1143851: hppa-linux-gnu-gcc does not honor -ffreestanding, generating referencs to memset
Michael Tokarev <[email protected]>
| Newsgroups | gmane.linux.debian.devel.gcc |
|---|---|
| Message-ID | <789e1070-1454-4ba9-b31c-f76235ed9b76__1246.79814777977$1786564049$gmane$org@tls.msk.ru> |
On 8/12/26 18:48, John David Anglin wrote: > If you add -save-temps to the compile options for your program, the .i, .s and .o files > will be generated. I suspect you will only see memset.constprop.0 in the .s and .o > intermediate files. However, there are likely some undefined symbols in the .o that > need to be resolved by linking against libgcc. There are millicode routines in it for > multiplication, etc, and routines for unwind EH support (e.g., uw_frame_state_for) that > use memset. The binary is actually linked against libgcc too, that's not the problem. -save-temps helps ofc, but the output is quite a bit too large. I was trying to simplify the thing. But it looks like the prob has been identified already... >> It feels like the prob is .constprop.0 suffix, added with -fwhole-program? Because ... >> Without -fwhole-program it seems to work. But I dunno if the resulting binary >> works. > > At the moment, I would say hppa is not compatible with -fwhole-program. The > simplest fix might be to add "_attribute__((used, externally_visible))" to the memcpy > declaration in your code. And this one helps to finish the build, and it finishes successfully. > This what google said about this: > [...] I see. It's a fun stuff. So, for the time being, I'm including this workaround. For the future, I guess something has to be done with the build system to avoid -fwhole-program (Cc'ing Helge Deller). BTW, this is the complete compiler command line: hppa64-linux-gnu-gcc -I. -Io64/ -Isrc -Ivgasrc -Os -MD -g \ -Wall -Wno-strict-aliasing -Wold-style-definition -Wno-address-of-packed-member \ -Wno-stringop-overflow -Wno-array-bounds -Wtype-limits \ -fomit-frame-pointer -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks \ -fdata-sections -fno-common -fno-merge-constants -mdisable-fpregs -fno-builtin-printf \ -fno-ipa-sra -fno-pie -fno-stack-protector -fstack-check=no -Wno-pointer-to-int-cast \ -Wno-int-to-pointer-cast -DMODE16=0 -DMODESEGMENT=0 -fwhole-program -DWHOLE_PROGRAM \ -c o64/ccode32flat.o.tmp.c -o o64/ccode32flat.o Without -fwhole-program there are numerous error messages in there, such as "impossible constraint in 'asm'" - many of them. Different optimization levels - such as omitting -Os - gives the same errors too. Thank you very much for the help! /mjt