Bug 54504 - Link failed when I move the GCC to another directory
Summary: Link failed when I move the GCC to another directory
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-06 14:09 UTC by progmei
Modified: 2012-09-07 14:16 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-09-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description progmei 2012-09-06 14:09:21 UTC
When I move the Cross GCC to another directory, the link failed. This is a requirement, our compilers are managed by Revision control, and the directory is always changed。
And I can not choose the library use -L option also. The lib file is exist on the origional directory.

/repo/yuhuamei/mips-linux-eglibc/bin/mips-linux-g++ test.cc
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc.so.6
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc_nonshared.a
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/ld.so.1
collect2: error: ld returned 1 exit status

/repo/yuhuamei/mips-linux-eglibc/bin/mips-linux-g++ -L/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib test.cc
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc.so.6
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc_nonshared.a
/repo/yuhuamei/mips-linux-eglibc/bin/../lib/gcc/mips-linux/4.7.1/../../../../mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/ld.so.1
collect2: error: ld returned 1 exit status

ls /repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/libc.so.6 /repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/libc_nonshared.a /repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/ld.so.1
/repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/ld.so.1           /repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/libc.so.6
/repo/yuhuamei/mips-linux-eglibc/mips-linux/lib/libc_nonshared.a
Comment 1 Andrew Pinski 2012-09-06 14:13:26 UTC
It works for me.

How did you configure GCC?
Comment 2 progmei 2012-09-07 01:10:41 UTC
My configuration as follow

/repo/yuhuamei/mips-linux-eglibc/bin/mips-linux-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/yuhuamei/mips-linux-eglibc/bin/mips-linux-gcc
COLLECT_LTO_WRAPPER=/repo/yuhuamei/mips-linux-eglibc/bin/../libexec/gcc/mips-linux/4.7.1/lto-wrapper
Target: mips-linux
Configured with: ../gcc-4.7.1/configure --prefix=/repo/yuhuamei/mips-linux-eglibc-gnu --with-ppl=/repo/yuhuamei/ppl --with-cloog=/repo/yuhuamei/cloog-ppl --enable-languages=c,c++ --target=mips-linux : (reconfigured) ../gcc-4.7.1/configure --prefix=/repo/yuhuamei/mips-linux-eglibc-gnu --target=mips-linux --with-ppl=/repo/yuhuamei/ppl --with-cloog=/repo/yuhuamei/cloog-ppl --enable-__cxa_atexit --enable-languages=c,c++
Thread model: posix
gcc version 4.7.1 (GCC)
Comment 3 Andrew Pinski 2012-09-07 01:15:46 UTC
So you are not using a sysroot?
Comment 4 progmei 2012-09-07 04:49:04 UTC
no,i'm not using a sysroot
Comment 5 Andrew Pinski 2012-09-07 04:53:08 UTC
This is a cross you really should be using a sysroot.

I use 4.7.x as a cross compiler with a sysroot and am able to move around GCC all the time.
Comment 6 progmei 2012-09-07 06:35:41 UTC
I've tried to use sysroot option, but I compile the GCC failed.

../gcc-4.7.1/configure --prefix=/repo/yuhuamei/mips-linux-eglibc-gnu --target=mips-linux --with-ppl=/repo/yuhuamei/ppl  --with-cloog=/repo/yuhuamei/cloog-ppl --enable-__cxa_atexit --enable-languages=c,c++ --with-sysroot=/repo/yuhuamei/mips-linux-eglibc-gnu



/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc.so.6 inside /repo/yuhuamei/gccobjdir/gcc/../../mips-linux-eglibc-gnu
/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/libc_nonshared.a inside /repo/yuhuamei/gccobjdir/gcc/../../mips-linux-eglibc-gnu
/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/lib/ld.so.1 inside /repo/yuhuamei/gccobjdir/gcc/../../mips-linux-eglibc-gnu
Comment 7 Andrew Pinski 2012-09-07 06:38:59 UTC
>I've tried to use sysroot option, but I compile the GCC failed.
Because that is not the correct usage of sysroot.
You want a full sysroot under the prefix directory:
/repo/yuhuamei/mips-linux-eglibc-gnu/sysroot
And install the libc inside that directory.
Comment 8 progmei 2012-09-07 07:41:20 UTC
I tried it again with your suggestion, but it also failed.

../gcc-4.7.1/configure --prefix=/repo/yuhuamei/mips-linux-eglibc-gnu --target=mips-linux --with-ppl=/repo/yuhuamei/ppl  --with-cloog=/repo/yuhuamei/cloog-ppl --enable-__cxa_atexit --enable-languages=c,c++ --with-sysroot=/repo/yuhuamei/mips-linux-eglibc-gnu/sysroot

/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot/lib/libc.so.6 inside /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot
/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot/lib/libc_nonshared.a inside /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot
/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot/lib/ld.so.1 inside /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot
Comment 9 Andrew Pinski 2012-09-07 08:49:14 UTC
>/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find
> /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot/lib/libc.so.6 inside
> /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot

How are you configuring glibc?  I think that is the problem here.
You should only configure glibc with --prefix=/usr .  And then install like:
make install install_root=${MY_PREFIX}/sysroot .
Comment 10 progmei 2012-09-07 13:30:13 UTC
It's OK now. And I just have some qusetions.
If I can build the cross compiler support both soft/hard float big/little endian? And how to compile this.
where can I get the related document on how to compile the cross gcc?
Thank you!


At 2012-09-07 16:49:14,"pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> wrote:
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54504
>
>Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
>           What    |Removed                     |Added
>----------------------------------------------------------------------------
>             Status|WAITING                     |RESOLVED
>         Resolution|                            |WORKSFORME
>
>--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-09-07 08:49:14 UTC ---
>>/repo/yuhuamei/mips-linux-eglibc-gnu/mips-linux/bin/ld: cannot find
>> /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot/lib/libc.so.6 inside
>> /repo/yuhuamei/mips-linux-eglibc-gnu/sysroot
>
>How are you configuring glibc?  I think that is the problem here.
>You should only configure glibc with --prefix=/usr .  And then install like:
>make install install_root=${MY_PREFIX}/sysroot .
>
>-- 
>Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
>------- You are receiving this mail because: -------
>You reported the bug.
Comment 11 progmei 2012-09-07 14:16:15 UTC
It's OK now. And I just have some qusetions.
If I can build the cross compiler support both soft/hard float big/little endian, and how to compile it.
where can I get the related document on how to compile the cross gcc?
Thank you!