Skip to contentSkip to conversation

package/cargo: pass appropriate library path to the linker

PATCH New Thomas Petazzoni 2 participants 3 messages Dec 28, 2018 – Jan 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/cargo: pass appropriate library path to the linker

When linking the host cargo binary, the linker should be told to find libraries in $(HOST_DIR)/lib, otherwise it will not work libraries such as libhttp_parser. This was found with per-package directory support, where the build failed with:

= note: /usr/bin/ld: cannot find -lhttp_parser
collect2: error: ld returned 1 exit status

In order to fix this, instead of passing -L$(HOST_DIR)/lib during the build of Cargo, we make sure all flags in $(HOST_LDFLAGS) are passed.

---
 package/cargo/cargo.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/cargo/cargo.mk +1 -1
index 1b1053ba41..a387281b4c 100644
@@ -70,7 +70,7 @@ HOST_CARGO_SNAP_OPTS = \
 	$(if $(VERBOSE),--verbose)
 
 HOST_CARGO_ENV = \
-	RUSTFLAGS="-Clink-arg=-Wl,-rpath,$(HOST_DIR)/lib" \
+	RUSTFLAGS="$(addprefix -Clink-arg=,$(HOST_LDFLAGS))" \
 	CARGO_HOME=$(HOST_CARGO_HOME)
 
 define HOST_CARGO_BUILD_CMDS
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/cargo: pass appropriate library path to the linker

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

When linking the host cargo binary, the linker should be told to find libraries in $(HOST_DIR)/lib, otherwise it will not work libraries

s/work/find/

Quoted 19 lines

such as libhttp_parser. This was found with per-package directory support, where the build failed with:

= note: /usr/bin/ld: cannot find -lhttp_parser
collect2: error: ld returned 1 exit status

In order to fix this, instead of passing -L$(HOST_DIR)/lib during the build of Cargo, we make sure all flags in $(HOST_LDFLAGS) are passed.

---
 package/cargo/cargo.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/cargo/cargo.mk +0 -0
index 1b1053ba41..a387281b4c 100644

package/cargo/cargo.mk HOST_CARGO_SNAP_OPTS = \ · line 73

Quoted 5 lines
package/cargo/cargo.mk +1 -1
@@ -70,7 +70,7 @@ HOST_CARGO_SNAP_OPTS = \
 	$(if $(VERBOSE),--verbose)
 
 HOST_CARGO_ENV = \
-	RUSTFLAGS="-Clink-arg=-Wl,-rpath,$(HOST_DIR)/lib" \
+	RUSTFLAGS="$(addprefix -Clink-arg=,$(HOST_LDFLAGS))" \

The -Clink-arg= thing looked odd to me, but is apparently how linker flags are passed:

https://github.com/rust-lang/rust/pull/36574

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 package/cargo: pass appropriate library path to the linker

In reply to Thomas Petazzoni
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

When linking the host cargo binary, the linker should be told to find libraries in $(HOST_DIR)/lib, otherwise it will not work libraries such as libhttp_parser. This was found with per-package directory support, where the build failed with:

Quoted 7 lines

= note: /usr/bin/ld: cannot find -lhttp_parser
collect2: error: ld returned 1 exit status

In order to fix this, instead of passing -L$(HOST_DIR)/lib during the build of Cargo, we make sure all flags in $(HOST_LDFLAGS) are passed.

Committed to 2018.02.x and 2018.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard