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

Cargo.toml: Add links = "cortex-m" #140

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Cargo.toml: Add links = "cortex-m" #140

merged 1 commit into from
Jun 6, 2019

Conversation

jonas-schievink
Copy link
Contributor

@jonas-schievink jonas-schievink commented Apr 24, 2019

This prevents linking multiple versions of cortex-m together, which would be
unsound. Currently it uses a #[no_mangle] static for this, which isn't always
reliable.

Fixes #137

@jonas-schievink jonas-schievink requested a review from a team as a code owner April 24, 2019 13:08
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @korken89 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Apr 24, 2019
@jonas-schievink
Copy link
Contributor Author

Since this will only work for other cortex-m versions also using links, I kept the #[no_mangle] solution in place for now (it's better than nothing)

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

SGTM

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Apr 24, 2019
140: Cargo.toml: Add `links = "cortex-m"` r=therealprof a=jonas-schievink

This prevents linking multiple versions of `cortex-m` together, which would be
unsound. Currently it uses a `#[no_mangle]` static for this, which isn't always
reliable.

Fixes #137

Co-authored-by: Jonas Schievink <[email protected]>
@bors
Copy link
Contributor

bors bot commented Apr 24, 2019

Build failed

@jonas-schievink
Copy link
Contributor Author

This might be rust-lang/rust#60050?

@jonas-schievink
Copy link
Contributor Author

@therealprof can you give this another go? The CI failure should've gone away.

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Jun 6, 2019
140: Cargo.toml: Add `links = "cortex-m"` r=therealprof a=jonas-schievink

This prevents linking multiple versions of `cortex-m` together, which would be
unsound. Currently it uses a `#[no_mangle]` static for this, which isn't always
reliable.

Fixes #137

Co-authored-by: Jonas Schievink <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 6, 2019

Build succeeded

@bors bors bot merged commit fa185a6 into rust-embedded:master Jun 6, 2019
@jonas-schievink jonas-schievink deleted the links branch June 6, 2019 09:08
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
140: entry/exception/interrupt: improvements to the `static mut` transformation r=therealprof a=japaric

see individual commits for details

Co-authored-by: Jorge Aparicio <[email protected]>
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
after #140 landed the entry, exception and interrupt attributes started
accepting code like this:

``` rust
 #[entry]
fn main() -> ! {
    static mut FOO: u32 = 0;
    static mut FOO: i32 = 0;
}
```

because that code expands into:

``` rust
fn main() -> ! {
    let FOO: &'static mut u32 = unsafe {
        static mut FOO: u32 = 0;
        &mut FOO
    };
    // shadows previous variable
    let FOO: &'static mut u32 = unsafe {
        static mut FOO: i32 = 0;
        &mut FOO
    };
}
```

this commit adds a check that rejects `static mut`s with duplicated names to
these three attributes.
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
149: reject duplicate `static mut` variables r=therealprof a=japaric

after #140 landed the entry, exception and interrupt attributes started
accepting code like this:

``` rust
 #[entry]
fn main() -> ! {
    static mut FOO: u32 = 0;
    static mut FOO: i32 = 0;
}
```

because that code expands into:

``` rust
fn main() -> ! {
    let FOO: &'static mut u32 = unsafe {
        static mut FOO: u32 = 0;
        &mut FOO
    };
    // shadows previous variable
    let FOO: &'static mut u32 = unsafe {
        static mut FOO: i32 = 0;
        &mut FOO
    };
}
```

this commit adds a check that rejects `static mut`s with duplicated names to
these three attributes.

Co-authored-by: Jorge Aparicio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using Cargo's links feature to ensure use only once
4 participants