Browse Source

[build] put --as-needed into linker flags instead of cflags

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3026 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.37
Stefan Bühler 6 years ago
parent
commit
2b9be8f072
  1. 22
      configure.ac
  2. 9
      src/CMakeLists.txt

22
configure.ac

@ -25,7 +25,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
dnl @synopsis TRY_CFLAGS [compiler flags]
dnl @summary check whether compiler supports given C flags and adds them to CFLAGS
dnl @summary check whether compiler supports given flags and adds them to CFLAGS
AC_DEFUN([TRY_CFLAGS],
[dnl
AC_MSG_CHECKING([if $CC supports $1])
@ -42,6 +42,23 @@ AC_DEFUN([TRY_CFLAGS],
AC_LANG_POP([C])
])
dnl @synopsis TRY_LDFLAGS [linker flags]
dnl @summary check whether linker supports given flags and adds them to LDFLAGS
AC_DEFUN([TRY_LDFLAGS],
[dnl
AC_MSG_CHECKING([if $LD supports $1])
AC_LANG_PUSH([C])
ac_try_ldflags_saved_ldflags="${LDFLAGS}"
LDFLAGS="${LDFLAGS} $1"
AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])],
[
AC_MSG_ERROR([no])
LDFLAGS="${ac_try_ldflags_saved_cflags}"
]
)
AC_LANG_POP([C])
])
dnl Checks for programs.
AC_PROG_CC
@ -674,7 +691,8 @@ AC_ARG_ENABLE(extra-warnings,
esac],[extrawarnings=false])
if test x$extrawarnings = xtrue; then
TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
TRY_CFLAGS([-g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security])
TRY_LDFLAGS([-Wl,--as-needed])
fi
dnl build version-id

9
src/CMakeLists.txt

@ -35,10 +35,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
option(BUILD_EXTRA_WARNINGS "extra warnings")
if(BUILD_EXTRA_WARNINGS)
set(WARN_FLAGS "-g -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wl,--as-needed -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security")
set(WARN_CFLAGS "-g -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security")
set(WARN_LDFLAGS "-Wl,--as-needed")
# -Werror -Wbad-function-cast -Wmissing-prototypes
else()
set(WARN_FLAGS "")
endif()
endif()
@ -627,10 +626,12 @@ if(HAVE_MEMCACHE_H)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wshadow -W -pedantic ${WARN_CFLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WARN_LDFLAGS}")
add_definitions(-D_GNU_SOURCE)
endif()

Loading…
Cancel
Save