binutils-2.23.1 build failed in raspberry pi Fix: add support armv6-portbld-freebsd10.0 in binutils' config files example: /usr/ports/devel/binutils/work/binutils-2.23.1/bfd/configure: arm-*-freebsd* | arm-*-kfreebsd*-gnu | armv6-*-freebsd*) How-To-Repeat: build binutils-2.23.1 in raspberry pi
Responsible Changed From-To: freebsd-arm->rene Take
[maintainer added] Your fix works on my Raspberry Pi running 10.0-RC2 building binutils 2.24, but later on ld complains: gmake[4]: Leaving directory `/usr/ports/devel/binutils/work/binutils-2.24/gprof' Configuring in ./ld [...] checking whether ANSI C string concatenation works... yes checking size of void *... 4 *** ld does not support target armv6-portbld-freebsd10.0 *** see ld/configure.tgt for supported targets gmake[3]: *** [configure-ld] Error 1 I patched ld/configure.tgt for this, but I'm not sure if it is correct (should it be its own target?) Patches are at http://people.freebsd.org/~rene/patches/devel__binutils.diff René
Responsible Changed From-To: rene->freebsd-arm Back to freebsd-arm, my patch produces a broken ld as can be seen in http://people.freebsd.org/~rene/patches/binutils-rpi-bug.txt
Another patchset: http://lists.freebsd.org/pipermail/freebsd-arm/2014-May/008413.html Just to keep this all in one place. I'm building it right now.
executable segfaults: $ cc -c z.c -Wall $ /usr/local/bin/ld -o z /usr/lib/crt1.o /usr/lib/crti.o z.o -lc $ file z z: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for FreeBSD 10.0 (1000710), not stripped $ ldd ./z ./z: libc.so.7 => /lib/libc.so.7 (0x2003c000) $ ./z Segmentation fault (core dumped) $ $ pkg info -xo binu binutils-2.24 devel/binutils $ uname -a FreeBSD BOZO 10.0-STABLE FreeBSD 10.0-STABLE #0 r268038: Tue Jul 1 04:29:43 UTC 2014 root@grind.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI-B arm $
Forgot to say that this was with Andreas Tobler's patchset. Also, it segfaults with the OS default ld too: $ cat z.c #include <stdio.h> int main(int argc, char **argv) { printf("mumu\n"); return 0; } $ cc -c z.c -Wall $ /usr/local/bin/ld -o z /usr/lib/crt1.o /usr/lib/crti.o z.o -lc $ ldd z z: libc.so.7 => /lib/libc.so.7 (0x2003c000) $ file z z: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for FreBSD 10.0 (1000710), not stripped $ ./z Segmentation fault (core dumped) $ /usr/bin/ld -o z /usr/lib/crt1.o /usr/lib/crti.o z.o -lc $ ldd z z: libc.so.7 => /lib/libc.so.7 (0x2003c000) $ file z z: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for FreBSD 10.0 (1000710), not stripped $ ./z Segmentation fault (core dumped) $
To get the right linker command do this: (the -v is for verbose) andreast@wandquad:~ % cc -o z z.c -v Using built-in specs. Target: armv6-undermydesk-freebsd Configured with: FreeBSD/armv6 system compiler Thread model: posix gcc version 4.2.1 20070831 patched [FreeBSD] /usr/libexec/cc1 -quiet -v -D_LONGLONG z.c -quiet -dumpbase z.c -auxbase z -version -o /tmp//ccMJ520s.s #include "..." search starts here: #include <...> search starts here: /usr/include/gcc/4.2 /usr/include End of search list. GNU C version 4.2.1 20070831 patched [FreeBSD] (armv6-undermydesk-freebsd) compiled by GNU C version 4.2.1 20070831 patched [FreeBSD]. GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=130664 Compiler executable checksum: 20743f84b7aef1f094db166caa2fbdf7 /usr/bin/as -mfpu=softvfp -meabi=4 -o /tmp//ccNNWzRe.o /tmp//ccMJ520s.s /usr/bin/ld --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -X -o z /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib -L/usr/lib /tmp//ccNNWzRe.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o GNU ld 2.17.50 [FreeBSD] 2007-07-03 Supported emulations: armelf_fbsd -->> Then build only the z.o: andreast@wandquad:~ % cc -c z.c -v Using built-in specs. Target: armv6-undermydesk-freebsd Configured with: FreeBSD/armv6 system compiler Thread model: posix gcc version 4.2.1 20070831 patched [FreeBSD] /usr/libexec/cc1 -quiet -v -D_LONGLONG z.c -quiet -dumpbase z.c -auxbase z -version -o /tmp//ccoqB09j.s #include "..." search starts here: #include <...> search starts here: /usr/include/gcc/4.2 /usr/include End of search list. GNU C version 4.2.1 20070831 patched [FreeBSD] (armv6-undermydesk-freebsd) compiled by GNU C version 4.2.1 20070831 patched [FreeBSD]. GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=130664 Compiler executable checksum: 20743f84b7aef1f094db166caa2fbdf7 /usr/bin/as -mfpu=softvfp -meabi=4 -o z.o /tmp//ccoqB09j.s --> And last, link the z.o to z: andreast@wandquad:~ % /build/gdb/testbin_armv6/bin/ld -V -Bstatic -X -o z /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbeginT.o -L/usr/lib z.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/crtend.o /usr/lib/crtn.o GNU ld (GNU Binutils) 2.24.51.20140706 Supported emulations: armelf_fbsd armelfb_fbsd armelf andreast@wandquad:~ % ./z mumu Doesn't matter if static or dynamic, at least for me. And I'm on current.
Now I'm confused even further. Your cc is GCC, whereas mine is clang: $ cc -o z z.c -v FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Target: armv6--freebsd10.0-gnueabi Thread model: posix Selected GCC installation: "/usr/bin/cc" -cc1 -triple armv6--freebsd10.0-gnueabi -S -disable-free -disable-ll vm-verifier -main-file-name z.c -mrelocation-model static -mdisable-fp-elim -mconst ructor-aliases -target-cpu arm1136jf-s -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-abi aapcs-linux -msoft-float -mfloat- abi soft -v -resource-dir /usr/bin/../lib/clang/3.4.1 -fno-dwarf-directory-asm -fde bug-compilation-dir /usr/home/mexas -ferror-limit 19 -fmessage-length 0 -mstackreal ign -fno-signed-char -fobjc-runtime=gnustep -fdiagnostics-show-option -vectorize-sl p -o /tmp/z-900faf.s -x c z.c clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target armv6-gnueabi-freebsd 10.0 ignoring nonexistent directory "/usr/bin/../lib/clang/3.4.1/include" #include "..." search starts here: #include <...> search starts here: /usr/include/clang/3.4.1 /usr/include End of search list. "/usr/bin/as" -mfpu=softvfp -meabi=5 -o /tmp/z-669589.o /tmp/z-900faf.s "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=bot h --enable-new-dtags -o z /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/us r/lib /tmp/z-669589.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-neede d -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o Clearly I need to build binutils first, before I can build GCC, right? Anyway, your other instructions helped. I could compile z.c into z.o and link it like this: /usr/local/bin/ld --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o z /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib z.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o $ ./z mumu $ So I'd say your patchset should be committed. Many thanks Anton