Git Product home page Git Product logo

Comments (13)

jonas-schievink avatar jonas-schievink commented on May 23, 2024 1

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.

berkus avatar berkus commented on May 23, 2024 1

Ahha, now I see the comma vs period, my bad!

from cortex-m-rt.

berkus avatar berkus commented on May 23, 2024 1

@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.

japaric avatar japaric commented on May 23, 2024

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.

fmckeogh avatar fmckeogh commented on May 23, 2024

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.

japaric avatar japaric commented on May 23, 2024

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.

therealprof avatar therealprof commented on May 23, 2024

Indeed, I've encountered it frequently.

from cortex-m-rt.

berkus avatar berkus commented on May 23, 2024

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.

therealprof avatar therealprof commented on May 23, 2024

@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.

berkus avatar berkus commented on May 23, 2024

@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.

berkus avatar berkus commented on May 23, 2024

@therealprof btw, could it be using the comma on all systems, not only macos?

from cortex-m-rt.

therealprof avatar therealprof commented on May 23, 2024

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.

adamgreig avatar adamgreig commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.