-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust: need a way to pass ldflags to rustc? #24375
Comments
Doesn't look right. Where is |
The build.rs for libbpf uses |
Because my OpenWrt build is NLS enabled (CONFIG_BUILD_NLS), libintl.so.8 is located in here :
The compilation is failing at einat not libbpf
These below are only workaround that i have tried in other to make rustc able to pickup libintl.so.8 but still not being picked up with rustc
|
you may try your luck using |
I did have tried using RUSTFLAGS but still not picked up with rustc, that's why it's weird. Based on here :
in dl/cargo/config.toml I have tried the following :
but still not picked up with rustc If you have time, you could try to reproduce this issue by enabling CONFIG_BUILD_NLS and glibc. |
@lu-zero I have tried to include the following to einat build.rs and "rpath = true" to einat's Cargo.toml :
But still rustc seems to ignore it |
The order should be the opposite, I think. Check what's the rustc final invocation passing -v to cargo |
Here is cargo very verbose log :
|
that I can see they are not present. |
That's why i said rustc seems ignoring everything that we are sets to cargo or Cargo.toml or config.toml or env variables. Please try it yourself, it's einat , and with CONFIG_BUILD_NLS enabled. It's also happening on musl & CONFIG_BUILD_NLS enabled. |
Hi, I am the author of https://github.com/EHfive/einat-ebpf. I think there is some misunderstanding going on here. So both einat and its build script link against As you can see, einat does not use The main problem here is both What need to addressed is why Another minor issue here is einat's build script is linking with target build of |
I guess part of the problem is that host and target are the same x86_64 to add additional confusion to the issue ... |
It seems like depend $(INTL_DEPENDS) is missing in Makefile. |
You mean in openwrt-einat-ebpf's Makefile? But einat does not link to cc @muink |
I tryied, still failed. |
Noticed that there is a commented # RUSTC_LDFLAGS+= -C link-args=$(INTL_LDFLAGS) line in @muink 's openwrt-einat-ebpf dev branch. However The following change should make openwrt-einat-ebpf built again with RUSTC_LDFLAGS+= $(foreach arg,$(INTL_LDFLAGS),-C link-arg=$(arg))
# or
RUSTC_LDFLAGS+= -C link-arg=-L$(INTL_PREFIX)/lib -C link-arg=-Wl,-rpath-link=$(INTL_PREFIX)/lib The following also works as rustc would pass proper link flags for libintl it found to linker(via
einat has build script depends on host libelf, and that build script would build target binary that depends on target libelf. @vortexilation build openwrt-einat-ebpf for This means the libintl searching error would also happens on compilation of build script if host triple and target triple are same. I guess passing the flags above can also make the build script built. However diff --git a/lang/rust/rust-values.mk b/lang/rust/rust-values.mk
index 534aaa0..aca2c24 100644
--- a/lang/rust/rust-values.mk
+++ b/lang/rust/rust-values.mk
@@ -97,7 +97,7 @@ CARGO_PKG_CONFIG_VARS= \
CARGO_PROFILE_RELEASE_PANIC=unwind \
CARGO_PROFILE_RELEASE_RPATH=false \
CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \
- RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
+ CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
TARGET_CC=$(TARGET_CC_NOCACHE) \
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" Though on execution the build script of einat would probably instead link to host libelf by edit: fix typo and reword |
muink/openwrt-einat-ebpf@master...dev |
@EHfive
Are you sure haven't forgot to re-enable "CONFIG_BUILD_NLS" ?. Haven't tried with musl but glibc still error on me. |
@vortexilation You didn't read my previous comment carefully, right? Especially the second section. And you are not even trying to read logs from yourself or changes in @muink 's commit. As if you read, you would know that error is for build script instead if einat target binary, and @muink 's commit only covers the first change mentioned in my comment that only fixes building for musl target.
Question yourself before question someone else next time. |
@EHfive
I have already previously tried adding CARGO_TARGET_x86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-args=-Wl,-rpath,$(STAGING_DIR)/usr/lib/libintl-full/lib" into rust-values.mk but it was seems getting no differences. Let me retry it now with your exact changes as snippet above. Recompiling rust now for OpenWrt. In Makefile, i just need to do the following ? :
[EDIT]
But still the same errror. |
Maintainer: @lu-zero @1715173329
Environment: x86_64, glibc
Description:
I wanted to compile einat , but somehow rustc cannot found libintl at the end.
I have tried everything
but rustc still didn't picked it up.
The text was updated successfully, but these errors were encountered: