Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - errata: linux linker default ld-script: (5 Items)
   
errata: linux linker default ld-script  
Binutils Developers,

It appears that the in QNX 640, 641, 650, the default linker script(s) compiled into the QNX-supplied binutils ld have a
 default library search path:

SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");

Running ld -verbose shows that these paths are indeed searched during linking.

Under no circumstances should a QNX crossdev build search in the native linux build directories for libraries.

dave

Re: errata: linux linker default ld-script  
On 11-04-04 08:01 AM, dave carlson wrote:
>
> Binutils Developers,
>
> It appears that the in QNX 640, 641, 650, the default linker script(s)
> compiled into the QNX-supplied binutils ld have a default library search
> path:
>
> SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
>
> Running ld -verbose shows that these paths are indeed searched during
> linking.

These paths get prefixed by the sysroot which gets supplied by the 
compiler drivers. If you're directly invoking ld, then you need to 
specify the --sysroot option . e.g. 
--sysroot=/opt/qnx650/target/qnx6/x86/. For most cases, using the 
compiler drivers to link is easier to use since there are a number of 
default options that need to be specified. e.g. linking in proper crt 
files, --dynamic-linker, etc.

But yes I suppose some gear could be added to make the default sysroot 
respect the $QNX_TARGET env variable. I'll open a bug for that.

Regards,

Ryan Mansfield
RE: errata: linux linker default ld-script  
Ryan,

Thanks for the quick response.

We do use the qcc wrapper.  The problem isn't finding "your" libs.  I have no problem with current method to find QNX 
xdev libs.  It is easy and it works.

The problem is "our" libs that appear to be later on the search path than the SEARCH_DIRs.  (Or lord-forbid, someone has
 a missing or typo-ed -L search path for a required lib.)

Vis., a common library (say libxml.a) that I need to link with may find the linux one.  Finding a linux library for a 
xdev build should be *very* hard to do -- not compile-time hard-wired "easy".  For xdev, will the SEARCH_DIRS ever be "
good"?

dave
 

-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Monday, April 04, 2011 9:31 AM
To: general-toolchain
Subject: Re: errata: linux linker default ld-script

On 11-04-04 08:01 AM, dave carlson wrote:
>
> Binutils Developers,
>
> It appears that the in QNX 640, 641, 650, the default linker script(s)
> compiled into the QNX-supplied binutils ld have a default library search
> path:
>
> SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
>
> Running ld -verbose shows that these paths are indeed searched during
> linking.

These paths get prefixed by the sysroot which gets supplied by the 
compiler drivers. If you're directly invoking ld, then you need to 
specify the --sysroot option . e.g. 
--sysroot=/opt/qnx650/target/qnx6/x86/. For most cases, using the 
compiler drivers to link is easier to use since there are a number of 
default options that need to be specified. e.g. linking in proper crt 
files, --dynamic-linker, etc.

But yes I suppose some gear could be added to make the default sysroot 
respect the $QNX_TARGET env variable. I'll open a bug for that.

Regards,

Ryan Mansfield



_______________________________________________

General
http://community.qnx.com/sf/go/post84560
Re: errata: linux linker default ld-script  
On 11-04-04 09:44 AM, dave carlson wrote:
> Ryan,
>
> Thanks for the quick response.
>
> We do use the qcc wrapper. The problem isn't finding "your" libs. I have
> no problem with current method to find QNX xdev libs. It is easy and it
> works.
>
> The problem is "our" libs that appear to be later on the search path
> than the SEARCH_DIRs. (Or lord-forbid, someone has a missing or typo-ed
> -L search path for a required lib.)
>
> Vis., a common library (say libxml.a) that I need to link with may find
> the linux one. Finding a linux library for a xdev build should be *very*
> hard to do -- not compile-time hard-wired "easy". For xdev, will the
> SEARCH_DIRS ever be "good"?

SEARCH_DIRS should always get prefixed with the sysroot so the search of 
these prefixed directories shouldn't result in linking against any host 
libraries. Even without the --sysroot supplied on the command line from 
the drivers, we have a default sysroot of $QNX_TARGET. ld should never 
have a default sysroot of / for cross linking so it should never be 
searching just

With the 6.5.0 binutils 2.19.1

$ ntox86-ld --verbose  -lxml2 -L/foo/bar
<snip>
attempt to open /foo/bar/libxml2.so failed
attempt to open /foo/bar/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/usr/local/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/usr/local/lib/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/lib/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/usr/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/usr/lib/libxml2.a failed
ntox86-ld: cannot find -lxml2
$ ls -al /usr/lib/libxml2.so
lrwxrwxrwx 1 root root 25 2011-04-04 10:03 /usr/lib/libxml2.so -> 
/usr/lib/libxml2.so.2.7.7

As you can see that the user supplied directories are searched before 
the SEARCH_DIRS prefixed with the default sysroot, and that the libxml2 
on my host isn't being found. Which version of the binutils are you using?

I agree that there's no way it should be picking up the host libraries 
so I want get to the bottom of this issue. Can you provide a simple 
example of what you're encountering?

Regards,

Ryan Mansfield
RE: errata: linux linker default ld-script  
I concur with your result under qcc.   I concede I must have been looking at a "raw" ld without a sysroot -- which 
scared the sh*t out of me.

My mistake.  Sorry to waste your time.

dave



-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Monday, April 04, 2011 10:17 AM
To: general-toolchain
Subject: Re: errata: linux linker default ld-script

On 11-04-04 09:44 AM, dave carlson wrote:
> Ryan,
>
> Thanks for the quick response.
>
> We do use the qcc wrapper. The problem isn't finding "your" libs. I have
> no problem with current method to find QNX xdev libs. It is easy and it
> works.
>
> The problem is "our" libs that appear to be later on the search path
> than the SEARCH_DIRs. (Or lord-forbid, someone has a missing or typo-ed
> -L search path for a required lib.)
>
> Vis., a common library (say libxml.a) that I need to link with may find
> the linux one. Finding a linux library for a xdev build should be *very*
> hard to do -- not compile-time hard-wired "easy". For xdev, will the
> SEARCH_DIRS ever be "good"?

SEARCH_DIRS should always get prefixed with the sysroot so the search of 
these prefixed directories shouldn't result in linking against any host 
libraries. Even without the --sysroot supplied on the command line from 
the drivers, we have a default sysroot of $QNX_TARGET. ld should never 
have a default sysroot of / for cross linking so it should never be 
searching just

With the 6.5.0 binutils 2.19.1

$ ntox86-ld --verbose  -lxml2 -L/foo/bar
<snip>
attempt to open /foo/bar/libxml2.so failed
attempt to open /foo/bar/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/usr/local/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/usr/local/lib/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/lib/libxml2.a failed
attempt to open /opt/qnx650/target/qnx6/usr/lib/libxml2.so failed
attempt to open /opt/qnx650/target/qnx6/usr/lib/libxml2.a failed
ntox86-ld: cannot find -lxml2
$ ls -al /usr/lib/libxml2.so
lrwxrwxrwx 1 root root 25 2011-04-04 10:03 /usr/lib/libxml2.so -> 
/usr/lib/libxml2.so.2.7.7

As you can see that the user supplied directories are searched before 
the SEARCH_DIRS prefixed with the default sysroot, and that the libxml2 
on my host isn't being found. Which version of the binutils are you using?

I agree that there's no way it should be picking up the host libraries 
so I want get to the bottom of this issue. Can you provide a simple 
example of what you're encountering?

Regards,

Ryan Mansfield




_______________________________________________

General
http://community.qnx.com/sf/go/post84567