Forwarding this for our (Gentoo) arm maintainers; the original bug report with full logs is https://bugs.gentoo.org/657760 This glibc package builds fine on other architectures (it even passes the testsuite on x86 and x86_64 for me). However, on arm the following happens: gcc 7.3.0 binutils 2.30 CFLAGS="-O2 -pipe -march=armv7-a -mfpu=neon -mfloat-abi=hard" armv7a-hardfloat-linux-gnueabi-gcc -Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -nostdlib -nostartfiles -r -o /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os '-Wl,-(' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/dl-allobjs.os /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/rtld-libc.a -lgcc '-Wl,-)' \ -Wl,-Map,/mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os.map armv7a-hardfloat-linux-gnueabi-gcc -Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -nostdlib -nostartfiles -shared -o /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/ld.so.new \ -Wl,-z,combreloc -Wl,-z,relro -Wl,-z,defs -Wl,-z,now \ /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os -Wl,--version-script=/mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/ld.map \ -Wl,-soname=ld-linux-armhf.so.3 \ -Wl,-defsym=_begin=0 /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `process_dl_debug': raise.c:(.text+0x4f0): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `dso_name_valid_for_suid': raise.c:(.text+0x60c): undefined reference to `memchr' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `_dl_start': raise.c:(.text+0xc48): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `handle_ld_preload': raise.c:(.text+0x1124): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `dl_main': raise.c:(.text+0x1370): undefined reference to `memcpy' raise.c:(.text+0x2700): undefined reference to `memcpy' raise.c:(.text+0x3068): undefined reference to `memcpy' raise.c:(.text+0x3410): undefined reference to `memchr' raise.c:(.text+0x4068): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `add_name_to_object.isra.4': raise.c:(.text+0x4e80): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `_dl_map_object_from_fd': raise.c:(.text+0x5d90): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `open_verify.constprop.7': raise.c:(.text+0x66d8): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os: In function `open_path': raise.c:(.text+0x6acc): undefined reference to `memcpy' /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/librtld.os:raise.c:(.text+0x75b4): more undefined references to `memcpy' follow /usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/7.3.0/../../../../armv7a-hardfloat-linux-gnueabi/bin/ld: /mnt/distfiles/tmp/portage/sys-libs/glibc-2.27-r3/work/build-arm-armv7a-hardfloat-linux-gnueabi-nptl/elf/ld.so.new: hidden symbol `memchr' isn't defined /usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/7.3.0/../../../../armv7a-hardfloat-linux-gnueabi/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status
I poked a bit at it and I think CFLAGS is not passed to .S files (but should). The reproducer: $ ../glibc/configure --build=x86_64-pc-linux-gnu --host=armv7a-hardfloat-linux-gnueabi CFLAGS="-pipe -march=armv7-a -O2 -mfpu=neon" --prefix=/usr $ make The dtails: On armv7 -mfpu=neon should disable ifunc selection and use neon memcpy() unconditionally: $ cat glibc/sysdeps/arm/armv7/multiarch/memcpy_neon.S /* For __ARM_NEON__ this file defines memcpy. */ #ifndef __ARM_NEON__ # define memcpy __memcpy_neon # undef libc_hidden_builtin_def # define libc_hidden_builtin_def(a) #endif #define MEMCPY_NEON #include "memcpy_impl.S" Unfortunately __ARM_NEON__ is not set on .S files (CFLAGS is not propagated): armv7a-hardfloat-linux-gnueabi-gcc ../sysdeps/arm/armv7/multiarch/memcpy_neon.S -c -U_FORTIFY_SOURCE -I../include -I/home/slyfox/dev/git/glibc-armv7a-neon/string -I/home/slyfox/dev/git/glibc-armv7a-neon -I../sysdeps/unix/sysv/linux/arm -I../sysdeps/arm/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm/armv7/multiarch -I../sysdeps/arm/armv7 -I../sysdeps/arm/armv6t2 -I../sysdeps/arm/armv6 -I../sysdeps/arm/include -I../sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -D_LIBC_REENTRANT -include /home/slyfox/dev/git/glibc-armv7a-neon/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -DASSEMBLER -Werror=undef -Wa,--noexecstack -o /home/slyfox/dev/git/glibc-armv7a-neon/string/memcpy_neon.o -MD -MP -MF /home/slyfox/dev/git/glibc-armv7a-neon/string/memcpy_neon.o.dt -MT /home/slyfox/dev/git/glibc-armv7a-neon/string/memcpy_neon.o
This change fixes macro propagation: --- a/Makerules +++ b/Makerules @@ -510,10 +510,10 @@ native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@ # GCC can grok options after the file name, and it looks nicer that way. compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS) -compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \ +compile.S = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) $(S-CPPFLAGS) \ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS) -COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \ +COMPILE.S = $(CC) -c $(CFLAGS) $(CPPFLAGS) $(S-CPPFLAGS) \ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) # We need this for the output to go in the right place. It will default to
Created attachment 11065 [details] 0001-Makerules-pass-CFLAGS-when-building-.S-files-BZ-2327.patch
Sent https://sourceware.org/ml/libc-alpha/2018-06/msg00181.html for review.
Architecture selection flags need to go into CC/CXX: https://sourceware.org/ml/libc-alpha/2018-06/msg00183.html
(In reply to Florian Weimer from comment #5) > Architecture selection flags need to go into CC/CXX: > > https://sourceware.org/ml/libc-alpha/2018-06/msg00183.html In fact you can add either on CC/CXX or on both CFLAGS *and* CPPFLAGS. Either way, I think this is not a bug.
Echoing https://sourceware.org/ml/libc-alpha/2018-06/msg00224.html here: """ CFLAGS/CPPFLAGS should work for us. I was about to ask why glibc is special in handling CFLAGS. But I guess it's not special and is mimicked after default rules of GNU make. Which is: .o: .S $(AS) $(CPPFLAGS) $(ASFLAGS) ... .o: .s $(AS) $(ASFLAGS) ... Thus passing ABI flags as part of ASFLAGS might be more generic (for projects that use .s and .S). But for glibc CPPFLAGS are used in the same context as [ASFLAGS]. """ Bug can be closed as INVALID. Thanks!
As per comment #7.