public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] gcc/file-prefix-map: Allow remapping of relative paths
Date: Tue, 1 Nov 2022 13:46:20 -0600	[thread overview]
Message-ID: <40aa90ef-2d06-9c02-be8c-be6b6e2e9b1c@gmail.com> (raw)
In-Reply-To: <20220817121534.1825108-1-richard.purdie@linuxfoundation.org>


On 8/17/22 06:15, Richard Purdie via Gcc-patches wrote:
> Relative paths currently aren't remapped by -ffile-prefix-map and friends.
> When cross compiling with separate 'source' and 'build' directories, the same
> relative paths between directories may not be available on target as compared
> to build time.
>
> In order to be able to remap these relative build paths to paths that would
> work on target, resolve paths within the file-prefix-map function using
> realpath().

Understood.


>
> This does cause a change of behaviour if users were previously relying upon
> symlinks or absolute paths not being resolved.

I'm not too worried about this scenario.


>
> Use basename to ensure plain filenames don't have paths added.
>
> gcc/ChangeLog:
>
>      * file-prefix-map.cc (remap_filename): Allow remapping of relative paths

Basically OK.  Just formatting nit:



>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>   gcc/file-prefix-map.cc | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/file-prefix-map.cc b/gcc/file-prefix-map.cc
> index 24733f831d6..50d5d724a8f 100644
> --- a/gcc/file-prefix-map.cc
> +++ b/gcc/file-prefix-map.cc
> @@ -70,19 +70,28 @@ remap_filename (file_prefix_map *maps, const char *filename)
>     file_prefix_map *map;
>     char *s;
>     const char *name;
> +  char *realname;
>     size_t name_len;
>   
> +  if (lbasename (filename) == filename)
> +    return filename;
> +
> +  realname = lrealpath (filename);
> +
>     for (map = maps; map; map = map->next)
> -    if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
> +    if (filename_ncmp (realname, map->old_prefix, map->old_len) == 0)
>         break;
> -  if (!map)
> +  if (!map) {
> +    free (realname);
>       return filename;
> -  name = filename + map->old_len;
> +  }


Put the the curley braces go on their own lines, indented two 
positions.  The code inside the curleys is indented two more 
positions.   I fixed that and pushed this change to the trunk.


THanks,

jeff



  parent reply	other threads:[~2022-11-01 19:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 12:15 Richard Purdie
2022-08-17 12:15 ` [PATCH 2/2] libcpp: Avoid remapping filenames within directives Richard Purdie
2022-08-17 14:19   ` Richard Purdie
2022-11-01 19:32   ` Jeff Law
2022-11-02 10:52     ` Richard Purdie
2022-11-01 19:46 ` Jeff Law [this message]
2023-01-19 13:06   ` [PATCH 1/2] gcc/file-prefix-map: Allow remapping of relative paths Jakub Jelinek
2023-01-20 15:05   ` [PATCH] file-prefix-map: Fix up -f*-prefix-map= [PR108464] Jakub Jelinek
2023-01-23 15:39     ` Jakub Jelinek
2023-03-10  8:49     ` Patch ping - " Jakub Jelinek
2023-03-10  9:05       ` Richard Biener
2023-03-10 10:14         ` Richard Purdie
2022-11-04  9:12 ` [PATCH 1/2] gcc/file-prefix-map: Allow remapping of relative paths Eric Botcazou
2022-11-04 17:21   ` Richard Purdie
2022-11-07  8:01     ` Eric Botcazou
2022-11-07 16:21       ` Jeff Law
2022-11-07 16:36         ` Eric Botcazou

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=40aa90ef-2d06-9c02-be8c-be6b6e2e9b1c@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.purdie@linuxfoundation.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).