Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Only emit link_section for cortex-m #310

Merged
merged 1 commit into from
Jan 27, 2021
Merged

Only emit link_section for cortex-m #310

merged 1 commit into from
Jan 27, 2021

Conversation

adamgreig
Copy link
Member

Previously we always emitted link_section, even though it only had an
effect when our linker script was being used (and only made sense on
cortex-m targets). This breaks building the code for a MacOS target,
which is occasionally useful for running cargo check etc.

In the macros crate we don't have the target information available, so
instead we continue to emit link_section except specifically on MacOS.

This keeps the fix from #306 but hopefully resolves the confusion in #74 (comment).

@adamgreig adamgreig requested a review from a team as a code owner January 27, 2021 11:36
@rust-highfive
Copy link

r? @therealprof

(rust-highfive has picked a reviewer for you, use r? to override)

@therealprof
Copy link
Contributor

Just curious, why do we need these sections at all then on a real OS? Can't we just generally omit them if we have a target_os defined?

@adamgreig
Copy link
Member Author

We don't need to emit any link sections on non-cortex-m platforms, which is what this PR does except for the macro crate. Do you have a better cfg match in mind for the macro crate? I'd just left it as not(target_os="macos") but if you have a better idea I'm all for it.

@therealprof
Copy link
Contributor

Ah, I was just looking at the macro part of the diff.

Would target_os="" work?

@jonas-schievink
Copy link
Contributor

cfg(target_os = "none") should work

Previously we always emitted link_section, even though it only had an
effect when our linker script was being used (and only made sense on
cortex-m targets). This breaks building the code for a MacOS target,
which is occasionally useful for running `cargo check` etc.

In the macros crate we don't have the target information available, so
instead we continue to emit link_section except specifically on MacOS.
@adamgreig
Copy link
Member Author

Yep, that seems to be working in my quick test (still places HardFault immediately after HardFaultTrampoline, while using target_os=dummy places it beforehand in with the other functions). Updated.

Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 27, 2021

@bors bors bot merged commit 6f719b6 into master Jan 27, 2021
@bors bors bot deleted the macos-link branch January 27, 2021 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants