Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-05

How does FPC calculate linker search paths upon -XP?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bruce Tulloch

Using FPC 2.7.1 I'm cross-compiling from x86_64 to ARM/RPi and have specified:

-XR/usr/local/opt/chroot/raspbian/rootfs

This produces a link.res file that includes the following:

SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf/") SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/lib/") SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/usr/lib/")

but it DOES NOT include this line:

SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/lib/arm-linux-gnueabihf/")

despite the fact the ld.so configuration file:

/usr/local/opt/chroot/raspbian/rootfs/etc/ld.so.conf.d/arm-linux-gnueabihf.conf

specifies both paths as:

# Multiarch support
/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabihf

What am I doing wrong?

Thanks, Bruce

Bruce Tulloch
to Bruce Tulloch

So it looks like -XR is not the solution for cross-compiling, at least in my case.

The compiler option I used:

-XR/usr/local/opt/chroot/raspbian/rootfs

seems to break when the linker encounters a linker script that specifies a new path for the actual library object required; these generated paths are not prepended when using -XR.

Instead one needs to use --sysroot so I've replaced this one line with:

-Xd
-k--sysroot=/usr/local/opt/chroot/raspbian/rootfs
-Fl/usr/local/opt/chroot/raspbian/rootfs/lib/arm-linux-gnueabihf -Fl/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf

disabling the default paths and making explicit the paths one actually requires. I still don't understand how FPC generates the search paths per my previous email but at least this alternative, verbose though it is, seems to work.

Is this the correct (i.e. "best practice") solution?

Thanks, Bruce.

Bruce Tulloch wrote 32 lines
Using FPC 2.7.1 I'm cross-compiling from x86_64 to ARM/RPi and have specified: -XR/usr/local/opt/chroot/raspbian/rootfs This produces a link.res file that includes the following: SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf/") SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/lib/") SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/usr/lib/") but it DOES NOT include this line: SEARCH_DIR("/usr/local/opt/chroot/raspbian/rootfs/lib/arm-linux-gnueabihf/") despite the fact the ld.so configuration file: /usr/local/opt/chroot/raspbian/rootfs/etc/ld.so.conf.d/arm-linux-gnueabihf.conf specifies both paths as: # Multiarch support /lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf What am I doing wrong? Thanks, Bruce
Jonas Maebe
to Bruce Tulloch
Bruce Tulloch wrote 13 lines
So it looks like -XR is not the solution for cross-compiling, at least in my case. The compiler option I used: -XR/usr/local/opt/chroot/raspbian/rootfs seems to break when the linker encounters a linker script that specifies a new path for the actual library object required; these generated paths are not prepended when using -XR.

Under Linux, -XR currently prepends the internal compiler library search paths with the path specified to -XR. The compiler does not pass --sysroot to the linker because sysroot support is optional in GNU ld (and hence always passing it would also break compilation in certain scenarios).

The compiler does not (try to) parse ld.so.conf*. The paths you saw before are hardcoded in the compiler binary.

Show quoted text 15 lines
Instead one needs to use --sysroot so I've replaced this one line with: -Xd -k--sysroot=/usr/local/opt/chroot/raspbian/rootfs -Fl/usr/local/opt/chroot/raspbian/rootfs/lib/arm-linux-gnueabihf -Fl/usr/local/opt/chroot/raspbian/rootfs/usr/lib/arm-linux-gnueabihf disabling the default paths and making explicit the paths one actually requires. I still don't understand how FPC generates the search paths per my previous email but at least this alternative, verbose though it is, seems to work. Is this the correct (i.e. "best practice") solution?

Probably, yes.

Jonas

Jonas Maebe
to Bruce Tulloch: Using FPC 2.7.1 I'm cross-compiling from x86_64 to ARM/RPi and have specified:…
Bruce Tulloch wrote 10 lines
despite the fact the ld.so configuration file: /usr/local/opt/chroot/raspbian/rootfs/etc/ld.so.conf.d/arm-linux- gnueabihf.conf specifies both paths as: # Multiarch support /lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf

For the record: the compile-time linker only reads ld.so.conf when compiling *natively*, not when cross-compiling. See the ld man page and search for "ld.so.conf".

Jonas