Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Autotools] Unicode's CFLAGS enforce -D_FORTIFY_SOURCE=2, -D_REENTRAN…
…T=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:


Canonical link: https://commits.webkit.org/137697@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
zdobersek committed Aug 13, 2013
1 parent 52efd52 commit 3c9894b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
23 changes: 23 additions & 0 deletions ChangeLog
@@ -1,3 +1,26 @@
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
Expand Down
2 changes: 1 addition & 1 deletion Source/autotools/FindDependencies.m4
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions Source/autotools/SetupCompilerFlags.m4
@@ -1,7 +1,7 @@
# 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
Expand All @@ -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"
Expand Down

0 comments on commit 3c9894b

Please sign in to comment.