public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hans-peter.nilsson@axis.com>
To: binutils@sourceware.org
Subject: RFC: allow a first "=" to mean sysroot for all paths in linker-scripts?
Date: Tue, 27 May 2014 02:32:00 -0000	[thread overview]
Message-ID: <201405270232.s4R2WUJL032457@ignucius.se.axis.com> (raw)

(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 libc.so is a linker script with the
equivalent of this line:
 GROUP ( /lib/libc.so.6 /lib/libc_nonshared.a  AS_NEEDED ( /lib/ld.so.1 ) )
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/libc.so.6 =/lib/libc_nonshared.a  AS_NEEDED ( =/lib/ld.so.1 ) )
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
suggestion.

brgds, H-P

             reply	other threads:[~2014-05-27  2:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-27  2:32 Hans-Peter Nilsson [this message]
2014-05-28 13:26 ` Hans-Peter Nilsson
2014-06-09 13:56 ` Nicholas Clifton
2014-10-09  2:55   ` [PATCH 0/6] Allow a first "=" to mean sysroot for all paths in linker-scripts Hans-Peter Nilsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201405270232.s4R2WUJL032457@ignucius.se.axis.com \
    --to=hans-peter.nilsson@axis.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).