Commit f18ab334 authored by zandobersek@gmail.com's avatar zandobersek@gmail.com

[Autotools] Unicode's CFLAGS enforce -D_FORTIFY_SOURCE=2, -D_REENTRANT=1,...

[Autotools] Unicode's CFLAGS enforce -D_FORTIFY_SOURCE=2, -D_REENTRANT=1, causing faulty Clang builds
https://bugs.webkit.org/show_bug.cgi?id=119685

Reviewed by Gustavo Noronha Silva.

icu-config includes '-D_FORTIFY_SOURCE=2 -D_REENTRANT=1' when printing out C preprocessor flags that are used
as the C compiler flags to avoid other unwanted compiler options. This causes problems when building optimized
builds with Clang because of a bug in that compiler:
http://llvm.org/bugs/show_bug.cgi?id=16821

To avoid that, the C preprocessor search flags, as printed by `icu-config --cppflags-searchpath` are now used
the Unicode dependency's C compiler flags, avoiding unconditionally specifying the two macros.

To adjust for that, the `-pthread` flag is added to the global CFLAGS and CXXFLAGS variables, ensuring
the _REENTRANT define is set to 1 and declaring the flag globally instead of relying on Glib dependency's
C compiler flags to do so for us. -D_FORTIFY_SOURCE=2 is only added to the CFLAGS and CXXFLAGS variables if
the compiler in use is gcc or g++, preventing the Clang builds to malfunction.

* Source/autotools/FindDependencies.m4:
* Source/autotools/SetupCompilerFlags.m4:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c1aaaea0
2013-08-13 Zan Dobersek <zdobersek@igalia.com>
[Autotools] Unicode's CFLAGS enforce -D_FORTIFY_SOURCE=2, -D_REENTRANT=1, causing faulty Clang builds
https://bugs.webkit.org/show_bug.cgi?id=119685
Reviewed by Gustavo Noronha Silva.
icu-config includes '-D_FORTIFY_SOURCE=2 -D_REENTRANT=1' when printing out C preprocessor flags that are used
as the C compiler flags to avoid other unwanted compiler options. This causes problems when building optimized
builds with Clang because of a bug in that compiler:
http://llvm.org/bugs/show_bug.cgi?id=16821
To avoid that, the C preprocessor search flags, as printed by `icu-config --cppflags-searchpath` are now used
the Unicode dependency's C compiler flags, avoiding unconditionally specifying the two macros.
To adjust for that, the `-pthread` flag is added to the global CFLAGS and CXXFLAGS variables, ensuring
the _REENTRANT define is set to 1 and declaring the flag globally instead of relying on Glib dependency's
C compiler flags to do so for us. -D_FORTIFY_SOURCE=2 is only added to the CFLAGS and CXXFLAGS variables if
the compiler in use is gcc or g++, preventing the Clang builds to malfunction.
* Source/autotools/FindDependencies.m4:
* Source/autotools/SetupCompilerFlags.m4:
2013-08-13 Zan Dobersek <zdobersek@igalia.com>
[Autotools] Don't compare $CC, $CXX to exact compiler names
......
......@@ -125,7 +125,7 @@ case "$host" in
# We don't use --cflags as this gives us a lot of things that we don't necessarily want,
# like debugging and optimization flags. See man (1) icu-config for more info.
UNICODE_CFLAGS=`$icu_config --cppflags`
UNICODE_CFLAGS=`$icu_config --cppflags-searchpath`
UNICODE_LIBS=`$icu_config --ldflags-libsonly`
;;
esac
......
# Use C99 as the language standard for C code.
CFLAGS="$CFLAGS -std=c99"
CFLAGS="$CFLAGS -pthread -std=c99"
# Use the C++11 standard. Do not warn about C++11 incompatibilities.
CXXFLAGS="$CXXFLAGS -std=c++11 -Wno-c++11-compat"
CXXFLAGS="$CXXFLAGS -pthread -std=c++11 -Wno-c++11-compat"
# Clang requires suppression of unused arguments warnings.
if test "$c_compiler" = "clang"; then
......@@ -15,6 +15,13 @@ if test "$cxx_compiler" = "clang++"; then
CXXFLAGS="$CXXFLAGS -stdlib=libstdc++ -Wno-c++11-extensions -Qunused-arguments"
fi
if test "$c_compiler" = "gcc"; then
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
fi
if test "$cxx_compiler" = "g++"; then
CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
fi
if test "$host_cpu" = "sh4"; then
CXXFLAGS="$CXXFLAGS -mieee -w"
CFLAGS="$CFLAGS -mieee -w"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment