50
GCC 4.8, State of the Onion Dodji Seketeli <[email protected]> Distro Recipes Conference - April 2013 - Paris, France Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 1/23

Distro Recipes 2013: What’s new in gcc 4.8?

Embed Size (px)

Citation preview

Page 1: Distro Recipes 2013: What’s new in gcc 4.8?

GCC 4.8, State of the Onion

Dodji Seketeli <[email protected]>

Distro Recipes Conference - April 2013 - Paris, France

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 1/23

Page 2: Distro Recipes 2013: What’s new in gcc 4.8?

Breakup of the talk

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 2/23

Page 3: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 3/23

Page 4: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

I 2 phases in the development time line of GCC

I Phase 1: New features; at least 6 monthsI Phase 2: Stabilization; the time it takes.

I GCC 4.7 released in March 2012

I GCC 4.8 released in March 2013

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 4/23

Page 5: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

I 2 phases in the development time line of GCCI Phase 1: New features; at least 6 months

I Phase 2: Stabilization; the time it takes.

I GCC 4.7 released in March 2012

I GCC 4.8 released in March 2013

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 4/23

Page 6: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

I 2 phases in the development time line of GCCI Phase 1: New features; at least 6 monthsI Phase 2: Stabilization; the time it takes.

I GCC 4.7 released in March 2012

I GCC 4.8 released in March 2013

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 4/23

Page 7: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

I 2 phases in the development time line of GCCI Phase 1: New features; at least 6 monthsI Phase 2: Stabilization; the time it takes.

I GCC 4.7 released in March 2012

I GCC 4.8 released in March 2013

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 4/23

Page 8: Distro Recipes 2013: What’s new in gcc 4.8?

GCC Development Plan

I 2 phases in the development time line of GCCI Phase 1: New features; at least 6 monthsI Phase 2: Stabilization; the time it takes.

I GCC 4.7 released in March 2012

I GCC 4.8 released in March 2013

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 4/23

Page 9: Distro Recipes 2013: What’s new in gcc 4.8?

Diagnostics changes

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 5/23

Page 10: Distro Recipes 2013: What’s new in gcc 4.8?

-fdiagnostics-show-caret Option

Displays source code in diagnostic messages

t.cc:4:19: fatal error: foo: No such file or directory

#include <foo>

^

compilation terminated.

This option is on by default in in 4.8!

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 6/23

Page 11: Distro Recipes 2013: What’s new in gcc 4.8?

-Wsizeof-pointer-memaccess Option

Warns about the suspicious use of memory access function of theC library, like in:

memset (ptr, 0, sizeof (ptr));

This option is turned on by -Wall

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 7/23

Page 12: Distro Recipes 2013: What’s new in gcc 4.8?

-ftrack-macro-location Option

I First appeared in 4.7 as an unstable tech preview.

I Ironed out, stabilized and set by default in 4.8

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 8/23

Page 13: Distro Recipes 2013: What’s new in gcc 4.8?

-ftrack-macro-location Option

I First appeared in 4.7 as an unstable tech preview.

I Ironed out, stabilized and set by default in 4.8

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 8/23

Page 14: Distro Recipes 2013: What’s new in gcc 4.8?

-ftrack-macro-location Option

Once upon a time, an error in the expansion of a macro was pain(in the bottom of the back) to diagnose:

============> test.c <==============

1 #define SHIFT(OP0, OP1) \

2 OP0 << OP1

3

4 int

5 main ()

6 {

7 return SHIFT (1, 1.1);

8 }

==========================

===============> Error Diagnostics <=============

test.c: In function ’int main()’:

test.c:7:10: error: invalid operands of types ’int’ and ’double’ to binary ’operator<<’

===============================================

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 9/23

Page 15: Distro Recipes 2013: What’s new in gcc 4.8?

Option -ftrack-macro-location

Now, with this option, combined with -fdiagnostics-show-caret ourback is relieved:

