legionus / kbd

Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/legion/kbd.git
https://kbd-project.org
Other
84 stars 41 forks source link

Use `AX_ADD_FORTIFY_SOURCE` to avoid redefining `_FORTIFY_SOURCE` #103

Closed thesamesam closed 12 months ago

thesamesam commented 12 months ago

Some distributions are now setting -D_FORTIFY_SOURCE=3 by default in their toolchains rather than _F_S=2. By forcing _F_S=2, this causes both a warning and a downgrade in the effective protection.

Use the autoconf-archive macro for this purpose (AX_ADD_FORTIFY_SOURCE) to add the fortification at the highest supported level if the compiler doesn't already default to it.

legionus commented 12 months ago

@thesamesam This seems generally correct and useful. But your change breaks distcheck:

./configure: line 17217: syntax error near unexpected token `-Werror,CFLAGS="$CFLAGS -Werror"'
checking for library containing timer_create... none required
./configure: line 17217: `    AX_CHECK_COMPILE_FLAG(-Werror,CFLAGS="$CFLAGS -Werror")'
thesamesam commented 12 months ago

Thanks. I can't seem to reproduce it locally yet, although I think I can see how it might happen with the -Werror mangling.

I'm going to switch to AS_IF as well given bare if is now recommended against. Let's see if that does the job...

legionus commented 12 months ago

I found the problem. The problem is not that -Werror is used, but that the AX_CHECK_COMPILE_FLAG macro is not expanded. We must also copy /usr/share/aclocal/ax_check_compile_flag.m4 to the m4 directory.

thesamesam commented 12 months ago

Thanks for the help - sorry it wasn't as straightforward as it was supposed to be.

legionus commented 12 months ago

Thank you! Applied.