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

Adds support for the Newlib-Nano Standard Library #179

Merged
merged 2 commits into from
Jan 31, 2021

Conversation

Danaozhong
Copy link
Contributor

  • For MCUs with very little flash, the Nano standard library is more suitable.
  • This change supports building with the GCC nano stdlib, simply by
    linking STM32::Nano library in cmake.

- For MCUs with very little flash, the Nano library is more suitable.
- This change supports building with the GCC nano stdlib, simply by
  linking STM32::Nano library in cmake.
@Hish15
Copy link
Collaborator

Hish15 commented Dec 28, 2020

Great contribution, can you add this modification to the Readme.md file too?

An undocumented feature is no feature at all 😄

@Hish15
Copy link
Collaborator

Hish15 commented Dec 28, 2020

There must be a way to check that we are not trying to link both STM32::NoSys STM32::Nano, since those does not make sense together.
I'm looking it up.
Edit : Found it!
with the changes I made, an error is raised if one tries to link both nosys and nano.

CMake Error: The INTERFACE_CUSTOM_GCC_SPECS property of "STM32::NoSys" does
not agree with the value of CUSTOM_GCC_SPECS already determined
for "stm32-blinky-f4.elf"

Comment on lines 233 to 238
if(NOT (TARGET STM32::Nano))
add_library(STM32::Nano INTERFACE IMPORTED)
target_compile_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
target_link_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
endif()

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if(NOT (TARGET STM32::Nano))
add_library(STM32::Nano INTERFACE IMPORTED)
target_compile_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
target_link_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
endif()
if(NOT (TARGET STM32::Nano))
add_library(STM32::Nano INTERFACE IMPORTED)
target_compile_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
target_link_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
#This custom property is used to check that specs is not set yet on a target linking to this one
set_property(TARGET STM32::Nano PROPERTY INTERFACE_CUSTOM_GCC_SPECS "NANO")
set_property(TARGET STM32::Nano APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING CUSTOM_GCC_SPECS)
endif()

@Hish15
Copy link
Collaborator

Hish15 commented Dec 29, 2020

You must change the way NoSys is handle as well.

if(NOT (TARGET STM32::NoSys))
    add_library(STM32::NoSys INTERFACE IMPORTED)
    target_compile_options(STM32::NoSys INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nosys.specs>)
    target_link_options(STM32::NoSys INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nosys.specs>)
    #This custom property is used to check that specs is not set yet on a target linking to this one
    set_property(TARGET STM32::NoSys PROPERTY INTERFACE_CUSTOM_GCC_SPECS "NOSYS")
    set_property(TARGET STM32::NoSys APPEND PROPERTY
        COMPATIBLE_INTERFACE_STRING CUSTOM_GCC_SPECS)
endif()

- Readme file is updated to provide more details on the NoSys and Nano
  libraries.
- A check was added to avoid linking both STM32::NoSys and STM32::Nano
  libraries.
@Danaozhong
Copy link
Contributor Author

@Hish15 Thank you. I updated the branch according to your suggestions.

Copy link
Collaborator

@Hish15 Hish15 left a comment

Choose a reason for hiding this comment

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

All good to me 😄

@ObKo ObKo merged commit e6be9f0 into ObKo:master Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants