8000 cmake: fix building in debug mode by ligurio · Pull Request #56 · ligurio/luzer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cmake: fix building in debug mode #56

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

Merged
merged 1 commit into from
Jul 3, 2025

Conversation

ligurio
Copy link
Owner
@ligurio ligurio commented Jul 3, 2025

The build with -DCMAKE_BUILD_TYPE=Debug can ends with the error:

In file included from luzer/counters.c:8:
In file included from /usr/lib/llvm/20/bin/../../../../lib/clang/20/include/stdint.h:56:
In file included from /usr/include/stdint.h:26:
In file included from /usr/include/bits/libc-header-start.h:33:
/usr/include/features.h:422:4: error: _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror,-W#warnings]
422 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)

This happened because _FORTIFY_SOURCE should be enabled along with non-zero optimization level. CMake has four build types: Release, Debug, RelWithDebInfo, MinSizeRel and only Debug build type disables optimizations. The patch applies C compiler hardening flags to all targets, enables _FORTIFY_SOURCE flags only for non-debug builds and fixes an error due to incorrect function prototype for get_global_lua_state().

Fixes #54

@ligurio ligurio force-pushed the ligurio/gh-54-fix-building-debug branch from c63b142 to d908d72 Compare July 3, 2025 11:03
Copy link
Contributor
@Buristan Buristan left a comment

Choose a reason for hiding this comment

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

Hi, Sergey!
Thanks for the fix!
I've tested it locally, and it works like a charm.
LGTM!

@ligurio ligurio force-pushed the ligurio/gh-54-fix-building-debug branch 3 times, most recently from 77f2a4f to 42d145c Compare July 3, 2025 13:08
The build with -DCMAKE_BUILD_TYPE=Debug can ends with the error:

> In file included from luzer/counters.c:8:
> In file included from /usr/lib/llvm/20/bin/../../../../lib/clang/20/include/stdint.h:56:
> In file included from /usr/include/stdint.h:26:
> In file included from /usr/include/bits/libc-header-start.h:33:
> /usr/include/features.h:422:4: error: _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror,-W#warnings]
  422 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)

This happened because optimizations must be enabled when
compiler option `_FORTIFY_SOURCE` is enabled. CMake has four
build types: Release, Debug, RelWithDebInfo, MinSizeRel and only
Debug build type disables optimizations. The patch applies
compiler hardening flags to all targets, enables `_FORTIFY_SOURCE`
option only for non-debug builds and fixes errors generated by
enabled compiler options.

Fixes #54
@ligurio ligurio force-pushed the ligurio/gh-54-fix-building-debug branch from 42d145c to 08666ba Compare July 3, 2025 13:11
@ligurio ligurio merged commit ce2b99e into master Jul 3, 2025
16 checks passed
@ligurio ligurio deleted the ligurio/gh-54-fix-building-debug branch July 3, 2025 13:13
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.

Support build in the Debug mode
2 participants
0