This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: allow a first "=" to mean sysroot for all paths in linker-scripts?

(Basically all the verbiage below boils down to the subject line.)

Is there a reason not to allow a first character '=' to mean
sysroot-prefix for all paths inside linker scripts?  Today, it's
interpreted that way for SEARCH_DIR, but elsewhere it's a syntax
error.  Allowing this would remove the ambiguity there is today,
in that the interpretation of absolute paths depends on
how/where the linker script is found during linking.

When you deal with build-systems that copy target toolchain
files around, including DSOs and linker scripts, and point at
them with linker options, this helps e.g. sysrooted toolchains
to fit in a non-sysrooted environment and would stop some
accidental misconfigurations from appearing to work.  For
example, as most readers of this list knows, for a sysrooted or
native system, the glibc is a linker script with the
equivalent of this line:
 GROUP ( /lib/ /lib/libc_nonshared.a  AS_NEEDED ( /lib/ ) )
where the paths are interpreted by the BFD linker to mean
"prefix all those absolute paths with sysroot" if the script is
found as a subdirectory of the linker sysroot (the configured
default or specified) or "no prefix" if found elsewhere.  I
haven't looked at what gold does.  This may look like a feature
but IMHO has a horrible potential to pick up the wrong files.
At least there's visible breakage for cross-builds when the
target system is different to the host system.  Less obvious
breakage when the host and target are superficially compatible.

For a non-sysrooted cross-toolchain you make the above line work
by adjusting those paths manually in the installed script,
prefixing with the installation prefix.  That'd remove the
accidental ambiguity and work for the sysrooted installation
too, but unfortunately that effectively stops otherwise
unaltered relocation of the toolchain (moving it around in the
build environment file-system), where it would otherwise work
out of the box when moved, IIUC.

Thus the interest in forcing the sysroot prefix.  Luckily,
there's existing syntax, the "=" character.  Even luckier, today
you get a syntax error if the above line reads:
 GROUP ( =/lib/ =/lib/libc_nonshared.a  AS_NEEDED ( =/lib/ ) )
so it seems no existing valid use needs to be considered for
unquoted paths.  For quoted paths there's theoretical conflict
with an actual path by that name, but IMHO that argument would
be trumped by consistency with the SEARCH_DIR interpretation.
Native non-sysroot installations can even use the same script as
the default is "" without a configured sysroot.  (ISTR use of
sysrooted native linkers, but are there any, where the default
sysroot isn't ""?)

So again, how about treating "=" as the sysroot prefix for
*all* paths in linker scripts?
What to do about quoted paths?
(I suggest both quoted and unquoted "="-prefixed paths to work.)

I'm looking for a "patches are welcome" reply, or a valid reason
to not follow through, or of course potential issues with the

brgds, H-P

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]