Comments (13)
The cortex-m crate goes out of its way to build at least on Linux, would be nice if all the core crates consistently built on Linux, macOS, and Windows
from cortex-m-rt.
Ahha, now I see the comma vs period, my bad!
from cortex-m-rt.
@therealprof on mac this is two names, ".vector_table" for the segment and "reset_vector" for the section name.
I will test on linux if a section name with comma works, the ELF file format spec says why not so the only limiting factor would be linker's parser.
from cortex-m-rt.
mach-o section specifier requires a segment whose length is between 1 and 16 characters
Are you compiling the cortex-m-rt
crate for the host (for mac)?
If that's the case we can drop the link_section when compiling for mac; trying to link a cortex-m program compiled for the host (mac / Linux) is going to fail anyway.
from cortex-m-rt.
I'm so sorry for wasting your time, I'm the biggest idiot. I forgot to set the default target in .cargo/config
.
from cortex-m-rt.
we ran into a similar issue in the defmt
project.
we found out that on macOS the longest linker section name can be .section,0123456789ABCDEF
(note: comma after .section
not period and a max of 16 characters after the comma)
this issue can probably be fixed by adding a cfg_attr(is_macos, link_section = "..")
to the relevant static variables
from cortex-m-rt.
Indeed, I've encountered it frequently.
from cortex-m-rt.
What does this fix do? It replaces section name with exactly the same but taking half a kilobyte more space in source code; am I missing something there?
from cortex-m-rt.
@berkus Not sure what you mean. What are you seeing and on which system? This is changing the section names for macOS only because it has a weird length restriction. It should not affect anything except to prevent linker errors on macOS.
from cortex-m-rt.
@therealprof ok, lets go with the way of example, shall we.
#[cfg_attr(target_os = "macos", link_section = ".vector_table,interrupts")]
#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.interrupts")]
On macOS the section name would be .vector_table.interrupts
, however on any other system it would be .vector_table.interrupts
which is EXACTLY THE SAME.
So now you've reduced readability, understandability and maintainability of the code to provide exactly the same section names for every system out there.
What am I missing? I could have missed something, to be precise am looking at this commit.
Here it is, condensed:
#[cfg_attr(target_os = "macos", link_section = ".HardFault,user")]
#[cfg_attr(not(target_os = "macos"), link_section = ".HardFault.user")] // NB: same name
#[cfg_attr(target_os = "macos", link_section = ".vector_table,reset_vector")]
#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.reset_vector")] // NB: same name
#[cfg_attr(target_os = "macos", link_section = ".HardFault,default")]
#[cfg_attr(not(target_os = "macos"), link_section = ".HardFault.default")] // NB: same name
#[cfg_attr(target_os = "macos", link_section = ".vector_table,exceptions")]
#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.exceptions")] // NB: same name
#[cfg_attr(target_os = "macos", link_section = ".vector_table,interrupts")]
#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.interrupts")] // NB: same name
from cortex-m-rt.
@therealprof btw, could it be using the comma on all systems, not only macos?
from cortex-m-rt.
Not sure sorry, I'm actually curious why this is supposed to work on macOS (NB: I haven't actually tested it myself). Maybe some internal linker magic to substitute the "." back?
from cortex-m-rt.
We could probably just remove the link_section
attribute entirely on MacOS, right? It's not going to actually do anything as I understand it, since we can't build final libraries or executables targeting MacOS with cortex-m-rt and it doesn't use our linker script (where the names matter) on MacOS either; this change just lets people on MacOS run cargo check/test without a target specified. I wouldn't want to swap the ARM builds or linker script to using commas for section names just so that Macs can check the code when compiling natively, though.
from cortex-m-rt.
Related Issues (20)
- How to link exceptions to C handlers HOT 2
- "error: cortex-m-rt appears more than once in the dependency graph" HOT 9
- main() calling convention discrepancy HOT 1
- How to utilize CCM SRAM for uninit statics? HOT 4
- VTOR and initial stack for debuggers HOT 5
- undefined reference to `__sheap' HOT 10
- Forward-port Changelog entries for v0.6.x
- RAM initialization code violates pointer provenance HOT 4
- Per crate memory.x file in a workspace. HOT 2
- [feature request] possibility to include asm stub before __pre_init for MCU that starts with RAM disabled HOT 5
- SCB.ICSR is more than 8 bits HOT 1
- Different virtual and physical address for FLAH HOT 1
- Error compiling with rwpi relocation model. HOT 2
- Position Independent Code HOT 2
- Why the code in this repo isn't the same as in crate.io even if the version number is the same? HOT 1
- master branch is out of date relative to 0.6.14 release HOT 2
- Use the semver trick? HOT 3
- Multiple versions of cortex-m-rt result in cryptic error messages HOT 4
- How to prevent generation of 'extra' code for ISR HOT 2
- Using the hard float compiler `thumbv7em-none-eabihf` problematic HOT 29
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 cortex-m-rt.