OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Makefile: Pass relative paths to the compiler.
@ 2021-11-29  1:55 Vagrant Cascadian
  2021-11-29  3:05 ` Dong Du
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Vagrant Cascadian @ 2021-11-29  1:55 UTC (permalink / raw)
  To: opensbi

Upstream commit 12753d22563f7d2d01f2c6644c7b66b06eb5c90f introduced
uses of __FILE__ which may result in the build path getting embedded
into the resulting binary.

https://reproducible-builds.org/docs/build-path/

Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
Cc: Xiang W <wxjstz@126.com>
Cc: Anup Patel <anup@brainfault.org>
---
Changes since v1:

* Pass relative paths to the compiler instead of using
  -ffile-prefix-map to strip out the full paths, as suggested by Xiang
  W.

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8623c1c..d017534 100644
--- a/Makefile
+++ b/Makefile
@@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
 	       -MM $(2) >> $(1) || rm -f $(1)
 compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
 	     echo " CC        $(subst $(build_dir)/,,$(1))"; \
-	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2) -o $(1)
+	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(subst $(src_dir)/,,$(2)) -o $(1)
 compile_as_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
 	     echo " AS-DEP    $(subst $(build_dir)/,,$(1))"; \
 	     printf %s `dirname $(1)`/ > $(1) && \
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-11-29  1:55 [PATCH v2] Makefile: Pass relative paths to the compiler Vagrant Cascadian
@ 2021-11-29  3:05 ` Dong Du
  2021-11-29  3:58 ` Xiang W
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Dong Du @ 2021-11-29  3:05 UTC (permalink / raw)
  To: opensbi




On Nov 29, 2021, at 9:55 AM, Vagrant Cascadian vagrant at reproducible-builds.org wrote:

> Upstream commit 12753d22563f7d2d01f2c6644c7b66b06eb5c90f introduced
> uses of __FILE__ which may result in the build path getting embedded
> into the resulting binary.
> 
> https://reproducible-builds.org/docs/build-path/
> 
> Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
> Cc: Xiang W <wxjstz@126.com>
> Cc: Anup Patel <anup@brainfault.org>
> ---
> Changes since v1:
> 
> * Pass relative paths to the compiler instead of using
>  -ffile-prefix-map to strip out the full paths, as suggested by Xiang
>  W.
> 
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 8623c1c..d017534 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
> 	       -MM $(2) >> $(1) || rm -f $(1)
> compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
> 	     echo " CC        $(subst $(build_dir)/,,$(1))"; \
> -	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2) -o $(1)
> +	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(subst
> $(src_dir)/,,$(2)) -o $(1)

Looks good to me.

Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn>

> compile_as_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
> 	     echo " AS-DEP    $(subst $(build_dir)/,,$(1))"; \
> 	     printf %s `dirname $(1)`/ > $(1) && \
> --
> 2.30.2
> 
> 
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-11-29  1:55 [PATCH v2] Makefile: Pass relative paths to the compiler Vagrant Cascadian
  2021-11-29  3:05 ` Dong Du
@ 2021-11-29  3:58 ` Xiang W
  2021-11-29 10:35 ` Andreas Schwab
  2021-12-02  3:46 ` Anup Patel
  3 siblings, 0 replies; 7+ messages in thread
From: Xiang W @ 2021-11-29  3:58 UTC (permalink / raw)
  To: opensbi

? 2021-11-28???? 17:55 -0800?Vagrant Cascadian???
> Upstream commit 12753d22563f7d2d01f2c6644c7b66b06eb5c90f introduced
> uses of __FILE__ which may result in the build path getting embedded
> into the resulting binary.
> 
> https://reproducible-builds.org/docs/build-path/
> 
> Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
> Cc: Xiang W <wxjstz@126.com>
> Cc: Anup Patel <anup@brainfault.org>
Looks good to me.

Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> Changes since v1:
> 
> * Pass relative paths to the compiler instead of using
> ? -ffile-prefix-map to strip out the full paths, as suggested by
> Xiang
> ? W.
> 
> ?Makefile | 2 +-
> ?1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 8623c1c..d017534 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname
> $(1)`; \
> ?????????????? -MM $(2) >> $(1) || rm -f $(1)
> ?compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
> ???????????? echo " CC??????? $(subst $(build_dir)/,,$(1))"; \
> -??????????? $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2)
> -o $(1)
> +??????????? $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c
> $(subst $(src_dir)/,,$(2)) -o $(1)
> ?compile_as_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
> ???????????? echo " AS-DEP??? $(subst $(build_dir)/,,$(1))"; \
> ???????????? printf %s `dirname $(1)`/ > $(1) && \




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-11-29  1:55 [PATCH v2] Makefile: Pass relative paths to the compiler Vagrant Cascadian
  2021-11-29  3:05 ` Dong Du
  2021-11-29  3:58 ` Xiang W
@ 2021-11-29 10:35 ` Andreas Schwab
  2021-11-29 18:13   ` Vagrant Cascadian
  2021-12-02  3:46 ` Anup Patel
  3 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2021-11-29 10:35 UTC (permalink / raw)
  To: opensbi

On Nov 28 2021, Vagrant Cascadian wrote:

> diff --git a/Makefile b/Makefile
> index 8623c1c..d017534 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>  	       -MM $(2) >> $(1) || rm -f $(1)
>  compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>  	     echo " CC        $(subst $(build_dir)/,,$(1))"; \
> -	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2) -o $(1)
> +	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(subst $(src_dir)/,,$(2)) -o $(1)

How about making src_dir empty throughout?  This now depends on
$(src_dir) being identical to ".", so making that explicit would be
better.

Andreas.

-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-11-29 10:35 ` Andreas Schwab
@ 2021-11-29 18:13   ` Vagrant Cascadian
  0 siblings, 0 replies; 7+ messages in thread
From: Vagrant Cascadian @ 2021-11-29 18:13 UTC (permalink / raw)
  To: opensbi

On 2021-11-29, Andreas Schwab wrote:
> On Nov 28 2021, Vagrant Cascadian wrote:
>
>> diff --git a/Makefile b/Makefile
>> index 8623c1c..d017534 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>>  	       -MM $(2) >> $(1) || rm -f $(1)
>>  compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>>  	     echo " CC        $(subst $(build_dir)/,,$(1))"; \
>> -	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2) -o $(1)
>> +	     $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(subst $(src_dir)/,,$(2)) -o $(1)
>
> How about making src_dir empty throughout?  This now depends on
> $(src_dir) being identical to ".", so making that explicit would be
> better.

Is this more-or-less what you were suggesting?

diff --git a/Makefile b/Makefile
index 8623c1c..cd4be3c 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ READLINK ?= readlink
 endif
 
 # Find out source, build, and install directories
-src_dir=$(CURDIR)
+src_dir=.
 ifdef O
  build_dir=$(shell $(READLINK) -f $(O))
 else


It builds fine (haven't boot tested), and doesn't embed the build path
in the binaries.


live well,
  vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/opensbi/attachments/20211129/56b04f77/attachment-0001.sig>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-11-29  1:55 [PATCH v2] Makefile: Pass relative paths to the compiler Vagrant Cascadian
                   ` (2 preceding siblings ...)
  2021-11-29 10:35 ` Andreas Schwab
@ 2021-12-02  3:46 ` Anup Patel
  2021-12-03 20:43   ` Vagrant Cascadian
  3 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2021-12-02  3:46 UTC (permalink / raw)
  To: opensbi

On Mon, Nov 29, 2021 at 7:25 AM Vagrant Cascadian
<vagrant@reproducible-builds.org> wrote:
>
> Upstream commit 12753d22563f7d2d01f2c6644c7b66b06eb5c90f introduced
> uses of __FILE__ which may result in the build path getting embedded
> into the resulting binary.
>
> https://reproducible-builds.org/docs/build-path/
>
> Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
> Cc: Xiang W <wxjstz@126.com>
> Cc: Anup Patel <anup@brainfault.org>

Now that we have sbi_panic() and SBI_ASSERT() in-place (Jessica's patch), we
don't need to change the top-level Makefile because __FILE__ is not
used anywhere
in sources.

Going forward, we should avoid taking patches that use __FILE__ so that we don't
break reproducible builds.

Regards,
Anup

> ---
> Changes since v1:
>
> * Pass relative paths to the compiler instead of using
>   -ffile-prefix-map to strip out the full paths, as suggested by Xiang
>   W.
>
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 8623c1c..d017534 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,7 +361,7 @@ compile_cc_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>                -MM $(2) >> $(1) || rm -f $(1)
>  compile_cc = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>              echo " CC        $(subst $(build_dir)/,,$(1))"; \
> -            $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(2) -o $(1)
> +            $(CC) $(CFLAGS) $(call dynamic_flags,$(1),$(2)) -c $(subst $(src_dir)/,,$(2)) -o $(1)
>  compile_as_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
>              echo " AS-DEP    $(subst $(build_dir)/,,$(1))"; \
>              printf %s `dirname $(1)`/ > $(1) && \
> --
> 2.30.2
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] Makefile: Pass relative paths to the compiler.
  2021-12-02  3:46 ` Anup Patel
@ 2021-12-03 20:43   ` Vagrant Cascadian
  0 siblings, 0 replies; 7+ messages in thread
From: Vagrant Cascadian @ 2021-12-03 20:43 UTC (permalink / raw)
  To: opensbi

On 2021-12-02, Anup Patel wrote:
> On Mon, Nov 29, 2021 at 7:25 AM Vagrant Cascadian
> <vagrant@reproducible-builds.org> wrote:
>>
>> Upstream commit 12753d22563f7d2d01f2c6644c7b66b06eb5c90f introduced
>> uses of __FILE__ which may result in the build path getting embedded
>> into the resulting binary.
>>
>> https://reproducible-builds.org/docs/build-path/
>>
>> Signed-off-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
>> Cc: Xiang W <wxjstz@126.com>
>> Cc: Anup Patel <anup@brainfault.org>
>
> Now that we have sbi_panic() and SBI_ASSERT() in-place (Jessica's patch), we
> don't need to change the top-level Makefile because __FILE__ is not
> used anywhere
> in sources.

I can confirm that fixes the issue of embedded build paths.


> Going forward, we should avoid taking patches that use __FILE__ so that we don't
> break reproducible builds.

Thanks for keeping reproducible builds in mind!


live well,
  vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/opensbi/attachments/20211203/d1985595/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-03 20:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-29  1:55 [PATCH v2] Makefile: Pass relative paths to the compiler Vagrant Cascadian
2021-11-29  3:05 ` Dong Du
2021-11-29  3:58 ` Xiang W
2021-11-29 10:35 ` Andreas Schwab
2021-11-29 18:13   ` Vagrant Cascadian
2021-12-02  3:46 ` Anup Patel
2021-12-03 20:43   ` Vagrant Cascadian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox