public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] rust-common: add LDFLAGS to 'build-rust-cc' wrapper
@ 2025-01-20 16:45 Enrico Scholz
  2025-01-21 13:19 ` [OE-core] " Mathieu Dubois-Briand
  0 siblings, 1 reply; 4+ messages in thread
From: Enrico Scholz @ 2025-01-20 16:45 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

From: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>

Although rust differs between compiling (--> 'rust-cc' wrapper) and
linking (--> 'rust-ccld' wrapper), some core crates are using only the
'rust-cc' wrapper to check for available compiler options [1] and
libraries [2].

Not having LDFLAGS can break the build in subtle ways.  E.g. 'cargo-native'
can fail to build with

|   = note: .../hosttools/ld: .../liblibz_sys-....rlib(deflate.o):
|     relocation R_X86_64_32S against hidden symbol `_length_code' can not be used when making a PIE object

because it does not find '-lz' (added by "DEPENDS = zlib") and builds
a static libz.a with missing PIC flags.

Add LDFLAGS to the 'build-rust-cc' wrapper as it is done already for
the target one.

[1] https://github.com/rust-lang/cc-rs/pull/1322

[2] https://github.com/rust-lang/libz-sys/blob/12a32798c6bd18986cb5cd603359b03c96f0eb4c/build.rs#L228-L234

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 meta/classes-recipe/rust-common.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes-recipe/rust-common.bbclass b/meta/classes-recipe/rust-common.bbclass
index 6940093e59bf..baa3869c478f 100644
--- a/meta/classes-recipe/rust-common.bbclass
+++ b/meta/classes-recipe/rust-common.bbclass
@@ -173,7 +173,7 @@ do_rust_create_wrappers () {
 	mkdir -p "${WRAPPER_DIR}"
 
 	# Yocto Build / Rust Host C compiler
-	create_wrapper_rust "${RUST_BUILD_CC}" "" "${CRATE_CC_FLAGS}" "${BUILD_CC}"
+	create_wrapper_rust "${RUST_BUILD_CC}" "" "${CRATE_CC_FLAGS}" "${BUILD_CC}" "${BUILD_LDFLAGS}"
 	# Yocto Build / Rust Host C++ compiler
 	create_wrapper_rust "${RUST_BUILD_CXX}" "" "${CRATE_CC_FLAGS}" "${BUILD_CXX}"
 	# Yocto Build / Rust Host linker
-- 
2.48.1



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

end of thread, other threads:[~2025-01-23  7:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 16:45 [PATCH] rust-common: add LDFLAGS to 'build-rust-cc' wrapper Enrico Scholz
2025-01-21 13:19 ` [OE-core] " Mathieu Dubois-Briand
2025-01-21 15:58   ` Mathieu Dubois-Briand
2025-01-23  7:30     ` Mathieu Dubois-Briand

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