[fpc-devel] Cross-compiling and warnings from linker
Jonas Maebe
jonas at freepascal.org
Mon Nov 22 15:52:09 CET 2021
On 21/11/2021 20:51, Sergey Organov via fpc-devel wrote:
> Then, in the /etc/fpc.cfg file, among a lot of statements inappropriate
> for cross-compilation (that happen to do no harm in my case), that is
> only expected for the file that belongs to installed native compiler,
> there is unconditional
>
> -Fl/usr/lib/$fpctarget-*
>
> directive that causes all this noise due to another bug, see below.
This one needs to become -Fl=/usr/lib/$fpctarget-* (see
https://wiki.freepascal.org/User_Changes_3.2.0#Library_search_directories_and_custom_sysroots
)
> 1. Globbing bug in TSearchPathList.AddLibraryPath() could likely affect
> even native (as opposed to cross) compilations. The bug is that it
> effectively silently translates /<path>/<anything>*<suffix> to
> /<path>/*<suffix> for the purposes of globbing, while fpc.cfg definitely
> assumes more reasonable behavior for globbing of /usr/lib/$fpctarget-*
> specification.
That indeed seems like a bug.
> 2. When -XR is provided, the fpc.cfg should likely be searched for
> relative to the sysroot, and /etc/fpc.cfg should never be implicitly
> used by cross-compiler.
The sysroot parameter only tells the compiler/linker where to look for
system libraries and system object files. It is unrelated to the
compiler's own configuration. The searched locations for configuration
files is always the same (current directory, ~/.fpc.cfg, /etc/fpc.cfg).
> Further, even for a native compiler being installed, say, in /usr/local,
> the fpc.cfg should probably be searched for in /usr/local/etc rather
> than in /etc,so the policy of searching for fpc.cfg should probably be
> revised in general.
It is indeed possible to argue for this, but that would be a significant
backward compatibility breakage and I'm not sure it would be worth it.
> 3. This is unrelated to the issue, but worth to be mentioned anyway. For
> whatever reason, -XR causes FPC to alter its strategy with respect to
> creation of the link.res file, and instead of augmenting of what is
> already there in GNU ld for given target, it entirely replaces GNU ld
> idea of suitable linker script with some outdated version of one being
> built-in into FPC. I failed to guess what's the reason for it, so I tend
> to think it's a design mistake.
This has been fixed in trunk already. It was originally done that way
because older versions of GNU LD did not support augmentation of
built-in linker scripts, only replacing them wholesale. When we
initially added support for GNU LD versions that did support
augmentation, it was only implemented for native targets. Only more
recently someone checked that it indeed also works correctly for
cross-compiling and it was changed there as well.
Jonas
More information about the fpc-devel
mailing list