Skip to contentSkip to conversation

package/pkg-cargo.mk: fix handling of debug and runtime debug builds

PATCH In review Moritz Bitsch via buildroot 2 participants 3 messages Oct 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/pkg-cargo.mk: fix handling of debug and runtime debug builds

From: Moritz Bitsch <[email protected]>

* when not supplying --release to cargo various optimizations get disabled, resulting in slower runtime: use BR2_ENABLE_RUNTIME_DEBUG

* Debug symbol generation can be controlled with the RUSTFLAGS variable:
add -g to RUSTFLAGS for debug symbols

---
 package/pkg-cargo.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +8 -2
index f7e3f39503..7ce7867f67 100644
@@ -51,9 +51,15 @@ PKG_CARGO_ENV = \
 # and should be removed when fixed upstream
 #
 ifeq ($(NORMALIZED_ARCH),arm)
-	PKG_CARGO_ENV += RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
+	PKG_CARGO_RUSTFLAGS += -Clink-arg=-Wl,--allow-multiple-definition
 endif
 
+ifeq ($(BR2_ENABLE_DEBUG),y)
+	PKG_CARGO_RUSTFLAGS += -g
+endif
+
+PKG_CARGO_ENV += RUSTFLAGS=$(subst $(space),$(comma),$(strip $(PKG_CARGO_RUSTFLAGS)))
+
 HOST_PKG_CARGO_ENV = \
 	$(PKG_COMMON_CARGO_ENV)
 
@@ -119,7 +125,7 @@ define $(2)_BUILD_CMDS
 		$$($(2)_CARGO_ENV) \
 		cargo build \
 			--offline \
-			$$(if $$(BR2_ENABLE_DEBUG),,--release) \
+			$$(if $$(BR2_ENABLE_RUNTIME_DEBUG),,--release) \
 			--manifest-path Cargo.toml \
 			--locked \
 			$$($(2)_CARGO_BUILD_OPTS)
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Moritz, All,

On 2022-10-19 10:53 +0200, Moritz Bitsch via buildroot spake thusly:

Quoted 7 lines

From: Moritz Bitsch <[email protected]>

* when not supplying --release to cargo various optimizations get disabled, resulting in slower runtime: use BR2_ENABLE_RUNTIME_DEBUG

* Debug symbol generation can be controlled with the RUSTFLAGS variable:
add -g to RUSTFLAGS for debug symbols

Two changes, two patches, please. Yes, they are very related, but the second one is a new feature, so should be a separate patch.

Quoted 12 lines
---
 package/pkg-cargo.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +0 -0
index f7e3f39503..7ce7867f67 100644
@@ -51,9 +51,15 @@ PKG_CARGO_ENV = \
 # and should be removed when fixed upstream
 #

package/pkg-cargo.mk PKG_CARGO_ENV = \ · line 61

Quoted 10 lines
package/pkg-cargo.mk +6 -1
 ifeq ($(NORMALIZED_ARCH),arm)
-	PKG_CARGO_ENV += RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
+	PKG_CARGO_RUSTFLAGS += -Clink-arg=-Wl,--allow-multiple-definition
 endif
 
+ifeq ($(BR2_ENABLE_DEBUG),y)
+	PKG_CARGO_RUSTFLAGS += -g
+endif
+
+PKG_CARGO_ENV += RUSTFLAGS=$(subst $(space),$(comma),$(strip $(PKG_CARGO_RUSTFLAGS)))

I was about to say that we had the make-comma-list macro for that, and that's too bad I badly named it, because it also introduces a space after the comma, so it is not fitted here...

We could tweak it not to introduce the space, but it is also used to create meson lists, and I'm not sure the space is required there or not. If it's not, then we can tweak it (and introduce make-comma-sp-list if needed elsewhere).

Meh, forget it...

Regards,
Yann E. MORIN.

Quoted 19 lines
package/pkg-cargo.mk +1 -1
 HOST_PKG_CARGO_ENV = \
 	$(PKG_COMMON_CARGO_ENV)
 
@@ -119,7 +125,7 @@ define $(2)_BUILD_CMDS
 		$$($(2)_CARGO_ENV) \
 		cargo build \
 			--offline \
-			$$(if $$(BR2_ENABLE_DEBUG),,--release) \
+			$$(if $$(BR2_ENABLE_RUNTIME_DEBUG),,--release) \
 			--manifest-path Cargo.toml \
 			--locked \
 			$$($(2)_CARGO_BUILD_OPTS)
Signature · 6 lines
2.37.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Yann,

Am 19.10.22 um 23:05 schrieb Yann E. MORIN:

Quoted 5 lines

Moritz, All,

On 2022-10-19 10:53 +0200, Moritz Bitsch via buildroot spake thusly:

Quoted 2 lines

From: Moritz Bitsch <[email protected]>

Quoted 7 lines
Quoted 5 lines

* when not supplying --release to cargo various optimizations get disabled, resulting in slower runtime: use BR2_ENABLE_RUNTIME_DEBUG

* Debug symbol generation can be controlled with the RUSTFLAGS variable:
add -g to RUSTFLAGS for debug symbols

Two changes, two patches, please. Yes, they are very related, but the second one is a new feature, so should be a separate patch.

Sure, I'm going to split the commit and re submit the patch. Sorry for the noise.

Regards,

Moritz Bitsch

Quoted 51 lines
Quoted 12 lines
---
  package/pkg-cargo.mk | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +0 -0
index f7e3f39503..7ce7867f67 100644
@@ -51,9 +51,15 @@ PKG_CARGO_ENV = \
  # and should be removed when fixed upstream
  #

package/pkg-cargo.mk PKG_CARGO_ENV = \ · line 61

Quoted 10 lines
package/pkg-cargo.mk +6 -1
  ifeq ($(NORMALIZED_ARCH),arm)
-	PKG_CARGO_ENV += RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
+	PKG_CARGO_RUSTFLAGS += -Clink-arg=-Wl,--allow-multiple-definition
  endif
 
+ifeq ($(BR2_ENABLE_DEBUG),y)
+	PKG_CARGO_RUSTFLAGS += -g
+endif
+
+PKG_CARGO_ENV += RUSTFLAGS=$(subst $(space),$(comma),$(strip $(PKG_CARGO_RUSTFLAGS)))

I was about to say that we had the make-comma-list macro for that, and that's too bad I badly named it, because it also introduces a space after the comma, so it is not fitted here...

We could tweak it not to introduce the space, but it is also used to create meson lists, and I'm not sure the space is required there or not. If it's not, then we can tweak it (and introduce make-comma-sp-list if needed elsewhere).

Meh, forget it...

Regards,
Yann E. MORIN.

Quoted 15 lines
package/pkg-cargo.mk +1 -1
  HOST_PKG_CARGO_ENV = \
  	$(PKG_COMMON_CARGO_ENV)
 
@@ -119,7 +125,7 @@ define $(2)_BUILD_CMDS
  		$$($(2)_CARGO_ENV) \
  		cargo build \
  			--offline \
-			$$(if $$(BR2_ENABLE_DEBUG),,--release) \
+			$$(if $$(BR2_ENABLE_RUNTIME_DEBUG),,--release) \
  			--manifest-path Cargo.toml \
  			--locked \
  			$$($(2)_CARGO_BUILD_OPTS)
Signature · 1 line
2.37.3
Quoted 4 lines
Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot