* collect2/ld doesn't search all paths dumped by gcc -print-search-dirs
@ 2009-02-22 1:29 John Z. Bohach
2009-02-23 20:51 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: John Z. Bohach @ 2009-02-22 1:29 UTC (permalink / raw)
To: gcc-help
I'm trying to build a tiny test program using an alternate toolchain
built purely from source (LFS ch. 5 method), but collect2 says that ld
can't find a lib. that _does_ exist under /usr/lib, but /usr/lib is not
even attempted as part of the search, even though /usr/lib _is_ part of
the library search path dumped by "gcc -print-search-dirs".
Bizarre...what am I misunderstanding?
Here are the particulars:
The program I'm building:
#include <stdio.h>
int main() { printf("Ok\n"); return(0); }
The build command line:
/tools/bin/gcc -o
try -O2 -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -L/usr/local/lib
try.c -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -Wl,--verbose
The failure:
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/bin/ld:
cannot find -lgdbm
collect2: ld returned 1 exit status
The pertinent parts of the -Wl,--verbose output from the build attempt:
GNU ld (GNU Binutils) 2.18
Supported emulations:
elf_i386
i386linux
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
"elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SEARCH_DIR("/tools/i686-pc-linux-uclibc/lib"); SEARCH_DIR("/tools/lib");
...
attempt to open /usr/local/lib/libgdbm.so failed
attempt to open /usr/local/lib/libgdbm.a failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.so
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.a
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/libgdbm.so
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/libgdbm.a
failed
attempt to open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.so
failed
attempt to open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.a
failed
attempt to open /usr/lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.so
failed
attempt to open /usr/lib/gcc/i686-pc-linux-uclibc/4.2.2/libgdbm.a failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/libgdbm.so
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/libgdbm.a
failed
attempt to
open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/libgdbm.so
failed
attempt to
open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/libgdbm.a
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../libgdbm.so
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../libgdbm.a
failed
attempt to
open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../libgdbm.so
failed
attempt to
open /tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../libgdbm.a
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/i686-pc-linux-uclibc/bin/../lib/libgdbm.so
failed
attempt to
open /data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/i686-pc-linux-uclibc/bin/../lib/libgdbm.a
failed
attempt to open /tools/i686-pc-linux-uclibc/lib/libgdbm.so failed
attempt to open /tools/i686-pc-linux-uclibc/lib/libgdbm.a failed
attempt to open /tools/lib/libgdbm.so failed
attempt to open /tools/lib/libgdbm.a failed
And the thing that makes this bizarre:
/tools/bin/gcc -print-search-dirs | sed 's/:/\n/g'
install
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/
programs
=/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../libexec/gcc/i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../libexec/gcc/
/tools/libexec/gcc/i686-pc-linux-uclibc/4.2.2/
/tools/libexec/gcc/i686-pc-linux-uclibc/4.2.2/
/tools/libexec/gcc/i686-pc-linux-uclibc/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/
/tools/lib/gcc/i686-pc-linux-uclibc/
/usr/libexec/gcc/i686-pc-linux-uclibc/4.2.2/
/usr/libexec/gcc/i686-pc-linux-uclibc/
/usr/lib/gcc/i686-pc-linux-uclibc/4.2.2/
/usr/lib/gcc/i686-pc-linux-uclibc/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/bin/i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/bin/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/bin/i686-pc-linux-uclibc/4.2.2/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/bin/
libraries
=/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/
/usr/lib/gcc/i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/i686-pc-linux-uclibc/4.2.2/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../../i686-pc-linux-uclibc/lib/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../i686-pc-linux-uclibc/4.2.2/
/data/devo/builds/i686-pc-linux-uclibc/orsus-2/rootfs/tools/bin/../lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../i686-pc-linux-uclibc/4.2.2/
/tools/lib/gcc/i686-pc-linux-uclibc/4.2.2/../../../
/lib/i686-pc-linux-uclibc/4.2.2/
/lib/
/usr/lib/i686-pc-linux-uclibc/4.2.2/
/usr/lib/
Note the /usr/lib on the last line!
Just for reference,
ls -al /usr/lib/libgdbm*
-rw-r--r-- 1 root root 123184 2009-02-11 16:05 /usr/lib/libgdbm.a
-rw-r--r-- 1 root root 83410 2009-02-11 16:05 /usr/lib/libgdbm_compat.a
So WHY is /usr/lib NOT being searched by ld? Isn't collect2 supposed to
pass on the same library paths as dumped by gcc -print-search-dirs to
ld? Any ideas?
FYI:
/tools/bin/gcc -dumpspecs
*asm:
%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
*asm_debug:
%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}
*asm_final:
*asm_options:
%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}
*invoke_as:
%{!S:-o %|.s |
as %(asm_options) %|.s %A }
*cpp:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
*cpp_options:
%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{f*} %{g*:
%{!g0:
%{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} %{save-temps:-fpch-preprocess}
*cpp_debug_options:
%{d*}
*cpp_unique_options:
%{C|CC:%{!E:%eGCC does not support -C or -CC
without -E}} %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD %{!o:
%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:
%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:
%{MD|MMD:
%{o*:-MQ %*}}}}} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{fmudflap:-D_MUDFLAP -include
mf-runtime.h} %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include
mf-runtime.h} %{E|M|MM:%W{o*}}
*trad_capable_cpp:
cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}
*cc1:
%(cc1_cpu) %{profile:-p}
*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are
incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{c|S:
%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:
%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:
%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|
fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}
*cc1plus:
*link_gcc_c_sequence:
%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}
*link_ssp:
%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}
*endfile:
%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} %{shared|
pie:crtendS.o%s;:crtend.o%s} crtn.o%s
*link:
%{!static:--eh-frame-hdr} -m %(link_emulation) %{shared:-shared} %{!shared: %{!ibcs: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} %{static:-static}}}
*lib:
%{pthread:-lpthread} %{shared:-lc} %{!shared:
%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}
*mfwrap:
%{static: %{fmudflap|
fmudflapth: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc --wrap=mmap --wrap=munmap --wrap=alloca} %{fmudflapth: --wrap=pthread_create}} %{fmudflap|
fmudflapth: --wrap=main}
*mflib:
%{fmudflap|fmudflapth: -export-dynamic}
*link_gomp:
*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:
%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}
*startfile:
%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}
crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
*switches_need_spaces:
*cross_compile:
0
*version:
4.2.2
*multilib:
. ;
*multilib_defaults:
*multilib_extra:
*multilib_matches:
*multilib_exclusions:
*multilib_options:
*linker:
collect2
*link_libgcc:
%D
*md_exec_prefix:
*md_startfile_prefix:
*md_startfile_prefix_1:
*startfile_prefix_spec:
*sysroot_spec:
--sysroot=%R
*sysroot_suffix_spec:
*sysroot_hdrs_suffix_spec:
*cc1_cpu:
%{!mtune*: %{m386:mtune=i386 %n`-m386' is deprecated. Use `-march=i386'
or `-mtune=i386' instead.
} %{m486:-mtune=i486 %n`-m486' is deprecated. Use `-march=i486' or
`-mtune=i486' instead.
} %{mpentium:-mtune=pentium %n`-mpentium' is deprecated. Use
`-march=pentium' or `-mtune=pentium' instead.
} %{mpentiumpro:-mtune=pentiumpro %n`-mpentiumpro' is deprecated. Use
`-march=pentiumpro' or `-mtune=pentiumpro' instead.
} %{mcpu=*:-mtune=%* %n`-mcpu=' is deprecated. Use `-mtune='
or '-march=' instead.
}} %<mcpu=* %{mintel-syntax:-masm=intel %n`-mintel-syntax' is
deprecated. Use `-masm=intel' instead.
} %{mno-intel-syntax:-masm=att %n`-mno-intel-syntax' is deprecated. Use
`-masm=att' instead.
}%{march=native:%<march=native %:local_cpu_detect(arch) %{!mtune=*:
%<mtune=native %:local_cpu_detect(tune)}} %{mtune=native:
%<mtune=native %:local_cpu_detect(tune)}
*link_emulation:
elf_i386
*dynamic_linker:
%{mglibc:%{muclibc:%e-mglibc and -muclibc used
together}/tools/lib/ld-linux.so.2;:/tools/lib/ld-uClibc.so.0}
*link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:
%{!S: %(linker) %l %{pie:-pie} %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:
%{!nostdlib:%{!nostartfiles:
%S}}} %{static:} %{L*} %(mfwrap) %(link_libgcc) %o %{fopenmp:
%:include(libgomp.spec)%(link_gomp)} %(mflib) %{fprofile-arcs|
fprofile-generate|coverage:-lgcov} %{!nostdlib:%{!nodefaultlibs:
%(link_ssp) %(link_gcc_c_sequence)}} %{!A:%{!nostdlib:
%{!nostartfiles:%E}}} %{T*} }}}}}}
Also, note that I am doing a native build on a i686-pc-linux-uclibc
system that works fine in all other regards...except that this is an
alternate toolchain's gcc that I'm using...but its still
i686-pc-linux-uclibc.
Any ideas?
Thanks,
John
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: collect2/ld doesn't search all paths dumped by gcc -print-search-dirs
2009-02-22 1:29 collect2/ld doesn't search all paths dumped by gcc -print-search-dirs John Z. Bohach
@ 2009-02-23 20:51 ` Ian Lance Taylor
2009-02-23 22:46 ` John Z. Bohach
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2009-02-23 20:51 UTC (permalink / raw)
To: John Z. Bohach; +Cc: gcc-help
"John Z. Bohach" <jzb2@aexorsyst.com> writes:
> I'm trying to build a tiny test program using an alternate toolchain
> built purely from source (LFS ch. 5 method), but collect2 says that ld
> can't find a lib. that _does_ exist under /usr/lib, but /usr/lib is not
> even attempted as part of the search, even though /usr/lib _is_ part of
> the library search path dumped by "gcc -print-search-dirs".
> Bizarre...what am I misunderstanding?
That certainly seems peculiar and may indicate a bug. Try running gcc
with the -v option to set the list of -L options which gcc passes to
collect2. Those options should all be passed on to the linker. You can
also run gcc with the option -Wl,-debug to see debugging information
from collect2.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: collect2/ld doesn't search all paths dumped by gcc -print-search-dirs
2009-02-23 20:51 ` Ian Lance Taylor
@ 2009-02-23 22:46 ` John Z. Bohach
0 siblings, 0 replies; 3+ messages in thread
From: John Z. Bohach @ 2009-02-23 22:46 UTC (permalink / raw)
To: gcc-help; +Cc: Ian Lance Taylor
On Monday 23 February 2009 12:51:07 pm Ian Lance Taylor wrote:
> "John Z. Bohach" <jzb2@aexorsyst.com> writes:
> > I'm trying to build a tiny test program using an alternate
> > toolchain built purely from source (LFS ch. 5 method), but collect2
> > says that ld can't find a lib. that _does_ exist under /usr/lib,
> > but /usr/lib is not even attempted as part of the search, even
> > though /usr/lib _is_ part of the library search path dumped by "gcc
> > -print-search-dirs". Bizarre...what am I misunderstanding?
>
> That certainly seems peculiar and may indicate a bug. Try running
> gcc with the -v option to set the list of -L options which gcc passes
> to collect2. Those options should all be passed on to the linker.
> You can also run gcc with the option -Wl,-debug to see debugging
> information from collect2.
Thanks for the response...I think I may have figured it out...
What I forgot to mention (wasn't aware of when I initially posted...) is
that the original 'ld' against which gcc was compiled was been switched
out. This new one has a more limited search path, and in fact appears
to conform to what the real search path really is, at least as far as
the linker goes.
So, if the '-print-search-dirs' option results are calculated at gcc
build time, and stored statically in the gcc binary, and do include the
linker's search path, and it does appear to, then the peculiarity is
solved. Since the linker has been switched, the static (if it is in
fact static) string that is dumped by the -print-search-dirs option is
stale.
Probably wouldn't consider this a bug, especially because this a rare
corner-case, but maybe an enhancement request to print the calculated
search-dirs. based on current ld search paths, if this is in fact what
I'm running into...I don't know, its probably not that important,
probably only needs documentation, and this forum should count for
that. Just confirmation about the string is really all that's needed,
at least IMHO.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-23 22:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-22 1:29 collect2/ld doesn't search all paths dumped by gcc -print-search-dirs John Z. Bohach
2009-02-23 20:51 ` Ian Lance Taylor
2009-02-23 22:46 ` John Z. Bohach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).