Skip to contentSkip to conversation

package/pkg-cargo: ensure host/target rustflags are properly split

PATCH Applied James Hilliard 4 participants 6 messages Apr 10, 2023 – Apr 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/pkg-cargo: ensure host/target rustflags are properly split

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config

We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"

Separately set target RUSTFLAGS for the target triple specific env variable.

---
Changes v2 -> v3:
- rebase
Changes v1 -> v2:
- add RUSTFLAGS to HOST_PKG_CARGO_ENV

---
 package/pkg-cargo.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +8 -2
index 5600c8e97e..264bf5a1ae 100644
@@ -34,7 +34,10 @@ PKG_COMMON_CARGO_ENV = \
 # using nighly features on stable releases, i.e features that are not
 # yet considered stable.
 #
-# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" "enables the nightly
+# CARGO_UNSTABLE_HOST_CONFIG="true" enables the host specific
+# configuration feature
+#
+# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
 # configuration option target-applies-to-host value to be set
 #
 # CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
@@ -43,9 +46,11 @@ PKG_COMMON_CARGO_ENV = \
 PKG_CARGO_ENV = \
 	$(PKG_COMMON_CARGO_ENV) \
 	__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" \
+	CARGO_UNSTABLE_HOST_CONFIG="true" \
 	CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
 	CARGO_TARGET_APPLIES_TO_HOST="false" \
 	CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
+	CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \
 	CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
 
 #
@@ -53,7 +58,8 @@ 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_ENV += \
+		CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
 endif
 
 HOST_PKG_CARGO_ENV = \
Signature · 6 lines
2.34.1

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

James, all,

On 2023-04-10 02:32 -0600, James Hilliard spake thusly:

Quoted 10 lines

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config

We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"

Separately set target RUSTFLAGS for the target triple specific env variable.

FTR, Arnout did a review of a previous iteration, and proposed a commt log with a lot more details and explanations on the actual reasons why we have to do this change:

    https://lore.kernel.org/buildroot/[email protected]/

Could you please reveview what he wrote, and incorporate that in your commit log (and amend/extend further if needed), and then respin, please?

Regards,
Yann E. MORIN.

Quoted 54 lines

---
Changes v2 -> v3:
- rebase
Changes v1 -> v2:
- add RUSTFLAGS to HOST_PKG_CARGO_ENV

---
 package/pkg-cargo.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +8 -2
index 5600c8e97e..264bf5a1ae 100644
@@ -34,7 +34,10 @@ PKG_COMMON_CARGO_ENV = \
 # using nighly features on stable releases, i.e features that are not
 # yet considered stable.
 #
-# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" "enables the nightly
+# CARGO_UNSTABLE_HOST_CONFIG="true" enables the host specific
+# configuration feature
+#
+# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
 # configuration option target-applies-to-host value to be set
 #
 # CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
@@ -43,9 +46,11 @@ PKG_COMMON_CARGO_ENV = \
 PKG_CARGO_ENV = \
 	$(PKG_COMMON_CARGO_ENV) \
 	__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" \
+	CARGO_UNSTABLE_HOST_CONFIG="true" \
 	CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
 	CARGO_TARGET_APPLIES_TO_HOST="false" \
 	CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
+	CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \
 	CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
 
 #
@@ -53,7 +58,8 @@ 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_ENV += \
+		CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
 endif
 
 HOST_PKG_CARGO_ENV = \
Signature · 6 lines
2.34.1

_______________________________________________
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
Quoted 12 lines · Yann E. MORIN

James, all,

On 2023-04-10 02:32 -0600, James Hilliard spake thusly:

Quoted 9 lines

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config

We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"

Separately set target RUSTFLAGS for the target triple specific env variable.

Quoted 7 lines
Quoted 1 line

FTR, Arnout did a review of a previous iteration, and proposed a commt log with a lot more details and explanations on the actual reasons why we have to do this change:

     https://lore.kernel.org/buildroot/[email protected]/

Actually, that was supposed to be a reply to this v3, my bad...

@james just confirmation that my proposed commit log is enough, I already have
it lined up for pushing.

Regards,
Arnout

Quoted 54 lines

Could you please reveview what he wrote, and incorporate that in your commit log (and amend/extend further if needed), and then respin, please?

Regards,
Yann E. MORIN.

Quoted 46 lines

---
Changes v2 -> v3:
- rebase
Changes v1 -> v2:
- add RUSTFLAGS to HOST_PKG_CARGO_ENV

---
  package/pkg-cargo.mk | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +8 -2
index 5600c8e97e..264bf5a1ae 100644
@@ -34,7 +34,10 @@ PKG_COMMON_CARGO_ENV = \
  # using nighly features on stable releases, i.e features that are not
  # yet considered stable.
  #
-# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" "enables the nightly
+# CARGO_UNSTABLE_HOST_CONFIG="true" enables the host specific
+# configuration feature
+#
+# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
  # configuration option target-applies-to-host value to be set
  #
  # CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
