Skip to content

build: do not modify user-provided CFLAGS variable #240

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ LT_INIT
AM_ICONV

# SIZE_MAX is missing without this
CXXFLAGS="$CXXFLAGS -D__STDC_LIMIT_MACROS"
AM_CXXFLAGS="$AM_CXXFLAGS -D__STDC_LIMIT_MACROS"

# Use the first x.y.z numbers of the version. Also allow x.y numbering.
AS_IF([echo "$PACKAGE_VERSION" | grep '^[[0-9]]*\.[[0-9]]*\.[[0-9]]'], [
Expand Down Expand Up @@ -772,8 +772,10 @@ SETTING_LINKED_FILES=`echo $libdovecot_c_files | $SED -e s,$srcdir/src,./src,g -
AC_SUBST(SETTING_FILES)
AC_SUBST(SETTING_LINKED_FILES)

CFLAGS="$CFLAGS $EXTRA_CFLAGS"
CXXFLAGS="$CXXFLAGS $EXTRA_CFLAGS"
AM_CFLAGS="$AM_CFLAGS $EXTRA_CFLAGS"
AM_CXXFLAGS="$AM_CXXFLAGS $EXTRA_CFLAGS"
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
BINARY_LDFLAGS="$PIE_LDFLAGS $RELRO_LDFLAGS"
BINARY_CFLAGS="$PIE_CFLAGS"

Expand Down Expand Up @@ -940,7 +942,7 @@ echo "userdbs ........ :$userdb"
if test "$not_userdb" != ""; then
echo " :$not_userdb"
fi
echo "CFLAGS ......... : $CFLAGS"
echo "AM_CFLAGS ...... : $AM_CFLAGS"

if test "$systemdsystemunitdir" != ""; then
echo "SYSTEMD ........ : $systemdservicetype - $systemdsystemunitdir/dovecot.service";
Expand Down
25 changes: 12 additions & 13 deletions m4/dovecot.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AC_DEFUN([AC_CC_D_FORTIFY_SOURCE],[
case "$host" in
*)
gl_COMPILER_OPTION_IF([-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2], [
CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
AM_CFLAGS="$AM_CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
],
[],
[AC_LANG_PROGRAM()]
Expand All @@ -43,20 +43,19 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
CFLAGS="-std=$mystd"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()
], [
CFLAGS="$CFLAGS $old_cflags"
AM_CFLAGS="$AM_CFLAGS $CFLAGS"
std=$mystd
break
], [
CFLAGS="$old_cflags"
])
done
AC_MSG_RESULT($std)
CFLAGS="$old_cflags"

AS_IF([test "x$ac_cv_c_compiler_gnu" = "xyes"], [
dnl -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
dnl -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
dnl -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
AM_CFLAGS="$AM_CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"

AS_IF([test "$have_clang" = "yes"], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Expand All @@ -65,11 +64,11 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
#endif
]], [[]])],[],[
dnl clang 3.3+ unfortunately this gives warnings with hash.h
CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier"
AM_CFLAGS="$AM_CFLAGS -Wno-duplicate-decl-specifier"
])
], [
dnl This is simply to avoid warning when building strftime() wrappers..
CFLAGS="$CFLAGS -fno-builtin-strftime"
AM_CFLAGS="$AM_CFLAGS -fno-builtin-strftime"
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Expand All @@ -78,7 +77,7 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
#endif
]], [[]])],[
dnl gcc4
CFLAGS="$CFLAGS -Wstrict-aliasing=2"
AM_CFLAGS="$AM_CFLAGS -Wstrict-aliasing=2"
],[])
])
])
Expand Down Expand Up @@ -210,12 +209,12 @@ AC_DEFUN([AC_CC_RETPOLINE],[
case "$host" in
*)
gl_COMPILER_OPTION_IF([-mfunction-return=$with_retpoline],
[CFLAGS="$CFLAGS -mfunction-return=$with_retpoline"],
[AM_CFLAGS="$AM_CFLAGS -mfunction-return=$with_retpoline"],
[],
[AC_LANG_PROGRAM()]
)
gl_COMPILER_OPTION_IF([-mindirect-branch=$with_retpoline], [
CFLAGS="$CFLAGS -mindirect-branch=$with_retpoline"
AM_CFLAGS="$AM_CFLAGS -mindirect-branch=$with_retpoline"
],
[],
[AC_LANG_PROGRAM()]
Expand All @@ -234,11 +233,11 @@ AC_DEFUN([AC_CC_F_STACK_PROTECTOR],[
case "$host" in
*)
gl_COMPILER_OPTION_IF([-fstack-protector-strong], [
CFLAGS="$CFLAGS -fstack-protector-strong"
AM_CFLAGS="$AM_CFLAGS -fstack-protector-strong"
],
[
gl_COMPILER_OPTION_IF([-fstack-protector], [
CFLAGS="$CFLAGS -fstack-protector"
AM_CFLAGS="$AM_CFLAGS -fstack-protector"
], [], [AC_LANG_PROGRAM()])
],
[AC_LANG_PROGRAM()]
Expand Down Expand Up @@ -310,7 +309,7 @@ AC_DEFUN([DC_DOVECOT_FUZZER],[
with_fuzzer=$withval,
with_fuzzer=no)
AS_IF([test x$with_fuzzer = xclang], [
CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
AM_CFLAGS="$AM_CFLAGS -fsanitize=fuzzer-no-link"
# use $LIB_FUZZING_ENGINE for linking if it exists
FUZZER_LDFLAGS=${LIB_FUZZING_ENGINE--fsanitize=fuzzer}
# May need to use CXXLINK for linking, which wants sources to
Expand Down