============> test.c <==============

1 #define SHIFT(OP0, OP1) \

2 OP0 << OP1

3

4 int

5 main ()

6 {

7 return SHIFT (1, 1.1);

8 }

==========================

==========> Ce que le compilateur nous dira maintenant <========

test.c: In function ’main’:

test.c:2:6: error: invalid operands to binary << (have ’int’ and ’double’)

OP0 << OP1

^

test.c:7:10: note: in expansion of macro ’SHIFT’

return SHIFT (1, 1.1);

^

=================================================

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 10/23

Page 16: Distro Recipes 2013: What’s new in gcc 4.8?

Changes in langage support

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 11/23

Page 17: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I New version 7 of ABI introduced. But for now, version 2 ofthe ABI remains the default.

I Better support for the memory model of C++11.

I Support of C++11 atomic operators.

I Thread variable - key word thread local

thread_local int i;

I Generalized attributes

struct [[gnu::packed]] a_type_of_5_bytes{

char premier;int second;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 12/23

Page 18: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I New version 7 of ABI introduced. But for now, version 2 ofthe ABI remains the default.

I Better support for the memory model of C++11.

I Support of C++11 atomic operators.

I Thread variable - key word thread local

thread_local int i;

I Generalized attributes

struct [[gnu::packed]] a_type_of_5_bytes{

char premier;int second;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 12/23

Page 19: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I New version 7 of ABI introduced. But for now, version 2 ofthe ABI remains the default.

I Better support for the memory model of C++11.I Support of C++11 atomic operators.

I Thread variable - key word thread local

thread_local int i;

I Generalized attributes

struct [[gnu::packed]] a_type_of_5_bytes{

char premier;int second;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 12/23

Page 20: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I New version 7 of ABI introduced. But for now, version 2 ofthe ABI remains the default.

I Better support for the memory model of C++11.I Support of C++11 atomic operators.

I Thread variable - key word thread local

thread_local int i;

I Generalized attributes

struct [[gnu::packed]] a_type_of_5_bytes{

char premier;int second;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 12/23

Page 21: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I New version 7 of ABI introduced. But for now, version 2 ofthe ABI remains the default.

I Better support for the memory model of C++11.I Support of C++11 atomic operators.

I Thread variable - key word thread local

thread_local int i;

I Generalized attributes

struct [[gnu::packed]] a_type_of_5_bytes{

char premier;int second;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 12/23

Page 22: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I Alignment Expressions;

struct alignas (a_type_of_5_bytes) another_type{char c;int i;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 13/23

Page 23: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I Alignment Expressions;

struct alignas (a_type_of_5_bytes) another_type{char c;int i;

};

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 13/23

Page 24: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I Inherited Constructors

struct A

{

A(int);

A(const char*);

};

struct B : public A

{

using A::A; // <-- all constructors of B are generated here

};

B b0("coucou"); // OK

B b1(10); // OK, too.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 14/23

Page 25: Distro Recipes 2013: What’s new in gcc 4.8?

C++11

I Inherited Constructors

struct A

{

A(int);

A(const char*);

};

struct B : public A

{

using A::A; // <-- all constructors of B are generated here

};

B b0("coucou"); // OK

B b1(10); // OK, too.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 14/23

Page 26: Distro Recipes 2013: What’s new in gcc 4.8?

Other languages

Support of Fortran and Go was greatly improved too.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 15/23

Page 27: Distro Recipes 2013: What’s new in gcc 4.8?

Optimizations and Middle End changes

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 16/23

Page 28: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 29: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 30: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 31: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 32: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 33: Distro Recipes 2013: What’s new in gcc 4.8?

General optimizer improvements

I DWARF 4 is now default debug info format. GDB 7.5,Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.

I New -Og : faster compilation, good debugging experience,reasonable speed. Better than -0O.

I Better scalability on very big functions.

I Better LTO support.

I Address Sanitizer: New fast memory error detector on inteland ppc GNU/Linux and intel/Darwin. -fsanitize=address.

I Thread Sanitizer: Data race memory error detector, on x86-64GNU/Linux. -fsanitize=thread.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 17/23

Page 34: Distro Recipes 2013: What’s new in gcc 4.8?

processor support

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 18/23

Page 35: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVRI In x86 land

I Support for new Broadwell architecture.I New built-in functions to detect CPU type at runtime:

builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 36: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVRI In x86 land

I Support for new Broadwell architecture.I New built-in functions to detect CPU type at runtime:

builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 37: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVR

I In x86 land

I Support for new Broadwell architecture.I New built-in functions to detect CPU type at runtime:

builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 38: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVRI In x86 land

I Support for new Broadwell architecture.I New built-in functions to detect CPU type at runtime:

builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 39: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVRI In x86 land

I Support for new Broadwell architecture.

I New built-in functions to detect CPU type at runtime:builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 40: Distro Recipes 2013: What’s new in gcc 4.8?

CPUs support

I AArch64, aka ARM 64. Just added for Cortex-A53 andCortex-A57 processors -mcpu=cortex-a53 and-mcpu=cortex-a57.

I Better code generation for several existing ARM chips,including better auto-vectorization.

I Better support for AVRI In x86 land

I Support for new Broadwell architecture.I New built-in functions to detect CPU type at runtime:

builtin cpu is(”westmere”); andbuiltin cpu supports(”sse”);

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 19/23

Page 41: Distro Recipes 2013: What’s new in gcc 4.8?

x86 CPU Support, continued

I Function Multi-versioning in G++: Create multiple versions ofa function, each one targeting a specific processor or ISA.Example:

__attribute__ ((target ("default")))

int foo(void)

{

return 1;

}

__attribute__ ((target ("sse4.2")))

int foo(void)

{

return 2;

}

int main (void)

{

int (*p) = &foo;

assert ((*p)() == foo());

return 0;

}

I AMD Steamroller and Jaguar Core. -march=bdver3 and-march=btver2.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 20/23

Page 42: Distro Recipes 2013: What’s new in gcc 4.8?

x86 CPU Support, continued

I Function Multi-versioning in G++: Create multiple versions ofa function, each one targeting a specific processor or ISA.Example:

__attribute__ ((target ("default")))

int foo(void)

{

return 1;

}

__attribute__ ((target ("sse4.2")))

int foo(void)

{

return 2;

}

int main (void)

{

int (*p) = &foo;

assert ((*p)() == foo());

return 0;

}

I AMD Steamroller and Jaguar Core. -march=bdver3 and-march=btver2.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 20/23

Page 43: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Change

GCC Development Plan

Significant Changes in 4.8DiagnosticLanguage supportOptimizations and Middle EndProcessorsArchitecture Change

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 21/23

Page 44: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.

This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 45: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 46: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 47: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 48: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 49: Distro Recipes 2013: What’s new in gcc 4.8?

Architecture Changes

GCC is now implemented in C++03.This allows:

I Doing the language change progressively. Now one could everre-write those millions lines of code out there overnight.

I Get better abstraction in a easier manner.

I Strong typing implies more errors detected at compile time.

I And compile time of the compiler didn’t increase! Quite theopposite.

A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 22/23

Page 50: Distro Recipes 2013: What’s new in gcc 4.8?

Merci !

http://gcc.gnu.org - Drink the Cool Aid.http://gcc.gnu.org/git - Code source repositorygit clone git://gcc.gnu.org/git/gcc.git - git the sources!http://news.gmane.org/gmane.comp.gcc.devel - Trolling, err,discussions, sorry.http://gcc.gnu.org/contribute.html - How to contribute. Yes, [email protected] - Where to send patches. Yes, you again.

Dodji Seketeli <[email protected]> GCC 4.8, State of the Onion 23/23