@@ -43,9 +46,11 @@ PKG_COMMON_CARGO_ENV = \
  PKG_CARGO_ENV = \
  	$(PKG_COMMON_CARGO_ENV) \
  	__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" \
+	CARGO_UNSTABLE_HOST_CONFIG="true" \
  	CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
  	CARGO_TARGET_APPLIES_TO_HOST="false" \
  	CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
+	CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \
  	CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
 
  #
@@ -53,7 +58,8 @@ 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_ENV += \
+		CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
  endif
 
Quoted 9 lines
Quoted 8 lines
package/pkg-cargo.mk +0 -0
  HOST_PKG_CARGO_ENV = \
Signature · 6 lines
2.34.1

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

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

#3 lore raw
Quoted 22 lines · Arnout Vandecappelle
Quoted 18 lines · Yann E. MORIN

James, all,

On 2023-04-10 02:32 -0600, James Hilliard spake thusly:

Quoted 10 lines

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config

We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"

Separately set target RUSTFLAGS for the target triple specific env variable.

FTR, Arnout did a review of a previous iteration, and proposed a commt log with a lot more details and explanations on the actual reasons why we have to do this change:

Quoted 6 lines
Quoted 1 line
     https://lore.kernel.org/buildroot/[email protected]/

Actually, that was supposed to be a reply to this v3, my bad...

@james just confirmation that my proposed commit log is enough, I already have
it lined up for pushing.

Yep, looks good to me.

Quoted 67 lines

Regards,
Arnout

Quoted 63 lines

Could you please reveview what he wrote, and incorporate that in your commit log (and amend/extend further if needed), and then respin, please?

Regards,
Yann E. MORIN.

Quoted 54 lines

---
Changes v2 -> v3:
- rebase
Changes v1 -> v2:
- add RUSTFLAGS to HOST_PKG_CARGO_ENV

---
  package/pkg-cargo.mk | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +8 -3
index 5600c8e97e..264bf5a1ae 100644
@@ -34,7 +34,10 @@ PKG_COMMON_CARGO_ENV = \
  # using nighly features on stable releases, i.e features that are not
  # yet considered stable.
  #
-# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" "enables the nightly
+# CARGO_UNSTABLE_HOST_CONFIG="true" enables the host specific
+# configuration feature
+#
+# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
  # configuration option target-applies-to-host value to be set
  #
  # CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
@@ -43,9 +46,11 @@ PKG_COMMON_CARGO_ENV = \
  PKG_CARGO_ENV = \
     $(PKG_COMMON_CARGO_ENV) \
     __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" \
+    CARGO_UNSTABLE_HOST_CONFIG="true" \
     CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
     CARGO_TARGET_APPLIES_TO_HOST="false" \
     CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
+    CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \
     CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
 
  #
@@ -53,7 +58,8 @@ 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_ENV += \
+            CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
  endif
 
  HOST_PKG_CARGO_ENV = \
--

2.34.1

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

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

#4 lore raw
In reply to James Hilliard
Quoted 10 lines · James Hilliard

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config

We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"

Separately set target RUSTFLAGS for the target triple specific env variable.

Applied to master after a complete rewrite of the commit message, thanks.

Regards,
Arnout

Quoted 38 lines

---
Changes v2 -> v3:
- rebase
Changes v1 -> v2:
- add RUSTFLAGS to HOST_PKG_CARGO_ENV

---
  package/pkg-cargo.mk | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
package/pkg-cargo.mk +6 -1
index 5600c8e97e..264bf5a1ae 100644
@@ -34,7 +34,10 @@ PKG_COMMON_CARGO_ENV = \
  # using nighly features on stable releases, i.e features that are not
  # yet considered stable.
  #
-# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" "enables the nightly
+# CARGO_UNSTABLE_HOST_CONFIG="true" enables the host specific
+# configuration feature
+#
+# CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" enables the nightly
  # configuration option target-applies-to-host value to be set
  #
  # CARGO_TARGET_APPLIES_TO_HOST="false" is actually setting the value
@@ -43,9 +46,11 @@ PKG_COMMON_CARGO_ENV = \
  PKG_CARGO_ENV = \
  	$(PKG_COMMON_CARGO_ENV) \
  	__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" \
+	CARGO_UNSTABLE_HOST_CONFIG="true" \
  	CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
  	CARGO_TARGET_APPLIES_TO_HOST="false" \
  	CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
+	CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \
  	CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
 
  #

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

Quoted 9 lines
package/pkg-cargo.mk +2 -1
@@ -53,7 +58,8 @@ 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_ENV += \
+		CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
  endif
 
  HOST_PKG_CARGO_ENV = \

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

#5 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 7 lines · James Hilliard

Set HOST_LDFLAGS RUSTFLAGS via the host-config feature, see:
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config
We have to enable this nightly feature first using:
CARGO_UNSTABLE_HOST_CONFIG="true"
Separately set target RUSTFLAGS for the target triple specific env variable.

Quoted 1 line

Applied to master after a complete rewrite of the commit message, thanks.

Committed to 2023.02.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot