Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GCC: Optimizing Linux, the Internet, and Everything

#1
GCC: Optimizing Linux, the Internet, and Everything

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2018/10/gcc-optimizing-linux-the-internet-and-everything.jpg" width="1500" height="818" title="" alt="" /></div><div><div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2018/10/gcc-optimizing-linux-the-internet-and-everything.jpg" class="ff-og-image-inserted" /></div>
<p><em><span><span>The purpose of this paper is to provide developers a comprehensive overview of the GNU Compiler Collection (GCC), a suite of compilers that has been in use for over 30 years and is the core component of the GNU toolchain. This includes highlighting GCC’s main benefits to programmers, showcasing when and why GCC is a good choice for code development, and providing basic information about GCC 8.2, the most recent release of this popular tool. </span></span></em></p>
<p><span><span>One of the first decisions facing a developer when starting a coding project is which programming tools to utilize. The GNU Compiler Collection (GCC ) offers a robust and reliable suite of compilers that has been in use and under constant development for more than 30 years. The main goal of the GCC project is to develop and maintain a world-class optimizing compiler that is retargetable across multiple architectures and diverse environments. </span><span>GCC </span><span>is a free software, which guarantees end users the freedom to run, study, share, and modify software.  </span></span></p>
<p><span><span>According to LLVM.org, GCC is</span><span> “the de facto-standard open source compiler today, and it routinely compiles a huge volume of code.”</span><span> [1] GCC is the main compiler that builds the Linux kernel and is used for developing software for GNU/Linux systems as well as other systems that use Linux as the kernel. GCC also plays a major role in the development of software for embedded processors and is an enabling platform for the research and development of other programming tools and application software. GCC is a core component of the GNU toolchain, a collection of highly integrated programming tools produced by the GNU Project. GCC is distributed under the GNU General Public License (GPL), a copyleft license, which means that derivative work can only be distributed under the same license terms. GPL is intended to protect GCC and other GNU software from being made proprietary and requires that changes to code are made available freely and openly.</span></span></p>
<p><span><span>The original author of GCC is Richard Stallman, the founder of the GNU Project. The GNU Project was started in 1984 to create a Unix-like operating system as free software. Since every Unix operating system needs a C compiler, the GNU Project took on the task of developing a compiler from scratch. GCC was first released on March 22, 1987 and was considered a significant breakthrough since it was the first portable ANSI C optimizing compiler released as  free software. GCC is currently maintained by a community of programmers from all over the world under the direction of a steering committee that ensures broad, representative oversight of the project. GCC’s community approach is one of its strengths, resulting in a large and diverse community of developers and users that contribute to and provide support for the project. According to Open Hub, GCC “is one of the largest open-source teams in the world, and is in the top 2% of all project teams on Open Hub.”</span><span> [2]</span></span></p>
<p><span><span>Today GCC supports over 60 hardware platforms, including ARM (32-bit and 64-bit), Intel and AMD (32-bit and 64-bit), IBM POWER (32-bit and 64-bit), SPARC, HP PA-RISC, and IBMz (32-bit and 64-bit). GCC offers highly compliant C/C++ compilers and support for popular C libraries including the GNU C Library (glibc), newlib, musl-libc, and the C libraries included with various BSD operating systems. GCC also offers front-ends for Fortran, Ada, and GO languages and support for a variety of programming APIs including OpenMP and OpenAcc. GCC runs with popular operating environments, including Linux, Windows, macOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, Solaris, AIX, HPUX, and RTEMS. A key benefit of GCC is its tight integration with the other components of the GNU toolchain, including glibc, Binutils, and the GNU Debugger (GDB). GCC also functions as a cross compiler, providing the capability of creating executable code for a platform other than the one on which the compiler is running.  </span></span></p>
<h3><span><span>Optimizing Linux</span></span></h3>
<p><span><span>GCC is the default compiler for the Linux kernel source, providing developers with trusted, stable performance. For successful Linux kernel development C needs additional extensions that provide more precise control over  certain parameters. GCC supports these extensions, offering the capability of correctly building the Linux kernel. GCC is also a standard component of popular Linux distributions, such as Arch Linux, CentOS, Debian, Fedora, openSUSE, and  Ubuntu, where it routinely compiles supporting system components. This includes the default libraries used by Linux, such as libc, libm, libintl, libssh, libssl, libcrypto, libexpat, libpthread, and ncurses. These libraries depend on GCC to provide correctness and performance and are used by applications and system utilities to access Linux kernel features. GCC also builds the many application packages included with a distribution, such as Python, Perl, Ruby, nginx, Apache HTTP Server, OpenStack, Docker, and OpenShift. The combination of kernel, libraries, and application software translates into a large volume of code built with GCC for each Linux distribution. For example, for the openSUSE distribution nearly 100% of native code is built by GCC, including 6,135 source packages producing 5,705 shared libraries and 38,927 executables. This amounts to about 24,540 sources packages compiled weekly with GCC for openSUSE. </span><span>[3]</span></span></p>
<p><span><span>It should be noted that the version of GCC included in Linux distributions is not necessarily the latest version, but rather the version used to create the libraries that define the system Application Binary Interface (ABI). User space developers will need to download  the latest stable version of GCC to gain access to new features, performance optimizations, and improvements in usability. Many organizations, including Red Hat, SUSE, ARM, Linaro, and IBM, offer toolchains that include the latest version of GCC along with other GNU tools to help enhance developer productivity and improve deployment times. </span></span></p>
<h3><span><span>Optimizing the Internet</span></span></h3>
<p><span><span>GCC is a de facto standard embedded compiler, enabling the development of software for the growing world of Internet of Things (IoT). GCC offers a number of extensions that make it well suited for embedded systems software development, including fine-grained control using many command-line options, inline assembly, and compiler #pragmas that helps control the compiler behavior in greater detail. GCC supports a broad base of embedded platforms, including ARM, AMCC, RISC-V, and Freescale Power Architecture-based processors, and produces high quality code for these environment. GCC’s cross-compilation capability is a critical function to this community and prebuilt cross-compilation toolchains are often a major requirement. For example, the GNU ARM Embedded toolchains [4]</span><span> are integrated and validated packages featuring the Arm Embedded GCC compiler, libraries, and other tools necessary for bare-metal software development. These toolchains are available for cross-compilation on Windows, Linux and macOS host operating systems and target the popular ARM Cortex-R and Cortex-M processors, which have shipped in tens of billions of Internet-capable devices.</span><span> [5]</span></span></p>
<p><span><span>GCC is a reliable development platform for creating software applications that need to directly manage computing resources, including the open source database and web serving engines and backup and security software that are used to power the Cloud. GCC is compliant with C++11, C++14, and C++17 and will build object code from source code without using an intermediary to first build C code from C++ source, creating better object code with better debugging information. Some examples of applications that utilize GCC include: MySQL Database Management System, which requires GCC for Linux [6];</span><span> the Apache HTTP Server, which recommends using GCC [7];</span><span> and Bacula, an enterprise ready network backup tool which require GCC. [8]</span><span>  </span></span></p>
<p><span><span>For the research and development of the scientific codes used in High Performance Computing (HPC), GCC offers mature C, C++, and Fortran front ends as well as support for OpenMP and OpenACC APIs for directive-based parallel programming. Because GCC offers portability across computing environments, it enables code to be more easily targeted and tested across a variety of new and legacy client and server platforms. Code performance is an important parameter to this community and GCC offers a solid performance base. A November 2017 paper published by Colfax Research evaluates C++ compilers on an Intel platform for the speed of compiled code parallelized with OpenMP 4.x directives and for the speed of compilation time. The paper summarizes “the GNU compiler also does very well in our tests. G++ produces the second fastest code in three out of six cases and is amongst the fastest compiler in terms of compile time.”</span><span> [9] The proprietary Intel Compiler, which only supports Intel hardware, produced the fastest code in all six cases.</span></span></p>
<h3><span><span>Optimizing Everything</span></span></h3>
<p><span><span>Finally, GCC offers an attractive and robust environment for building development tools because of its free availability, retargetability, and continued development. An example of a popular tool developed with GCC is LLVM, a compiler infrastructure project initially started at the University of Illinois Urbana-Champaign in 2000. GCC provided the resources to bootstrap LLVM, was used for compiling LLVM until it was self-hosting, and is still used by LLVM for filling language and library gaps. In 2005 Apple formed a team to work on the LLVM system, making it an integral part of Apple’s development tools for macOS and iOS. Clang, a C language front end developed by Apple for LLVM, was d</span><span>esigned to be compatible with GCC 4.2.1, supporting compilation flags and unofficial language extension,</span><span> and utilizing the GCC tool chain. LLVM and Clang are distributed under a BSD license, which imposes minimal restrictions on the use and redistribution of code and is considered more friendly for corporations needing to protect IP. Unlike GPL, BSD does not protect code from being co-opted by other organizations. </span></span></p>
<p><span><span>The Clang project has generated a wealth of comparisons between GCC and Clang/LLVM mainly focused around performance, diagnostics, and licensing. A more comprehensive comparison is useful for developers who are evaluating these compilers.</span></span></p>
<ul>
<li>
<p><span><span>GCC supports a broader base of hardware and operating environments, which is key to application developers who are required to write software that supports a variety of new and legacy computing platforms. </span></span></p>
<ul>
<li>
<p><span><span>GCC supports over 60 hardware platforms and Linux, Windows, macOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, Solaris, AIX, HPUX, and RTEMS operating environments.</span></span></p>
</li>
<li>
<p><span><span>Clang provides stable support for Intel and AMD (x86 and AMD64), a limited number of ARM processors, and PowerPC (mainly 64) and Linux, NetBSD, FreeBSD, Butterfly BSD  and MacOS operating environments. [10]</span><span> </span></span></p>
</li>
</ul>
</li>
<li>
<p><span><span>For developers writing scientific applications, GCC offers compliant, optimized C, C++ and Fortran compilers that include support for OpenMP and OpenACC APIs. </span></span></p>
<ul>
<li>
<p><span><span>GCC has offered full support for OpenMP 4.0 for C, C++ and Fortran compilers since version 4.9.1 and full support for OpenMP 4.5 for C and C++ compilers since version 6.1. For OpenACC, GCC has </span><span>supported most of the 2.5 specification and performance optimizations since version 6.</span></span></p>
</li>
<li>
<p><span><span>Clang only supports C-like languages and offers limited OpenMP support, including OpenMP 3.1 support since version 3.8 and some feature support for OpenMP 4.0 and 4.5 since version 3.9. [11]</span><span> In terms of OpenACC, support is under development.</span></span></p>
</li>
</ul>
</li>
<li>
<p><span><span>GCC delivers cross compilation capabilities for a broad range of hardware and operating environments. This has resulted in many prebuilt cross compiler toolchains available that help streamline IoT development efforts for embedded systems developers.</span></span></p>
</li>
<li>
<p><span><span>The GNU ARM Embedded toolchains are</span><span> ready-to-use, open source suite of tools </span><span>based on GCC</span><span> for programming Arm Cortex-M and Cortex-R processor</span><span>s. The Bootlin web site provides access to 138 pre-compiled cross compiler toolchains based on GCC, binutils, and GDB for a variety of hardware platforms. [12]</span><span> </span></span></p>
</li>
<li>
<p><span><span>For Clang there are limited prebuilt toolchains such as the standalone Android NDK. Theoretically Clang could replace GCC in existing cross compiling toolchains, but developers will need to rebuild these toolchains to include Clang. [13]</span></span></p>
</li>
<li>
<p><span><span>GCC creates optimized, well performing code. In comparisons of current versions of GCC and Clang, GCC provided better performance over a range of benchmarks. </span></span></p>
<ul>
<li>
<p><span><span>The</span><span> <em>GCC 8/9 vs. LLVM Clang 6/7 Compiler Benchmarks On AMD EPYC</em></span><span> article provides results of 49 benchmarks ran across the four tested compilers at three optimization levels. Coming in first 34% of the time was GCC 8.2 RC1 using “-O3 -march=native” level, while at the same optimization level LLVM Clang 6.0 came in second with wins 20% of the time.</span><span> [14]</span></span></p>
</li>
<li>
<p><span><span>With OpenMP workloads, GCC outperformed Clang in the six reported cases </span><span>in a paper published by Colfax Research (referenced in footnote 9) and was also one of the fastest compilers in terms of compile time. </span></span></p>
</li>
</ul>
</li>
</ul>
<h3><span><span>GCC: Continuing to Optimize Linux, the Internet, and Everything</span></span></h3>
<p><span><span>GCC  continues to move forward as the world-class compiler that is optimized across multiple architectures and diverse environments. The most current version of GCC is 8.2, released in July 2018, added hardware support for upcoming Intel CPUs, more ARM CPUs and improved performance for AMD’s ZEN CPU. Initial C17 support has been added along with initial work towards C++2A. Diagnostics have continued to be enhanced including </span><span>better emitted diagnostics, with improved locations, location ranges, and fix-it hints, particularly in the C++ front end. </span></span></p>
<p><span><span>In </span><em><span>The State of Developer Ecosystem Survey in 2018</span></em><span><em> </em>by JetBrains, out of 6,000 developers who took the survey GCC  is regularly used by 66% of C++ programmers and 73% of C programmers</span><span>. New hardware platforms continue to rely on the GCC toolchain for software development, such as RISC-V, a free and open ISA that of interest to machine learning, Artifical Intelligence (AI), and IoT market segments. GCC continues to be a critical component in the continuing development of Linux systems. The Clear Linux Project for Intel Architecture, an emerging distribution built for cloud, client, and IoT use cases, provides a good example of how GCC compiler technology is being used and improved to boost the performance and security of a Linux-based system. GCC is also being used for application development for Microsoft’s Azure Sphere, a Linux-based operating system for IoT applications that initially supports the ARM based MediaTek MT3620 processor. In terms of developing the next generation of programmers, GCC is also a core component of the Windows toolchain for Raspberry PI, the low-cost embedded board running Debian-based GNU/Linux that is used to promote the teaching of basic computer science in schools and in developing countries. </span></span></p>
<p><strong>Notes</strong></p>
<p> 3. <span><span>Information provided by SUSE based on recent build statistics. There are other source packages in openSUSE that do not generate an executable image and these are not included in the counts.</span></span></p>
<p><em>Margaret Lewis is a technology consultant who previously served as Director of Software Planning at AMD and an Associate Director at the Maui High Performance Computing Center.  </em></p>
</div>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016