This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] sysroot and Windows->Linux cross ld
- From: Douglas B Rupp <rupp at adacore dot com>
- To: binutils at sourceware dot org
- Cc: Joseph Myers <joseph at codesourcery dot com>, Carlos O'Donell <carlos at redhat dot com>, Joel Brobecker <brobecker at adacore dot com>, Erwan Le Guillou <leguillou at adacore dot com>
- Date: Fri, 23 Feb 2018 10:20:08 -0800
- Subject: [PATCH] sysroot and Windows->Linux cross ld
- Authentication-results: sourceware.org; auth=none
- References: <20180117175405.6elswkryoba5yq3d@adacore.com> <7c54b3d7-5c98-12e7-ac9a-506270ad268f@redhat.com> <alpine.DEB.2.20.1801172233540.3681@digraph.polyomino.org.uk> <20180119115506.bo4gx6asfaja42kp@adacore.com>
In regards to a discussion about a bug on or about Jan 17 on the above
subject, please find attached my patch.
I don't have write access to binutils at this time.
The problem was the ld expect libiberty/lrealpath() to always return a
path, but in some cases it returns a prefix. It seemed like too much of
an earthquake to propose a fix to lrealpath.
--Douglas Rupp
AdaCore
ld/
* ldmain.c (main): Remove any trailing directory separator
from ld_canon_sysroot and adjust ld_canon_sysroot_len.
diff --git ld/ldmain.c ld/ldmain.c
index e049de3..524b7cd 100644
--- ld/ldmain.c
+++ ld/ldmain.c
@@ -237,9 +237,17 @@ main (int argc, char **argv)
if (*ld_sysroot)
ld_canon_sysroot = lrealpath (ld_sysroot);
if (ld_canon_sysroot)
- ld_canon_sysroot_len = strlen (ld_canon_sysroot);
+ {
+ ld_canon_sysroot_len = strlen (ld_canon_sysroot);
+
+ /* is_sysrooted_pathname() relies on no trailing dirsep. */
+ if (IS_DIR_SEPARATOR (ld_canon_sysroot [ld_canon_sysroot_len - 1]))
+ ld_canon_sysroot [--ld_canon_sysroot_len] = '\0';
+ }
else
- ld_canon_sysroot_len = -1;
+ {
+ ld_canon_sysroot_len = -1;
+ }
/* Set the default BFD target based on the configured target. Doing
this permits the linker to be configured for a particular target,