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

CMakeLists.txt: don't override the optimization level #847

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpetazzoni
Copy link

zenoh-pico's CMakeLists.txt has some logic to provide its own compiler optimization level: -O3 for release builds, -O0 for debug builds.

Unfortunately, using add_compile_options() means that those settings take precedence over what the user can pass as custom compiler flags. And this causes issues for example when doing a debug build with _FORTIFY_SOURCE enabled, as _FORTIFY_SOURCE support in glibc is incompatible with unoptimized builds causing this build failure:

/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~

which is a warning, but as zenoh-pico builds with -Werror, it turns into a build failure.

As it is unclear how CMakeLists.txt can pass a default -O level, while allowing it to be overridden by the user, we simply remove those optimization level options.

zenoh-pico's CMakeLists.txt has some logic to provide its own compiler
optimization level: -O3 for release builds, -O0 for debug builds.

Unfortunately, using add_compile_options() means that those settings
take precedence over what the user can pass as custom compiler
flags. And this causes issues for example when doing a debug build
with _FORTIFY_SOURCE enabled, as _FORTIFY_SOURCE support in glibc is
incompatible with unoptimized builds causing this build failure:

/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
  414 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

which is a warning, but as zenoh-pico builds with -Werror, it turns
into a build failure.

As it is unclear how CMakeLists.txt can pass a default -O level, while
allowing it to be overridden by the user, we simply remove those
optimization level options.

Signed-off-by: Thomas Petazzoni <[email protected]>
Copy link

PR missing one of the required labels: {'breaking-change', 'dependencies', 'documentation', 'enhancement', 'new feature', 'bug', 'internal'}

@tpetazzoni tpetazzoni marked this pull request as draft December 31, 2024 16:00
@tpetazzoni tpetazzoni marked this pull request as ready for review December 31, 2024 16:02
@tpetazzoni
Copy link
Author

The CI asks me to add a label... but I don't have the rights to do so. The "bug" label should be added.

@sashacmc sashacmc added the bug Something isn't working label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants