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

Build with optimizations by default #543

Merged
merged 1 commit into from
Oct 1, 2019

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Sep 30, 2019

GCC builds without optimizations by default while Clang uses -O2. Use -O2 for GCC by default too, but switch to -O0 when DEBUG is defined. Also make sure to always output debug information, not only in debug builds. Additional sections with it do not impact performance but are very useful in production. And they can be easily stripped out of the binaries if necessary, like we do when building packages.

We disable frame pointer omission optimization to get better stack frames and enable debugging on x86. While it has some impact, I’d rather have working backtraces.

GCC builds without optimizations by default while Clang uses -O2.
Use -O2 for GCC by default too, but switch to -O0 when DEBUG is
defined. Also make sure to always output debug information, not
only in debug builds. Additional sections with it do not impact
performance but are very useful in production. And they can be
easily stripped out of the binaries if necessary, like we do when
building packages.

We disable frame pointer omission optimization to get better stack
frames and enable debugging on x86. While it has some impact, I'd
rather have working backtraces.
@ilammy ilammy added the core Themis Core written in C, its packages label Sep 30, 2019
@vixentael vixentael added infrastructure Automated building and packaging and removed core Themis Core written in C, its packages labels Sep 30, 2019
Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

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

compiler optimizations might be unexpected, but looks like our tests are 👌

ifdef COVERAGE
CFLAGS += -g -O0 --coverage
CFLAGS += -O0 --coverage
Copy link
Collaborator

Choose a reason for hiding this comment

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

-O0 will override -O2 from outer scope?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. The compiler looks at the last specified level. With DEBUG enabled we end up with -O2 -O0 which is equivalent to just -O0. (Individual flags like -fno-omit-frame-pointer are effective regardless of the optimization level set by -O.)

@ilammy ilammy merged commit 170bec7 into cossacklabs:master Oct 1, 2019
@ilammy ilammy deleted the debug-symbols branch October 1, 2019 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Automated building and packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants