Skip to content
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

.rlib file format not recognized when linking #210

Closed
keredson opened this issue May 20, 2024 · 3 comments
Closed

.rlib file format not recognized when linking #210

keredson opened this issue May 20, 2024 · 3 comments

Comments

@keredson
Copy link

keredson commented May 20, 2024

Bug description

Adding and using the library libssh-rs leads to the linker throwing .rlib: error adding symbols: file format not recognized.

  • Would you like to work on a fix? [y]

To Reproduce

Steps to reproduce the behavior:

  1. start a project:
$ cargo install espup
$ espup install
$ . $HOME/export-esp.sh
$ cargo generate esp-rs/esp-idf-template
⚠️   Favorite `esp-rs/esp-idf-template` not found in config, using it as a git repository: https://github.com/esp-rs/esp-idf-template.git
✔ 🤷   Which template should be expanded? · cargo
🤷   Project Name: test-linking
✔ 🤷   Which MCU to target? · esp32
✔ 🤷   Configure advanced template options? · false
✨   Done! New project created /tmp/test-linking
  1. add the dep:
$ cargo add libssh-rs
  1. enable cross compiling in .cargo/config.toml:
[env]
PKG_CONFIG_ALLOW_CROSS = "1"
  1. this will build!
$ cargo build
Compiling libssh-rs-sys v0.2.4
Compiling openssl-sys v0.9.102
Compiling libssh-rs v0.3.3
Finished dev [optimized + debuginfo] target(s) in 6.62s
  1. but try to use it by adding the following to src/main.rs
use libssh_rs::{Session};
let mut session = Session::new().unwrap();

(obviously the second line goes in the main function)
6. and you get:

= note: [ldproxy] Running ldproxy
Error: Linker /tmp/test-linking/.embuild/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc failed: exit status: 1
STDERR OUTPUT:
/tmp/test-linking/.embuild/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/test-linking/target/xtensa-esp32-espidf/debug/deps/liblibssh_rs_sys-ba33b208cf49f79d.rlib: error adding symbols: file format not recognized

Expected behavior

No linking error.

Environment

  • OS: Ubuntu 24.04
  • How did you install the environment: recent espup

Additional context

Same in esp-idf v4 and v5 (enabled in advanced template options).

@keredson
Copy link
Author

$ objdump -d /tmp/test-linking-idfv4/target/xtensa-esp32-espidf/debug/deps/liblibssh_rs_sys-ba33b208cf49f79d.rlib looks OK, but admittedly i'm out of my depth here.

@keredson
Copy link
Author

actually the start of objdump contains:

In archive /tmp/test-linking-idfv4/target/xtensa-esp32-espidf/debug/deps/liblibssh_rs_sys-ba33b208cf49f79d.rlib:
lib.rmeta:     file format elf32-little
libssh_rs_sys-ba33b208cf49f79d.libssh_rs_sys.f63cc42efaec27b7-cgu.0.rcgu.o:     file format elf32-little
1fa44eb5313ef680-agent.o:     file format elf64-x86-64

it prob. shouldn't contain elf64-x86-64 objects? no clue if this i related, but thought i'd note.

@ivmarkov
Copy link
Collaborator

actually the start of objdump contains:

In archive /tmp/test-linking-idfv4/target/xtensa-esp32-espidf/debug/deps/liblibssh_rs_sys-ba33b208cf49f79d.rlib:
lib.rmeta:     file format elf32-little
libssh_rs_sys-ba33b208cf49f79d.libssh_rs_sys.f63cc42efaec27b7-cgu.0.rcgu.o:     file format elf32-little
1fa44eb5313ef680-agent.o:     file format elf64-x86-64

it prob. shouldn't contain elf64-x86-64 objects? no clue if this i related, but thought i'd note.

Of course it is. The lib likely has some x86 assembly hard-coded. Not sure all of this is a problem with the esp idf crates.

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants