GCC 4.9 Release

GCC 4.9 版本发布,包含 mudflap 运行时检查器移除、多系统支持废弃、内存错误检测增强、优化改进、新语言特性、内存使用减少和构建速度提升等关键更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GCC 4.9 Release Series
Changes, New Features, and Fixes

Caveats

  • The mudflap run time checker has been removed. The mudflap options remain, but do nothing.

  • Support for a number of older systems and recently unmaintained or untested target ports of GCC has been declared obsolete in GCC 4.9. Unless there is activity to revive them, the next release of GCC will have their sources permanently removed.

    The following ports for individual systems on particular architectures have been obsoleted:

    • Solaris 9 (*-*-solaris2.9). Details can be found in the announcement.
  • On AArch64, the singleton vector types int64x1_t, uint64x1_t and float64x1_t exported by arm_neon.h are defined to be the same as their base types. This results in incorrect application of parameter passing rules to arguments of types int64x1_t and uint64x1_t, with respect to the AAPCS64 ABI specification. In addition, names of C++ functions with parameters of these types (including float64x1_t) are not mangled correctly. The current typedef declarations also unintentionally allow implicit casting between singleton vector types and their base types. These issues will be resolved in a near future release. See PR60825 for more information.

More information on porting to GCC 4.9 from previous versions of GCC can be found in the porting guide for this release.

General Optimizer Improvements

  • AddressSanitizer, a fast memory error detector, is now available on ARM.
  • UndefinedBehaviorSanitizer (ubsan), a fast undefined behavior detector, has been added and can be enabled via -fsanitize=undefined. Various computations will be instrumented to detect undefined behavior at runtime. UndefinedBehaviorSanitizer is currently available for the C and C++ languages.
  • Link-time optimization (LTO) improvements:
    • Type merging was rewritten. The new implementation is significantly faster and uses less memory.
    • Better partitioning algorithm resulting in less streaming during link time.
    • Early removal of virtual methods reduces the size of object files and improves link-time memory usage and compile time.
    • Function bodies are now loaded on-demand and released early improving overall memory usage at link time.
    • C++ hidden keyed methods can now be optimized out.
    • When using a linker plugin, compiling with the -flto option now generates slim object files (.o) which only contain intermediate language representation for LTO. Use -ffat-lto-objects to create files which contain additionally the object code. To generate static libraries suitable for LTO processing, use gcc-ar and gcc-ranlib; to list symbols from a slim object file use gcc-nm. (This requires that ar, ranlib and nm have been compiled with plugin support.)
    Memory usage building Firefox with debug enabled was reduced from 15GB to 3.5GB; link time from 1700 seconds to 350 seconds.
  • Inter-procedural optimization improvements:
    • New type inheritance analysis module improving devirtualization. Devirtualization now takes into account anonymous name-spaces and the C++11 final keyword.
    • New speculative devirtualization pass (controlled by -fdevirtualize-speculatively.
    • Calls that were speculatively made direct are turned back to indirect where direct call is not cheaper.
    • Local aliases are introduced for symbols that are known to be semantically equivalent across shared libraries improving dynamic linking times.
  • Feedback directed optimization improvements:
    • Profiling of programs using C++ inline functions is now more reliable.
    • New time profiling determines typical order in which functions are executed.
    • A new function reordering pass (controlled by -freorder-functions) significantly reduces startup time of large applications. Until binutils support is completed, it is effective only with link-time optimization.
    • Feedback driven indirect call removal and devirtualization now handle cross-module calls when link-time optimization is enabled.

New Languages and Language specific improvements

  • Version 4.0 of the OpenMP specification is now supported in the C and C++ compilers and starting with the 4.9.1 release also in the Fortran compiler. The new -fopenmp-simd option can be used to enable OpenMP's SIMD directives, while ignoring other OpenMP directives. The new -fsimd-cost-model= option permits to tune the vectorization cost model for loops annotated with OpenMP and Cilk Plus simd directives; -Wopenmp-simd warns when the current cost model overrides simd directives set by the user.
  • The -Wdate-time option has been added for the C, C++ and Fortran compilers, which warns when the __DATE__, __TIME__ or __TIMESTAMP__ macros are used. Those macros might prevent bit-wise-identical reproducible compilations.

Ada

  • GNAT switched to Ada 2012 instead of Ada 2005 by default.

C family

  • Support for colorizing diagnostics emitted by GCC has been added. The -fdiagnostics-color=auto will enable it when outputting to terminals, -fdiagnostics-color=always unconditionally. The GCC_COLORS environment variable can be used to customize the colors or disable coloring. If GCC_COLORS variable is present in the environment, the default is -fdiagnostics-color=auto, otherwise -fdiagnostics-color=never.
    Sample diagnostics output:
        $ g++ -fdiagnostics-color=always -S -Wall test.C
        test.C: In function ‘int foo()’:
        test.C:1:14: warning: no return statement in function returning non-void [-Wreturn-type]
         int foo () { }
                      ^
        test.C:2:46: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘struct X<100>’
         template <int N> struct X { static const int value = X<N-1>::value; }; template struct X<1000>;
                                                      ^
        test.C:2:46:   recursively required from ‘const int X<999>::valuetest.C:2:46:   required from ‘const int X<1000>::valuetest.C:2:88:   required from here
    
        test.C:2:46: error: incomplete type ‘X<100>’ used in nested name specifier
        
  • With the new #pragma GCC ivdep, the user can assert that there are no loop-carried dependencies which would prevent concurrent execution of consecutive iterations using SIMD (single instruction multiple data) instructions.
  • Support for Cilk Plus has been added and can be enabled with the -fcilkplus option. Cilk Plus is an extension to the C and C++ languages to support data and task parallelism. The present implementation follows ABI version 1.2; all features but _Cilk_for have been implemented.

C

  • ISO C11 atomics (the _Atomic type specifier and qualifier and the <stdatomic.h> header) are now supported.
  • ISO C11 generic selections (_Generic keyword) are now supported.
  • ISO C11 thread-local storage (_Thread_local, similar to GNU C __thread) is now supported.
  • ISO C11 support is now at a similar level of completeness to ISO C99 support: substantially complete modulo bugs, extended identifiers (supported except for corner cases when -fextended-identifiers is used), floating-point issues (mainly but not entirely relating to optional C99 features from Annexes F and G) and the optional Annexes K (Bounds-checking interfaces) and L (Analyzability).
  • A new C extension __auto_type provides a subset of the functionality of C++11 auto in GNU C.

C++

  • The G++ implementation of C++1y return type deduction for normal functions has been updated to conform to N3638, the proposal accepted into the working paper. Most notably, it adds decltype(auto) for getting decltype semantics rather than the template argument deduction semantics of plain auto:
    int& f();
             auto  i1 = f(); // int
    decltype(auto) i2 = f(); // int&
    
  • G++ supports C++1y lambda capture initializers:
    [x = 42]{ ... };
    
    Actually, they have been accepted since GCC 4.5, but now the compiler doesn't warn about them with -std=c++1y, and supports parenthesized and brace-enclosed initializers as well.
  • G++ supports C++1y variable length arrays. G++ has supported GNU/C99-style VLAs for a long time, but now additionally supports initializers and lambda capture by reference. In C++1y mode G++ will complain about VLA uses that are not permitted by the draft standard, such as forming a pointer to VLA type or applying sizeof to a VLA variable. Note that it now appears that VLAs will not be part of C++14, but will be part of a separate document and then perhaps C++17.
    void f(int n) {
      int a[n] = { 1, 2, 3 }; // throws std::bad_array_length if n < 3
      [&a]{ for (int i : a) { cout << i << endl; } }();
      &a; // error, taking address of VLA
    }
    
  • G++ supports the C++1y [[deprecated]] attribute modulo bugs in the underlying [[gnu::deprecated]] attribute. Classes and functions can be marked deprecated and a diagnostic message added:
    class A;
    int bar(int n);
    #if __cplusplus > 201103
    class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
    [[deprecated("bar is unsafe; use foo() instead")]]
    int bar(int n);
    
    int foo(int n);
    class B;
    #endif
    A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
    int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use foo() instead
    
  • G++ supports C++1y digit separators. Long numeric literals can be subdivided with a single quote ' to enhance readability:
    int i = 1048576;
    int j = 1'048'576;
    int k = 0x10'0000;
    int m = 0'004'000'000;
    int n = 0b0001'0000'0000'0000'0000'0000;
    
    double x = 1.602'176'565e-19;
    double y = 1.602'176'565e-1'9;
    
  • G++ supports C++1y generic (polymorphic) lambdas.
    // a functional object that will increment any type
    auto incr = [](auto x) { return x++; };
    
  • As a GNU extension, G++ supports explicit template parameter syntax for generic lambdas. This can be combined in the expected way with the standard auto syntax.
    // a functional object that will add two like-type objects
    auto add = [] <typename T> (T a, T b) { return a + b; };
    
  • G++ supports unconstrained generic functions as specified by §4.1.2 and §5.1.1 of N3889: Concepts Lite Specification. Briefly, auto may be used as a type-specifier in a parameter declaration of any function declarator in order to introduce an implicit function template parameter, akin to generic lambdas.
    // the following two function declarations are equivalent
    auto incr(auto x) { return x++; }
    template <typename T>
    auto incr(T x) { return x++; }
    
Runtime Library (libstdc++)
  • Improved support for C++11, including:
    • support for <regex>;
    • The associative containers in <map> and <set> and the unordered associative containers in <unordered_map> and <unordered_set> meet the allocator-aware container requirements;
  • Improved experimental support for the upcoming ISO C++ standard, C++14, including:
    • fixing constexpr member functions without const;
    • implementation of the std::exchange() utility function;
    • addressing tuples by type;
    • implemention of std::make_unique;
    • implemention of std::shared_lock;
    • making std::result_of SFINAE-friendly;
    • adding operator() to std::integral_constant;
    • adding user-defined literals for standard library types std::basic_string, std::chrono::duration, and std::complex;
    • adding two range overloads to non-modifying sequence oprations std::equal and std::mismatch;
    • adding IO manipulators for quoted strings;
    • adding constexpr members to <utility>, <complex>, <chrono>, and some containers;
    • adding compile-time std::integer_sequence;
    • adding cleaner transformation traits;
    • making <functional>s operator functors easier to use and more generic;
  • An implementation of std::experimental::optional.
  • An implementation of std::experimental::string_view.
  • The non-standard function std::copy_exception has been deprecated and will be removed in a future version. std::make_exception_ptr should be used instead.

Fortran

  • Compatibility notice:
    • Module files: The version of the module files (.mod) has been incremented; additionally, module files are now compressed. Fortran MODULEs compiled by earlier GCC versions have to be recompiled, when they are USEd by files compiled with GCC 4.9. GCC 4.9 is not able to read .mod files of earlier GCC versions; attempting to do so gives an error message. Note: The ABI of the produced assembler data itself has not changed: object files and libraries are fully compatible with older versions (except as stated below).
    • ABI changes:
      • The argument passing ABI has changed for scalar dummy arguments of type INTEGER, REAL, COMPLEX and LOGICAL, which have both the VALUE and the OPTIONAL attributes.
      • To support finalization the virtual table associated with polymorphic variables has changed. Code containing CLASS should be recompiled, including all files which define derived types involved in the type definition used by polymorphic variables. (Note: Due to the incremented module version, trying to mix old code with new code will usually give an error message.)
    • GNU Fortran no longer deallocates allocatable variables or allocatable components of variables declared in the main program. Since Fortran 2008, the standard explicitly states that variables declared in the Fortran main program automatically have the SAVE attribute.
    • When opening files, the close-on-exec flag is set if the system supports such a feature. This is generally considered good practice these days, but if there is a need to pass file descriptors to child processes the parent process must now remember to clear the close-on-exec flag by calling fcntl(), e.g. via ISO_C_BINDING, before executing the child process.
  • The deprecated command-line option -fno-whole-file has been removed. (-fwhole-file is the default since GCC 4.6.) -fwhole-file/-fno-whole-file continue to be accepted but do not influence the code generation.
  • The compiler no longer unconditionally warns about DO loops with zero iterations. This warning is now controlled by the -Wzerotrips option, which is implied by -Wall.
  • The new NO_ARG_CHECK attribute of the !GCC$ directive can be used to disable the type-kind-rank (TKR) argument check for a dummy argument. The feature is similar to ISO/IEC TS 29133:2012's TYPE(*), except that it additionally also disables the rank check. Variables with NO_ARG_CHECK have to be dummy arguments and may only be used as argument to ISO_C_BINDING's C_LOC and as actual argument to another NO_ARG_CHECK dummy argument; also the other constraints of TYPE(*) apply. The dummy arguments should be declared as scalar or assumed-size variable of type type(*) (recommended) – or of type integer, real, complex or logical. With NO_ARG_CHECK, a pointer to the data without further type or shape information is passed, similar to C's void*. Note that also TS 29113's type(*),dimension(..) accepts arguments of any type and rank; contrary to NO_ARG_CHECK assumed-rank arguments pass an array descriptor which contains the array shape and stride of the argument.
  • Fortran 2003:
    • Finalization is now supported. It is currently only done for a subset of those situations in which it should occur.
    • Experimental support for scalar character components with deferred length (i.e. allocatable string length) in derived types has been added. (Deferred-length character variables are supported since GCC 4.6.)
  • Fortran 2008:
    • When STOP or ERROR STOP are used to terminate the execution and any exception (but inexact) is signaling, a warning is printed to ERROR_UNIT, indicating which exceptions are signaling. The -ffpe-summary= command-line option can be used to fine-tune for which exceptions the warning should be shown.
    • Rounding on input (READ) is now handled on systems where strtod honours the rounding mode. (For output, rounding is supported since GCC 4.5.) Note that for input, the compatible rounding mode is handled as nearest (i.e., for a tie, rounding to an even last significant [cf. IEC 60559:1989] – while compatible rounds away from zero for a tie).

Go

  • GCC 4.9 provides a complete implementation of the Go 1.2.1 release.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值