From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 1594938582BC for ; Tue, 1 Nov 2022 19:46:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1594938582BC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x535.google.com with SMTP id q71so14312293pgq.8 for ; Tue, 01 Nov 2022 12:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=W5T78bQnXcKB4m+Ww9KiwEx0ozhA3CqAOc35/6S2eJg=; b=BG9n0Vj3hHMu160nYOGgCJ8Rfz31lZRBdW0aOuAr45nmGk7zgpj6KNO6oH8r54u54o KRtn9zvWZga1LGv4AJktZLC3a1BwInbuoigk6rqohNHdUGEfN3CLc3ocblzK74ahroHJ ClcZ04kax6PfXLp+Zw/0QUPhLNBmKwZlLzYnTQH9gIgACyCvoOmnPmd7Tci3v7oy+38Q w8WcUzDipJA6cfbwig2TsUWtXtJuCuGJem1WOR6MrIIWGPwIkrXCsq0inhNz95yUR+HJ z4k4/OK7GVyfnGm0qXa3vRhsC7heiJDeJHQvWreqDPjfqWRsQiYrD5fQHVNJnpJd40io Vw0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W5T78bQnXcKB4m+Ww9KiwEx0ozhA3CqAOc35/6S2eJg=; b=DeW4W3SLvOgATx5We37y8VOLiiWOvyFlFkfDvnCyTFnk/N5OsjZSBV4cBe+U9t108C S3PWz8HpxwKP8oLl5x5xEcTcuNdDUVS3l4xkAeXYtaFdc5VFzu+MJs7roL/9XecFpuaB IHX6nN8SjGttzsDJWRoQRFKtyiP3J/ce2hZVGeFpdy02mLccF53Hq8KADxhhxocCNkBv 4F/puMoOkU3ySwKknsvthY7x4q4jL7SNt/VskAhK4FG4t6PGNEOI7BNDsv3cfJBvJSzm nrYLfQnMY3VYNCO6f6ZyErkXvWXcqiabI00yTBTEw5Su1n20ANF92cjZjQ9TS9EfrqKj q4KQ== X-Gm-Message-State: ACrzQf2yUqtr5uvdXXG8jMU7y7SmfFr3r2Nh9oz9ZdjzTjR+lENqVqZu 6SRetxed7wdGaH0fCgOt7v0= X-Google-Smtp-Source: AMsMyM6MeX0yNoEZwUnajzRRnCxX2ocB412o/eoppDLco3uTBccGY8/UWJYUHefCSUDXz7YNGS21rQ== X-Received: by 2002:a63:8b42:0:b0:46f:5bd0:1ae2 with SMTP id j63-20020a638b42000000b0046f5bd01ae2mr18061582pge.422.1667331984983; Tue, 01 Nov 2022 12:46:24 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id p189-20020a6229c6000000b0056bc9294e1asm6886135pfp.24.2022.11.01.12.46.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 12:46:24 -0700 (PDT) Message-ID: <40aa90ef-2d06-9c02-be8c-be6b6e2e9b1c@gmail.com> Date: Tue, 1 Nov 2022 13:46:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH 1/2] gcc/file-prefix-map: Allow remapping of relative paths Content-Language: en-US To: Richard Purdie , gcc-patches@gcc.gnu.org References: <20220817121534.1825108-1-richard.purdie@linuxfoundation.org> From: Jeff Law In-Reply-To: <20220817121534.1825108-1-richard.purdie@linuxfoundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 > --- > 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