Re: Dynamic linking is go (again)

Izumi Tsutsui <[email protected]>
Newsgroups gmane.os.netbsd.ports.sh3,gmane.os.netbsd.ports.dreamcast
Message-ID <[email protected]>
In article <[email protected]>
[email protected] wrote:

> The -nostdlib comes from bsd.prog.mk, right?

Yes. It was passed if DESTDIR is set, and DESTDIR is set
unless USETOOLS=no.

> Does it choose the wrong
> crt*.o, or put the objects in the wrong order or something perhaps?
> If -nostdlib is specified, all crt objects must be added manually, and
> this makefile might not be updated to work with gcc3...

crt*.o files are also set properly by bsd.prog.mk and
they are passed to gcc(1), but gcc(1) does not pass "-e __start"
to collect2 in that case even with your gcc3.3 toolchain:
---
% pwd
/usr/src/bin/cat
% make CC=/usr/local/bin/gcc HAVE_GCC3=yes MKPROFILE=no -n
/usr/local/bin/gcc   -o cat -nostdlib  -Wl,-dynamic-linker=/libexec/ld.elf_so \
-Wl,-rpath-link,/lib:/usr/lib  -R/lib -R/usr/lib  -L/lib /usr/lib/crt0.o \
/usr/lib/crti.o /usr/lib/crtbegin.o cat.o  -L/usr/lib -L/usr/lib  \
-lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
% /usr/local/bin/gcc   -o cat -nostdlib  \
-Wl,-dynamic-linker=/libexec/ld.elf_so -Wl,-rpath-link,/lib:/usr/lib  \
-R/lib -R/usr/lib  -L/lib /usr/lib/crt0.o /usr/lib/crti.o \
/usr/lib/crtbegin.o cat.o  -L/usr/lib -L/usr/lib  -lgcc -lc -lgcc \
/usr/lib/crtend.o /usr/lib/crtn.o -v
Reading specs from /usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/specs
Configured with: /home/marcus/gcc-3.3/configure \
--enable-languages=c,c++ --disable-shared
Thread model: single
gcc version 3.3
 /usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/collect2 -m shlelf_nbsd \
-R/lib -R/usr/lib -dc -dp -dynamic-linker /usr/libexec/ld.elf_so -o cat \
-L/lib -L/usr/lib -L/usr/lib \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3 \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/../../../../shl-unknown-netbsdelf1.6T/lib \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/../../.. \
-dynamic-linker=/libexec/ld.elf_so -rpath-link /lib:/usr/lib \
/usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o cat.o -lgcc -lc -lgcc \
/usr/lib/crtend.o /usr/lib/crtn.o
% 
(and generated binary dumps core)
---

If USETOOLS=no is set (i.e. DESTDIR is not set in that case),
-nostdlib is not passed to gcc and collect2 is called with "-e __start":
---
% make CC=/usr/local/bin/gcc HAVE_GCC3=yes MKPROFILE=no USETOOLS=no -n
/usr/local/bin/gcc   -o cat  -Wl,-dynamic-linker=/libexec/ld.elf_so \
-Wl,-rpath-link,/lib:/usr/lib  -R/lib -R/usr/lib  -L/lib cat.o 
% /usr/local/bin/gcc   -o cat  -Wl,-dynamic-linker=/libexec/ld.elf_so \
-Wl,-rpath-link,/lib:/usr/lib  -R/lib -R/usr/lib  -L/lib cat.o -v
Reading specs from /usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/specs
Configured with: /home/marcus/gcc-3.3/configure \
--enable-languages=c,c++ --disable-shared
Thread model: single
gcc version 3.3
 /usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/collect2 -m shlelf_nbsd \
-R/lib -R/usr/lib -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so \
-o cat /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/lib \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3 \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/../../../../shl-unknown-netbsdelf1.6T/lib \
-L/usr/local/lib/gcc-lib/shl-unknown-netbsdelf1.6T/3.3/../../.. \
-dynamic-linker=/libexec/ld.elf_so -rpath-link /lib:/usr/lib cat.o \
-lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
%
(This binary works fine)
---

We should check LINK_SPEC or something in gcc-3.3?
---
Izumi Tsutsui
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.