653: Allow custom `link_section` attributes for late resources r=AfoHT a=vccggorski

This commit makes RTIC aware of user-provided `link_section` attributes,
letting user override default section mapping.

Co-authored-by: Gabriel Górski <gabriel.gorski@volvocars.com>
This commit is contained in:
bors[bot] 2022-07-27 18:36:56 +00:00 committed by GitHub
commit d4816e054b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -9,6 +9,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Added ### Added
- Allow custom `link_section` attributes for late resources
### Fixed ### Fixed
### Changed ### Changed

View file

@ -27,8 +27,14 @@ pub fn codegen(
let mangled_name = util::static_local_resource_ident(name); let mangled_name = util::static_local_resource_ident(name);
let attrs = &res.attrs; let attrs = &res.attrs;
// late resources in `util::link_section_uninit` // late resources in `util::link_section_uninit`
let section = util::link_section_uninit(); // unless user specifies custom link section
let section = if attrs.iter().any(|attr| attr.path.is_ident("link_section")) {
None
} else {
Some(util::link_section_uninit())
};
// For future use // For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!()); // let doc = format!(" RTIC internal: {}:{}", file!(), line!());

View file

@ -23,10 +23,16 @@ pub fn codegen(
let ty = &res.ty; let ty = &res.ty;
let mangled_name = &util::static_shared_resource_ident(name); let mangled_name = &util::static_shared_resource_ident(name);
// late resources in `util::link_section_uninit`
let section = util::link_section_uninit();
let attrs = &res.attrs; let attrs = &res.attrs;
// late resources in `util::link_section_uninit`
// unless user specifies custom link section
let section = if attrs.iter().any(|attr| attr.path.is_ident("link_section")) {
None
} else {
Some(util::link_section_uninit())
};
// For future use // For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!()); // let doc = format!(" RTIC internal: {}:{}", file!(), line!());
mod_app.push(quote!( mod_app.push(quote!(