Comments (14)
From the RIOT side, my setup works now. Thank you @chrysn and @maribu for helping me out.
Excellent support right here, thank you for all of your contributions to RIOT.
For anyone reading this issue in the future:
Problem
RIOT examples of rust programs (rust-hello-world, rust-gcoap) fail to build because of link-time error in c2rust on Arch Linux.
Solution
Use the BUILD_IN_DOCKER=1 TOOLCHAIN=llvm environment variables when compiling the program
If compilation fails because of an incompatible version of rustc, pull the latest docker image required for the build process:
docker pull riot/riotbuild
. If after that you get some weird issues with eh_personality
, read this issue rust-lang/rust#106864 and try solutions suggested there. The thing that worked for me was adding a dummy implementation of that missing function to my main lib.rs file:
#[no_mangle]
extern "C" fn rust_eh_personality() {}
from riot.
Haven't seen this yet; AFAIK @maribu is the RIOT developer who has the most experience with distros that use musl libc.
It may also be that this is an issue with the include paths and how they are adjusted between GCC and LLVM.
Please try both these:
- Build with BUILD_IN_DOCKER=1
- Build with TOOLCHAIN=llvm
from riot.
I have already tried setting TOOLCHAIN=llvm, however this hasn't changed anything.
To give you some additional context, in order to get c2rust to even compile during installing, I had to explicitly set
LLVM_TOOLCHAIN_DIR=/usr/lib
And then compile c2rust using the version from the git repo.
It seems like the multilib setup on arch isn't ideal, or there is some problem with my configuration.
I don't have access to my main machine right now, once I have it, I will test the build in docker option
As for my setup, I'm pretty sure I have all versions of clang and llvm from 14 to 17 installed. Not sure why the compilation process isn't able to find any of them.
from riot.
AFAIK @maribu is the RIOT developer who has the most experience with distros that use musl libc.
Likely true, but Arch is using glibc.
Sounds more like the bug you fixed some time ago with the order of items in compile_commands.json being assumed to be in a particular order.
from riot.
Speaking of compile_commands.json, it could have something to do with this.
I had some issues with riot-wrappers and riot-sys after syncing to the latest version of RIOT master.
It kept complaining that I need to set RIOT_USEMODULE, even though the build.rs of the latest riot sys should not fail at that point.
In order to fix that issue, I had to add the RIOT_USEMODULE line back to this file:
9a59d59
from riot.
I will look into the above once I'm back and figure out if it is causing the issue.
Although I did clone a fresh RIOT repo as well and just compiled the rust-hello-word example there and it failed with the
same exception.
from riot.
Ok so I have tried running with BUILD_IN_DOCKER=1 however there seems to be an issue with the latest version of riot-wrappers requiring a newer version of rustc (1.75) than the one present in the docker image. Do you know how to deal with this issue?
from riot.
from riot.
Thank you for suggesting this, I did that, however it didn't seem to affect the actual image used for docker build:
Launching build container using image "docker.io/riot/riotbuild:latest".
I have pulled this image as 'riotdocker' wasn't found: docker pull kaspar030/riotdocker
. Is this the right one? I assume I would have to override it in the config somewhere. I looked through the RIOT build in docker docs, however there doesn't seem to be an easy way to change the image.
I will also try this one docker pull riot/riotdocker-base
Or I think this is the one that's executing the build: docker pull riot/riotbuild
from riot.
Ok, pulling the last image did the trick. Now I was able to compile the rust-hello-word example and it did execute correctly.
Thanks a lot for your help.
I tried using the same setup for my main project, but got the issue where the rust doesn't have the proper toolchain installed:
i686-unknown-linux-gnu
It is interesting that this one is targeted as I have that one installed locally. I assume it isn't present in docker. I will investigate that.
Edit: Ok so it turns out that I had a toolchain override present in the directory which was messing things up. Now it seems like the toolchain is set up correctly. The problem I'm having now is that one of the packages that my project depends on lives outside of the RIOT tree and the build in docker has some trouble copying it over:
make[1]: Nothing to be done for 'prepare'.
rm -Rf /data/riotbuild/riotbase/build/pkg/femto-container
mkdir -p $(dirname /data/riotbuild/riotbase/build/pkg/femto-container)
cp -a /data/riotbuild/riotbase/../femto-containers /data/riotbuild/riotbase/build/pkg/femto-container
cp: cannot stat '/data/riotbuild/riotbase/../femto-containers': No such file or directory
Does build in docker support out-of-tree packages?
from riot.
BUILD_IN_DOCKER=1
uses docker.io/riot/riotbuild
to build. So you should go for
docker pull docker.io/riot/riotbuild
to update.
You can use a different container via DOCKER_IMAGE=<img_name>
(if I recall the name correctly), but I think @chrysn was not suggesting to do that but just recalled the docker image name incorrectly.
from riot.
Sorry, still didn't have time to look into this in full, just dumping anything I have on short notes:
think chrysn was not suggesting to do that but just recalled the docker image name incorrectly.
Indeed; I just sent the remark from mobile without looking up the details.
It kept complaining that I need to set RIOT_USEMODULE, even though the build.rs of the latest riot sys should not fail at that point.
That should be fixed already because the latest riot-sys has been uploaded to crates.io. RIOT uses riot-sys/-wrappers with a patch.crates-io to go directly to git. Tracked in #20452 for not letting this happen again.
from riot.
Thank you @chrysn for opening the other issue, I will look into this and provide additional context where applicable.
As for the current state of my build-in-docker. I did manage to pull the correct image and get the rust-hello-world and rust-gcoap examples to compile. Thanks a lot for helping me fix this issue. My project still doesn't work, but I think the issue lies somewhere deeper (either in the rust toolchain for i686 or c2rust) you can see the issue below but it's probably unrelated to the original problem:
/usr/bin/ld: /data/riotbuild/riotproject/mibpf-server/bin/native/mibpf_server/mibpf_server-fcf3a3ec338093ea.mibpf_server.9ede0b52c9482aa-cgu.0.rcgu.o:(.data.DW.ref.rust_eh_personality[DW.ref.rust_eh_personality]+0x0): undefined reference to `rust_eh_personality'
collect2: error: ld returned 1 exit status
I just attached it here in case you have seen it before.
Does this look familiar?
I did some digging and found that this missing eh_personality problem shouldn't be there if Cargo.toml specifies in profile.release panic="abort"
A possible workaround that I found online was to define this function manually like so:
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
The problem is that it requires nightly rust to allow for using language features. Do you know how I can override the toolchain used by the build-in-docker process? I tried using a custom toolchain.toml file, however it then complains that it doesn't have the target installed:
rustup target add i686-unknown-linux-gnu
Is there a way of adding new targets to the rust toolchain that is present in the docker image?
Edit:
In case anyone encounters a similar error, I have followed this issue thread: rust-lang/rust#106864
and managed to fix my problem by adding a dummy implementation of the missing function:
#[no_mangle]
extern "C" fn rust_eh_personality() {}
The thing is that I'm not sure why this errors as after some reading I found that if you use panic="abort" then the rust_eh_personality should never be called.
from riot.
Hello,
I would also like to report that I'm having the same problem with C2Rust failing when trying to build the rust examples on my Arch Linux (just that I don't use LLVM like OP). Worked around with BUILD_IN_DOCKER=1 but the underlying issue on Arch still remains. 🙏
from riot.
Related Issues (20)
- add board for Flipper Zero
- Make Kconfig data visible in documentation HOT 1
- Rust sys/wrapper version out-of-tree users get can fall behind
- Microchip vendor files migration process HOT 8
- examples/psa_crypto: key_bits usage doesn't match specification
- usbus/dfu: cannot detach device to reboot into bootloader HOT 1
- core/lib: print_stack_usage_metric called with misaligned stack
- drivers/at86rf215: The activation of the address match interrupt is missing in the at86rf215_reset function
- stdio_rtt is loosing output
- doxygen: @ingroup does not support braces HOT 23
- Standard output is truncated and sent to the shell input on Arduino Nano 33 BLE for the default example HOT 3
- boards/nRF: Make documentation more consistent and updated HOT 1
- BlackMagicProbe does not recognize nRF52 device HOT 2
- cpu/msp430: USCI not working with auxiliary clock HOT 1
- High-level stdio is not beginner friendly when they use asserts HOT 2
- Bug: BUILD_IN_DOCKER in Makefile on WSL not working as intended / breaking the build
- mcp2515: can driver incomplete ID flag handling
- test files required to compile HOT 1
- gcoap_fileserver: can't deal with 16 byte block size HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riot.