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

Solve the issue of not being able to override existing builtin functions under LTO. #728

Closed
wants to merge 4 commits into from
Closed

Conversation

DianQK
Copy link

@DianQK DianQK commented Dec 17, 2023

Solve the rp-rs/rp2040-project-template#71 issue of not recognizing builtin functions under LTO.
Also set the builtin functions in compiler_builtins to weak.

@@ -37,6 +37,7 @@

#![warn(missing_docs)]
#![no_std]
#![feature(naked_functions)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is my understanding correct that this is not stable yet ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's only on nightly. Are we going to use it on stable too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library targets stable rust, yes. So nightly features can't be used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that even stabilizing naked is not enough. Using compiler_builtins requires nightly.
But we can change it to default weak in rust. I think the key here is still to stabilize the naked first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please help me verify that the current modification works?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, what can I do?
Currently, it doesn't build. Obviously not with stable, but I also get errors with nightly:

$ cargo +nightly build --release
[...]
   Compiling rp2040-hal v0.9.1 (/home/jan/rp2040/rp-rs/rp-hal/rp2040-hal)
error: invalid instruction
   --> rp2040-hal/src/sio.rs:299:22
    |
299 |                     "hwdivider_head",
    |                      ^
    |
note: instantiated into assembly here
   --> <inline asm>:1:2
    |
1   |     hwdivider_head
    |     ^
[...]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this error yet. But I was able to compile it successfully at https://github.com/rp-rs/rp2040-project-template. I also need add compiler_builtins = { version = "0.1.104", features = ["weak-intrinsics"] } to the rp2040-project-template.

@DianQK
Copy link
Author

DianQK commented Dec 28, 2023

I believe there are ways to not use naked here.

@DianQK DianQK closed this Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants