Distro Recipes 2013: What’s new in gcc 4.8?
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
700
On Slideshare
700
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. GCC 4.8, State of the Onion Dodji Seketeli <dodji@redhat.com> Distro Recipes Conference - April 2013 - Paris, FranceDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 1/23
  • 2. Breakup of the talkGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 2/23
  • 3. GCC Development PlanGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 3/23
  • 4. GCC Development Plan 2 phases in the development time line of GCCDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 4/23
  • 5. GCC Development Plan 2 phases in the development time line of GCC Phase 1: New features; at least 6 monthsDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 4/23
  • 6. GCC Development Plan 2 phases in the development time line of GCC Phase 1: New features; at least 6 months Phase 2: Stabilization; the time it takes.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 4/23
  • 7. GCC Development Plan 2 phases in the development time line of GCC Phase 1: New features; at least 6 months Phase 2: Stabilization; the time it takes. GCC 4.7 released in March 2012Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 4/23
  • 8. GCC Development Plan 2 phases in the development time line of GCC Phase 1: New features; at least 6 months Phase 2: Stabilization; the time it takes. GCC 4.7 released in March 2012 GCC 4.8 released in March 2013Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 4/23
  • 9. Diagnostics changesGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 5/23
  • 10. -fdiagnostics-show-caret OptionDisplays source code in diagnostic messagest.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 <dodji@redhat.com> GCC 4.8, State of the Onion 6/23
  • 11. -Wsizeof-pointer-memaccess OptionWarns about the suspicious use of memory access function of theC library, like in:memset (ptr, 0, sizeof (ptr));This option is turned on by -WallDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 7/23
  • 12. -ftrack-macro-location Option First appeared in 4.7 as an unstable tech preview.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 8/23
  • 13. -ftrack-macro-location Option First appeared in 4.7 as an unstable tech preview. Ironed out, stabilized and set by default in 4.8Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 8/23
  • 14. -ftrack-macro-location OptionOnce 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 <dodji@redhat.com> GCC 4.8, State of the Onion 9/23
  • 15. Option -ftrack-macro-locationNow, 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 <dodji@redhat.com> GCC 4.8, State of the Onion 10/23
  • 16. Changes in langage supportGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 11/23
  • 17. C++11 New version 7 of ABI introduced. But for now, version 2 of the ABI remains the default.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 12/23
  • 18. C++11 New version 7 of ABI introduced. But for now, version 2 of the ABI remains the default. Better support for the memory model of C++11.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 12/23
  • 19. C++11 New version 7 of ABI introduced. But for now, version 2 of the ABI remains the default. Better support for the memory model of C++11. Support of C++11 atomic operators.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 12/23
  • 20. C++11 New version 7 of ABI introduced. But for now, version 2 of the ABI remains the default. Better support for the memory model of C++11. Support of C++11 atomic operators. Thread variable - key word thread local thread_local int i;Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 12/23
  • 21. C++11 New version 7 of ABI introduced. But for now, version 2 of the ABI remains the default. Better support for the memory model of C++11. Support of C++11 atomic operators. Thread variable - key word thread local thread_local int i; Generalized attributes struct [[gnu::packed]] a_type_of_5_bytes { char premier; int second; };Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 12/23
  • 22. C++11 Alignment Expressions;Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 13/23
  • 23. C++11 Alignment Expressions; struct alignas (a_type_of_5_bytes) another_type { char c; int i; };Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 13/23
  • 24. C++11 Inherited ConstructorsDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 14/23
  • 25. C++11 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"); // OKB b1(10); // OK, too.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 14/23
  • 26. Other languagesSupport of Fortran and Go was greatly improved too.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 15/23
  • 27. Optimizations and Middle End changesGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 16/23
  • 28. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 29. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly. New -Og : faster compilation, good debugging experience, reasonable speed. Better than -0O.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 30. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly. New -Og : faster compilation, good debugging experience, reasonable speed. Better than -0O. Better scalability on very big functions.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 31. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly. New -Og : faster compilation, good debugging experience, reasonable speed. Better than -0O. Better scalability on very big functions. Better LTO support.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 32. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly. New -Og : faster compilation, good debugging experience, reasonable speed. Better than -0O. Better scalability on very big functions. Better LTO support. Address Sanitizer: New fast memory error detector on intel and ppc GNU/Linux and intel/Darwin. -fsanitize=address.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 33. General optimizer improvements DWARF 4 is now default debug info format. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 were updated accordingly. New -Og : faster compilation, good debugging experience, reasonable speed. Better than -0O. Better scalability on very big functions. Better LTO support. Address Sanitizer: New fast memory error detector on intel and ppc GNU/Linux and intel/Darwin. -fsanitize=address. Thread Sanitizer: Data race memory error detector, on x86-64 GNU/Linux. -fsanitize=thread.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 17/23
  • 34. processor supportGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 18/23
  • 35. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 36. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57. Better code generation for several existing ARM chips, including better auto-vectorization.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 37. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57. Better code generation for several existing ARM chips, including better auto-vectorization. Better support for AVRDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 38. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57. Better code generation for several existing ARM chips, including better auto-vectorization. Better support for AVR In x86 landDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 39. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57. Better code generation for several existing ARM chips, including better auto-vectorization. Better support for AVR In x86 land Support for new Broadwell architecture.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 40. CPUs support AArch64, aka ARM 64. Just added for Cortex-A53 and Cortex-A57 processors -mcpu=cortex-a53 and -mcpu=cortex-a57. Better code generation for several existing ARM chips, including better auto-vectorization. Better support for AVR In x86 land Support for new Broadwell architecture. New built-in functions to detect CPU type at runtime: builtin cpu is(”westmere”); and builtin cpu supports(”sse”);Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 19/23
  • 41. x86 CPU Support, continued Function Multi-versioning in G++: Create multiple versions of a 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; }Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 20/23
  • 42. x86 CPU Support, continued Function Multi-versioning in G++: Create multiple versions of a 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; } AMD Steamroller and Jaguar Core. -march=bdver3 and -march=btver2.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 20/23
  • 43. Architecture ChangeGCC Development PlanSignificant Changes in 4.8 Diagnostic Language support Optimizations and Middle End Processors Architecture ChangeDodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 21/23
  • 44. Architecture ChangesGCC is now implemented in C++03.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 45. Architecture ChangesGCC is now implemented in C++03.This allows: Doing the language change progressively. Now one could ever re-write those millions lines of code out there overnight.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 46. Architecture ChangesGCC is now implemented in C++03.This allows: Doing the language change progressively. Now one could ever re-write those millions lines of code out there overnight. Get better abstraction in a easier manner.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 47. Architecture ChangesGCC is now implemented in C++03.This allows: Doing the language change progressively. Now one could ever re-write those millions lines of code out there overnight. Get better abstraction in a easier manner. Strong typing implies more errors detected at compile time.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 48. Architecture ChangesGCC is now implemented in C++03.This allows: Doing the language change progressively. Now one could ever re-write those millions lines of code out there overnight. Get better abstraction in a easier manner. Strong typing implies more errors detected at compile time. And compile time of the compiler didn’t increase! Quite the opposite.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 49. Architecture ChangesGCC is now implemented in C++03.This allows: Doing the language change progressively. Now one could ever re-write those millions lines of code out there overnight. Get better abstraction in a easier manner. Strong typing implies more errors detected at compile time. And compile time of the compiler didn’t increase! Quite the opposite.A subset of C++ was chose, to avoid the Oil Refinery syndrome.Code review is still the better quality insurance tool.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 22/23
  • 50. 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, you!gcc-patches@gcc.gnu.org - Where to send patches. Yes, you again.Dodji Seketeli <dodji@redhat.com> GCC 4.8, State of the Onion 23/23