[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] build: avoid absolute paths in executables


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 3 Sep 2025 18:12:39 +0200
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 03 Sep 2025 16:12:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.09.2025 17:26, Andrew Cooper wrote:
> On 03/09/2025 4:13 pm, Jan Beulich wrote:
>> For in-tree builds relative paths are used, whereas for out-of-tree builds
>> in various situations absolute ones come into play. The extra paths can be
>> long, wasting space and e.g. serial line bandwidth. They would also get in
>> the way of location-independent reproducible builds. Leverage newer gcc's
>> (and Clang's) ability to "remap" file names. For older gcc fall back to
>> using the option affecting debug info only.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> Of course we may want to consider putting this in the top-level Config.mk,
>> to also affect other sub-trees (presently mainly/only affecting debug
>> info, for which even gcc5 already supports -fdebug-prefix-remap=).
>>
>> As to a Fixes: tag, I wasn't quite sure whether to "blame" the
>> introduction of out-of-tree builds.
>>
>> --- a/xen/Makefile
>> +++ b/xen/Makefile
>> @@ -448,6 +448,8 @@ LDFLAGS-$(CONFIG_CC_IS_CLANG) += -plugin
>>  endif
>>  
>>  ifdef building_out_of_srctree
>> +    CFLAGS += $(call cc-option,$(CC),-ffile-prefix-map=$(srctree)/=, \
>> +                                     -fdebug-prefix-map=$(srctree)/=)
>>      CFLAGS += -I$(objtree)/include
>>      CFLAGS += -I$(objtree)/arch/$(SRCARCH)/include
>>  endif
> 
> We do want to be taking a change like this, but it's also definitely not
> limited to out-of-tree builds.  I have full paths embedded even for
> in-tree builds.

In xen-syms I see only two full paths - in debug info, supplying the base
path to the tree. That's okay to stay imo.

In xen.efi I see a few hundred, but they're all the same as above. As I
learned earlier today, SHF_MERGE processing isn't invoked when linking
ELF objects into a PE binary.

> To be useful, it wants to apply to everything, not just the hypervisor,
> so does want to be in the top level Config.mk.

As per my first remark then. But no, I meanwhile realized that this can't
go in Config.mk: For the hypervisor we want to use $(srctree), i.e.
including the leaf /xen referencing the xen/ subtree. I expect that for
e.g. tools/libs/ we'd want something similar - eliminate the entire path
up to the base of the component's source dir. So it will need to be
piecemeal.

> https://reproducible-builds.org/docs/build-path/ has a full list of
> compiler versions. It looks like we need to use both options here until
> we can increase the minimum GCC version to 8.

Not quite, -ffile-prefix-map= is documented to imply all other
-f*-prefix-map=, matching my observations.

Bottom line - at least for now I think the patch wants to remain as is,
and further patches for other parts of the tree will need making.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.