Changeset 154008 in webkit


Ignore:
Timestamp:
Aug 13, 2013 9:58:17 AM (11 years ago)
Author:
zandobersek@gmail.com
Message:

[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:
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r154007 r154008  
     12013-08-13  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [Autotools] Unicode's CFLAGS enforce -D_FORTIFY_SOURCE=2, -D_REENTRANT=1, causing faulty Clang builds
     4        https://bugs.webkit.org/show_bug.cgi?id=119685
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        icu-config includes '-D_FORTIFY_SOURCE=2 -D_REENTRANT=1' when printing out C preprocessor flags that are used
     9        as the C compiler flags to avoid other unwanted compiler options. This causes problems when building optimized
     10        builds with Clang because of a bug in that compiler:
     11        http://llvm.org/bugs/show_bug.cgi?id=16821
     12
     13        To avoid that, the C preprocessor search flags, as printed by `icu-config --cppflags-searchpath` are now used
     14        the Unicode dependency's C compiler flags, avoiding unconditionally specifying the two macros.
     15
     16        To adjust for that, the `-pthread` flag is added to the global CFLAGS and CXXFLAGS variables, ensuring
     17        the _REENTRANT define is set to 1 and declaring the flag globally instead of relying on Glib dependency's
     18        C compiler flags to do so for us. -D_FORTIFY_SOURCE=2 is only added to the CFLAGS and CXXFLAGS variables if
     19        the compiler in use is gcc or g++, preventing the Clang builds to malfunction.
     20
     21        * Source/autotools/FindDependencies.m4:
     22        * Source/autotools/SetupCompilerFlags.m4:
     23
    1242013-08-13  Zan Dobersek  <zdobersek@igalia.com>
    225
  • trunk/Source/autotools/FindDependencies.m4

    r153885 r154008  
    126126        # We don't use --cflags as this gives us a lot of things that we don't necessarily want,
    127127        # like debugging and optimization flags. See man (1) icu-config for more info.
    128         UNICODE_CFLAGS=`$icu_config --cppflags`
     128        UNICODE_CFLAGS=`$icu_config --cppflags-searchpath`
    129129        UNICODE_LIBS=`$icu_config --ldflags-libsonly`
    130130        ;;
  • trunk/Source/autotools/SetupCompilerFlags.m4

    r154007 r154008  
    11# Use C99 as the language standard for C code.
    2 CFLAGS="$CFLAGS -std=c99"
     2CFLAGS="$CFLAGS -pthread -std=c99"
    33# Use the C++11 standard. Do not warn about C++11 incompatibilities.
    4 CXXFLAGS="$CXXFLAGS -std=c++11 -Wno-c++11-compat"
     4CXXFLAGS="$CXXFLAGS -pthread -std=c++11 -Wno-c++11-compat"
    55
    66# Clang requires suppression of unused arguments warnings.
     
    1414if test "$cxx_compiler" = "clang++"; then
    1515    CXXFLAGS="$CXXFLAGS -stdlib=libstdc++ -Wno-c++11-extensions -Qunused-arguments"
     16fi
     17
     18if test "$c_compiler" = "gcc"; then
     19    CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
     20fi
     21if test "$cxx_compiler" = "g++"; then
     22    CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
    1623fi
    1724
Note: See TracChangeset for help on using the changeset viewer.