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

Set macro NDEBUG for release builds #347

Closed
betzw opened this issue Sep 15, 2016 · 13 comments
Closed

Set macro NDEBUG for release builds #347

betzw opened this issue Sep 15, 2016 · 13 comments

Comments

@betzw
Copy link
Contributor

betzw commented Sep 15, 2016

It seems as if the macro NDEBUG gets never set even if doing a release build.
Or is this intentionally left to be specified on the command line with -DNDEBUG?

@screamerbg
Copy link
Contributor

@betzw Is this still relevant? I think this was fixed in the mbed OS build tools.

@betzw
Copy link
Contributor Author

betzw commented Oct 6, 2016

After merging the latest version of the master branch I still do not see an automatic definition of macro NDEBUG.
Furthermore, the usage of flag -o seems now not working anymore 👎

@bridadan
Copy link
Contributor

bridadan commented Oct 6, 2016

@betzw The -o flag has been replaced with the more general --profile flag, you should be able to use that and it offers greater flexibility

@betzw
Copy link
Contributor Author

betzw commented Oct 7, 2016

Maybe you should reflect this in the documentation including the help message which gets printed by mbed compile -h.
What about macro NDEBUG? Is there a profile which defines it?

@bridadan
Copy link
Contributor

bridadan commented Oct 7, 2016

Thanks @betzw, I submitted a PR here for just that: #365

I'm not as familiar with the NDEBUG option, so sorry I can't comment on it. Build profiles don't actually specify macros, just compiler flags. You should be able to set the NDEBUG macro through the config system.

@pan-
Copy link
Member

pan- commented Oct 7, 2016

@bridadan

Build profiles don't actually specify macros, just compiler flags.

So then it should be possible to add -D NDEBUG I guess.

@bridadan
Copy link
Contributor

bridadan commented Oct 7, 2016

Yup, -D NDEBUG should do the trick. You can also add it to your mbed_app.json config file if you don't feel like typing it on the command line. More info on application config is available here: https://github.com/ARMmbed/mbed-os/blob/master/docs/config_system.md#configuration-data-in-applications

@pan-
Copy link
Member

pan- commented Oct 7, 2016

Sorry, I wasn't clear. I mean, -D NDEBUG is a compiler flag (for GCC at least, other compilers also support defines on the command line) so it should be possible to add it to a build profile instead of polluting the command line or mbed_app.json.

@bridadan
Copy link
Contributor

bridadan commented Oct 7, 2016

@pan- Oh you're absolutely right, my bad! Yeah you technically can do that since its just a compiler flag 😄 Though I would imagine we wouldn't be adding many (if any) compiler flags directly to the default build profiles since we then can't configure them. However with custom build profiles, you're free to do as you wish. Just know that things may break. (not necessarily from NDEBUG, but just adding flags in general since we can't test every configuration of this)

@betzw
Copy link
Contributor Author

betzw commented Oct 10, 2016

As I can see you have defined a debug.json and a default.json build profile. Typically, macro NDEBUG should be defined for "release" builds (e.g. it removes the code for assertions), for which currently there is no ecplicit profile in mbed-os.

Btw, how do those profiles work? Do they all inherit from default.json and then add the flags specified in the current profile?
Where can I find more documentation regarding profiles?

@bridadan
Copy link
Contributor

The documentation for build profiles are here: https://github.com/ARMmbed/mbed-os/blob/master/docs/Toolchain_Profiles.md

I'm actually not 100% sure about the inheritance of the profiles. @theotherjimmy could you clarify this and maybe add it to the documentation?

@screamerbg
Copy link
Contributor

Ping @theotherjimmy

1 similar comment
@betzw
Copy link
Contributor Author

betzw commented Nov 14, 2016

Ping @theotherjimmy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants