Skip to contentSkip to conversation

dt-bindings: Remove example file on dt-extract-example error

PATCH In review Rob Herring 2 participants 5 messages May 10, 2022 – May 17, 2022 Device tree bindings

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 dt-bindings: Remove example file on dt-extract-example error

As 'dt-extract-example' writes the example dts files to stdout, a file is always created even on an error such as Ctrl-C. The resulting empty file(s) then cause unexpected errors on subsequent builds. Fix this by removing the output file on any error.

---
 Documentation/devicetree/bindings/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/Makefile +1 -1
index c9953f86b19d..c9fadff3dd74 100644
@@ -20,7 +20,7 @@ check_dtschema_version:
 	{ echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; }
 
 quiet_cmd_extract_ex = DTEX    $@
-      cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@
+      cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ || rm $@
 
 $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
 	$(call if_changed,extract_ex)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Rob Herring

As 'dt-extract-example' writes the example dts files to stdout, a file is always created even on an error such as Ctrl-C. The resulting empty file(s) then cause unexpected errors on subsequent builds. Fix this by removing the output file on any error.

Did you really set it?

The target deletion on interrupt is automatic
since the following commit:

commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0

Author: Masahiro Yamada <[email protected]>
Date:   Fri Jul 20 16:46:33 2018 +0900

kbuild: add .DELETE_ON_ERROR special target

Quoted 21 lines
---
 Documentation/devicetree/bindings/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/Makefile +1 -2
index c9953f86b19d..c9fadff3dd74 100644
@@ -20,7 +20,7 @@ check_dtschema_version:
        { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; }
 
 quiet_cmd_extract_ex = DTEX    $@
-      cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@
+      cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ || rm $@
 
 $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
        $(call if_changed,extract_ex)
--

2.34.1

Signature · 2 lines
Best Regards
Masahiro Yamada
author maintainer
#2 lore raw
Quoted 10 lines · Masahiro Yamada
Quoted 6 lines · Rob Herring

As 'dt-extract-example' writes the example dts files to stdout, a file is always created even on an error such as Ctrl-C. The resulting empty file(s) then cause unexpected errors on subsequent builds. Fix this by removing the output file on any error.

Did you really set it?

Set what?

I'm sure I've gotten empty files which then throw errors on the next run.

Quoted 10 lines

The target deletion on interrupt is automatic
since the following commit:

commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0

Author: Masahiro Yamada <[email protected]>
Date:   Fri Jul 20 16:46:33 2018 +0900

kbuild: add .DELETE_ON_ERROR special target

You're saying I shouldn't need this change? For some reason I do...

Rob

#3 lore raw
Quoted 11 lines · Rob Herring
Quoted 9 lines · Masahiro Yamada
Quoted 6 lines · Rob Herring

As 'dt-extract-example' writes the example dts files to stdout, a file is always created even on an error such as Ctrl-C. The resulting empty file(s) then cause unexpected errors on subsequent builds. Fix this by removing the output file on any error.

Quoted 3 lines
Quoted 1 line

Did you really set it?

Set what?

Sorry for the typo. I meant "Did you really see it?"

Quoted 3 lines

I'm sure I've gotten empty files which then throw errors on the next run.

Hmm, OK.

When you observed this issue, were you using
a pipe to another program?

For example,

  $  make  dt_binding_check  2>&1  |  tee  dt_binding_check.log
Quoted 9 lines
Quoted 9 lines

The target deletion on interrupt is automatic
since the following commit:

commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0

Author: Masahiro Yamada <[email protected]>
Date:   Fri Jul 20 16:46:33 2018 +0900
Quoted 5 lines
Quoted 1 line

kbuild: add .DELETE_ON_ERROR special target

You're saying I shouldn't need this change? For some reason I do...

Rob

If .DELETE_ON_ERROR works as the manual [1] explains,

[1] https://www.gnu.org/software/make/manual/make.html#Special-Targets

the deletion of the target is automatic.

Basically, it worked like that, except when Make is piped to another program.

I asked this in GNU Make ML before.

When Make is piped to another program, which is terminated by Ctrl-C, Make is also killed by SIGPIPE before cleaning up the incomplete targets.

Signature · 2 lines
Best Regards
Masahiro Yamada
author maintainer
#4 lore raw
Quoted 25 lines · Masahiro Yamada
Quoted 11 lines · Rob Herring
Quoted 9 lines · Masahiro Yamada
Quoted 6 lines · Rob Herring

As 'dt-extract-example' writes the example dts files to stdout, a file is always created even on an error such as Ctrl-C. The resulting empty file(s) then cause unexpected errors on subsequent builds. Fix this by removing the output file on any error.

Quoted 3 lines
Quoted 1 line

Did you really set it?

Set what?

Sorry for the typo. I meant "Did you really see it?"

Quoted 3 lines

I'm sure I've gotten empty files which then throw errors on the next run.

Quoted 9 lines

Hmm, OK.

When you observed this issue, were you using
a pipe to another program?

For example,

  $  make  dt_binding_check  2>&1  |  tee  dt_binding_check.log

Indeed, I am. I only do that all the time in my build script...

Quoted 24 lines
Quoted 10 lines
Quoted 10 lines

The target deletion on interrupt is automatic
since the following commit:

commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0

Author: Masahiro Yamada <[email protected]>
Date:   Fri Jul 20 16:46:33 2018 +0900
Quoted 5 lines
Quoted 1 line

kbuild: add .DELETE_ON_ERROR special target

You're saying I shouldn't need this change? For some reason I do...

Rob

If .DELETE_ON_ERROR works as the manual [1] explains,

[1] https://www.gnu.org/software/make/manual/make.html#Special-Targets

the deletion of the target is automatic.

Quoted 6 lines

Basically, it worked like that, except when Make is piped to another program.

I asked this in GNU Make ML before.

When Make is piped to another program, which is terminated by Ctrl-C, Make is also killed by SIGPIPE before cleaning up the incomplete targets.

Humm, that seems to make the feature less useful to rely on.

Rob