Skip to content

Questions about linking/examples #8

@ratmice

Description

@ratmice

I'm pretty new and ignorant of rust embedded development...

I was curious if there were any projects/example using it, I had seen the one in trouble But wasn't able to get it to compile due to what seemed like a circular dependency on embassy-time-driver perhaps caused by both apache-nimble crate and the trouble example depending on embassy-time? It wasn't clear to me what the issue was, it seemed to complain about two instances of the same version.

Trying to just take a minimal skeleton of an empty entry point I got a little bit further...

The first issue I had when linking, was duplicate symbols between libc and the libapache_nimble_sys.rlib file:
(snipped)

rust-lld: error: duplicate symbol: strlen
rust-lld: error: duplicate symbol: __assert_func

It's probably a bad idea but I was able to hack my way past that by telling the linker to allow multiple definitions of symbols :)

rustflags = [
    "-C", "link-arg=-Tlink.x",
    "-C", "link-arg=-Tdefmt.x",
    "-C", "link-arg=--allow-multiple-definition",
]

After that I ran into undefined references to all these functions that are commented out in embassy.rs:
port-layers/embassy.rs

Reading the comment there, I wasn't exactly sure what to look for in build.rs but related to the first error I saw, I noticed this comment:
which references: __assert_func which was one of the multiply defined functions I encountered earlier.

apache-nimble/build.rs

Anyhow, adding uncommented versions of those to my source files, It did finally link properly -- the following doesn't try and get anything actually functioning, but did get so far as to get it compiling linking. https://github.com/ratmice/apache_nimble_test/

I'm curious if these hacks are needed on others systems, or perhaps if there is some crate or step that I've missed. The version of newlib in my sysroot appears to be arm-none-eabi-newlib-4.4.0 if that helps.

Anyhow apologies for the wall of text, hopefully that covers everything I encountered/tried.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions