GNU Compiler Collection: Difference between revisions
Jump to navigation
Jump to search
imported>Citation bot Altered quote. Add: date, authors 1-1. | Use this bot. Report bugs. | Suggested by Jay8g | Category:CS1 errors: invisible characters | #UCB_Category 1/15 |
imported>Graham87 m 1 revision imported: import oldest edit from "GNU Compiler Collection" in the August 2001 database dump |
||
| Line 14: | Line 14: | ||
| discontinued = | | discontinued = | ||
| latest release version = {{wikidata|property|preferred|references|edit|Q178940|P348|P548=Q2804309}} | | latest release version = {{wikidata|property|preferred|references|edit|Q178940|P348|P548=Q2804309}} | ||
| latest release date = {{wikidata|qualifier|preferred|single|Q178940|P348|P548=Q2804309|P577}} | | latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|Q178940|P348|P548=Q2804309|P577}}}} | ||
| latest preview version = {{wikidata|property|preferred|references|edit|Q178940|P348|P548=Q51930650}} | | latest preview version = {{wikidata|property|preferred|references|edit|Q178940|P348|P548=Q51930650}} | ||
| latest preview date = {{wikidata|qualifier|preferred|single|Q178940|P348|P548=Q51930650|P577}} | | latest preview date = {{Start date and age|{{wikidata|qualifier|preferred|single|Q178940|P348|P548=Q51930650|P577}}}} | ||
| programming language = [[C (programming language)|C]], [[C++]]<ref>{{Cite web|title=GCC Coding Conventions - GNU Project|url=https://gcc.gnu.org/codingconventions.html|access-date=2022-02-07|website=gcc.gnu.org|archive-date=May 28, 2023|archive-url=https://web.archive.org/web/20230528012107/https://gcc.gnu.org/codingconventions.html|url-status=live}}</ref> | | programming language = [[C (programming language)|C]], [[C++]]<ref>{{Cite web|title=GCC Coding Conventions - GNU Project|url=https://gcc.gnu.org/codingconventions.html|access-date=2022-02-07|website=gcc.gnu.org|archive-date=May 28, 2023|archive-url=https://web.archive.org/web/20230528012107/https://gcc.gnu.org/codingconventions.html|url-status=live}}</ref> | ||
| operating system = [[Cross-platform]] | | operating system = [[Cross-platform]] | ||
| Line 28: | Line 28: | ||
}} | }} | ||
The '''GNU Compiler Collection''' ('''GCC''') is a collection of [[compiler]]s from the [[GNU Project]] that support various [[programming language]]s, [[Computer architecture|hardware architectures]], and [[operating system]]s. The [[Free Software Foundation]] (FSF) distributes GCC as [[free software]] under the [[GNU General Public License]] (GNU GPL). GCC is a key component of the [[GNU toolchain]] which is used for most projects related to [[GNU]] and the [[Linux kernel]]. With roughly 15 million lines of code in 2019, GCC is one of the largest free programs in existence.<ref name="loc"/> It has played an important role in the growth of [[free software]], as both a tool and an example. | The '''GNU Compiler Collection''' ('''GCC'''; formerly '''GNU C Compiler''') is a collection of [[compiler]]s from the [[GNU Project]] that support various [[programming language]]s, [[Computer architecture|hardware architectures]], and [[operating system]]s. The [[Free Software Foundation]] (FSF) distributes GCC as [[free software]] under the [[GNU General Public License]] (GNU GPL). GCC is a key component of the [[GNU toolchain]] which is used for most projects related to [[GNU]] and the [[Linux kernel]]. With roughly 15 million lines of code in 2019, GCC is one of the largest free programs in existence.<ref name="loc"/> It has played an important role in the growth of [[free software]], as both a tool and an example. | ||
When it was first released in 1987 by [[Richard Stallman]], GCC 1.0 was named the | When it was first released in 1987 by [[Richard Stallman]], GCC 1.0 was named the ''GNU C Compiler'' since it only handled the [[C (programming language)|C programming language]].<ref name="release-history" /> It was extended to compile [[C++]] in December of that year. [[Compiler#Front end|Front ends]] were later developed for [[Objective-C]], [[Objective-C++]], [[Fortran]], [[Ada (programming language)|Ada]], [[Go (programming language)|Go]], [[D (programming language)|D]], [[Modula-2]], [[Rust (programming language)|Rust]], [[COBOL]], and [[ALGOL 68]] among others.<ref name=":7">{{cite web |url=https://gcc.gnu.org/frontends.html |title=GCC Front Ends |publisher=GNU Project |access-date=February 13, 2026 |archive-date=February 13, 2026 |archive-url=https://web.archive.org/web/20260213025826/https://gcc.gnu.org/frontends.html |url-status=live}}</ref> The [[OpenMP]] and [[OpenACC]] specifications are also supported in the C and C++ compilers.<ref name="gcc6">{{Cite web|url=https://gcc.gnu.org/gcc-6/changes.html|title=GCC 6 Release Series — Changes, New Features, and Fixes - GNU Project|website=gcc.gnu.org|access-date=September 19, 2016|archive-date=September 22, 2016|archive-url=https://web.archive.org/web/20160922161533/http://gcc.gnu.org/gcc-6/changes.html|url-status=live}}</ref><ref name=":2">{{Cite web|url=https://gcc.gnu.org/wiki/OpenACC|title=OpenACC - GCC Wiki|website=gcc.gnu.org|access-date=September 19, 2016|archive-date=April 1, 2015|archive-url=https://web.archive.org/web/20150401174332/https://gcc.gnu.org/wiki/OpenACC|url-status=live}}</ref> | ||
As well as being the official compiler of the [[GNU operating system]], GCC has been adopted as the standard compiler by many other modern [[Unix-like]] computer [[operating system]]s, including most [[Linux]] distributions. Most [[Berkeley Software Distribution|BSD]] family operating systems also switched to GCC shortly after its release, although since then, [[FreeBSD]] and [[MacOS|Apple macOS]] have moved to the [[Clang]] compiler,<ref>{{Cite web|url=https://llvm.org/Users.html|title=The LLVM Compiler Infrastructure Project|website=llvm.org|access-date=September 24, 2021|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185909/https://llvm.org/Users.html|url-status=live}}</ref> largely due to licensing reasons.<ref>{{Cite web|title=Apple's GPLv3 purge|url=http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/|access-date=2021-01-12|website=meta.ath0.com|date=February 5, 2012|language=en-us|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185910/http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/|url-status=live}}</ref><ref>{{Cite web|last=Linnemann|first=Reid|date=June 20, 2012|title=Why Clang|url=https://lists.freebsd.org/pipermail/freebsd-questions/2012-June/242495.html|access-date=2021-01-12|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185910/https://lists.freebsd.org/pipermail/freebsd-questions/2012-June/242495.html|url-status=live}}</ref><ref>{{Cite web|date=2007-10-11|title=August 29, 2007: FreeBSD Foundation Newsletter, August 29, 2007|url=http://www.freebsdfoundation.org/press/2007Aug-newsletter.shtml#Letter|access-date=2021-01-12|archive-url=https://web.archive.org/web/20071011023649/http://www.freebsdfoundation.org/press/2007Aug-newsletter.shtml#Letter|archive-date=October 11, 2007}}</ref> GCC can also compile code for [[Windows]], [[Android (operating system)|Android]], [[iOS]], [[Solaris (operating system)|Solaris]], [[HP-UX]], [[IBM AIX|AIX]], and [[MS-DOS]] compatible operating systems.<ref>{{Cite web|title=Installing GCC: Binaries - GNU Project - Free Software Foundation (FSF)|url=https://gcc.gnu.org/install/binaries.html|access-date=2021-01-12|website=gcc.gnu.org|archive-date=January 5, 2021|archive-url=https://web.archive.org/web/20210105200706/https://gcc.gnu.org/install/binaries.html|url-status=live}}</ref> | As well as being the official compiler of the [[GNU operating system]], GCC has been adopted as the standard compiler by many other modern [[Unix-like]] computer [[operating system]]s, including most [[Linux]] distributions. Most [[Berkeley Software Distribution|BSD]] family operating systems also switched to GCC shortly after its release, although since then, [[FreeBSD]] and [[MacOS|Apple macOS]] have moved to the [[Clang]] compiler,<ref>{{Cite web|url=https://llvm.org/Users.html|title=The LLVM Compiler Infrastructure Project|website=llvm.org|access-date=September 24, 2021|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185909/https://llvm.org/Users.html|url-status=live}}</ref> largely due to licensing reasons.<ref>{{Cite web|title=Apple's GPLv3 purge|url=http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/|access-date=2021-01-12|website=meta.ath0.com|date=February 5, 2012|language=en-us|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185910/http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/|url-status=live}}</ref><ref>{{Cite web|last=Linnemann|first=Reid|date=June 20, 2012|title=Why Clang|url=https://lists.freebsd.org/pipermail/freebsd-questions/2012-June/242495.html|access-date=2021-01-12|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185910/https://lists.freebsd.org/pipermail/freebsd-questions/2012-June/242495.html|url-status=live}}</ref><ref>{{Cite web|date=2007-10-11|title=August 29, 2007: FreeBSD Foundation Newsletter, August 29, 2007|url=http://www.freebsdfoundation.org/press/2007Aug-newsletter.shtml#Letter|access-date=2021-01-12|archive-url=https://web.archive.org/web/20071011023649/http://www.freebsdfoundation.org/press/2007Aug-newsletter.shtml#Letter|archive-date=October 11, 2007}}</ref> GCC can also compile code for [[Windows]], [[Android (operating system)|Android]], [[iOS]], [[Solaris (operating system)|Solaris]], [[HP-UX]], [[IBM AIX|AIX]], and [[MS-DOS]] compatible operating systems.<ref>{{Cite web|title=Installing GCC: Binaries - GNU Project - Free Software Foundation (FSF)|url=https://gcc.gnu.org/install/binaries.html|access-date=2021-01-12|website=gcc.gnu.org|archive-date=January 5, 2021|archive-url=https://web.archive.org/web/20210105200706/https://gcc.gnu.org/install/binaries.html|url-status=live}}</ref> | ||
| Line 37: | Line 37: | ||
== History == | == History == | ||
In late 1983, in an effort to [[Bootstrapping (compilers)|bootstrap]] the [[GNU]] operating system, [[Richard Stallman]] asked [[Andrew S. Tanenbaum]], the author of the [[Amsterdam Compiler Kit]] (also known as the ''[[Vrije Universiteit Amsterdam|Free University]]'' ''Compiler Kit''), for permission to use that software for GNU. When Tanenbaum advised him that the compiler was not free, | In late 1983, in an effort to [[Bootstrapping (compilers)|bootstrap]] the [[GNU]] operating system, [[Richard Stallman]] asked [[Andrew S. Tanenbaum]], the author of the [[Amsterdam Compiler Kit]] (also known as the ''[[Vrije Universiteit Amsterdam|Free University]]'' ''Compiler Kit''), for permission to use that software for GNU. When Tanenbaum advised him that the compiler itself was not free, but rather only the university, Stallman decided to work on a different compiler.<ref>{{cite book |last=von Hagen |first=William |date=2006 |title=The Definitive Guide to GCC |edition=2nd |series=Definitive Guides |publisher=Apress |isbn=978-1-4302-0219-6 |page=XXVII |quote=So he wrote to VUCK's author asking if GNU could use it. Evidently, VUCK's developer was uncooperative, responding that the university was free but that the compiler was not. |url=https://books.google.com/books?id=wQ6r3UTivJgC |access-date=September 25, 2020 |archive-date=April 5, 2024 |archive-url=https://web.archive.org/web/20240405040135/https://books.google.com/books?id=wQ6r3UTivJgC |url-status=live }}</ref> His initial plan was to rewrite an existing compiler from [[Lawrence Livermore National Laboratory]] from [[Pastel (programming language)|Pastel]] in C with some help from [[Leonard H. Tower Jr.|Len Tower]] and others.<ref name=LLLCompiler>{{cite web | last = Stallman | first = Richard | title = About the GNU Project | publisher = The GNU Project | date = September 20, 2011 | url = https://www.gnu.org/gnu/thegnuproject.html | access-date = October 9, 2011 | archive-date = August 9, 2019 | archive-url = https://web.archive.org/web/20190809050636/http://www.gnu.org/gnu/thegnuproject.html | url-status = live }}</ref><ref>{{cite journal | editor-last = Puzo | editor-first = Jerome E. | title = Gnu's Zoo | journal = GNU's Bulletin | volume = 1 | issue = 1 | date = February 1986 | publisher = Free Software Foundation | url = https://www.gnu.org/bulletins/bull1.txt | access-date = 2007-08-11 | archive-date = June 23, 2015 | archive-url = https://web.archive.org/web/20150623180723/http://www.gnu.org/bulletins/bull1.txt | url-status = live }}</ref> Stallman wrote a new C front end for the Livermore compiler, but then realized that it required megabytes of stack space, an impossibility on a [[Motorola 68000|68000]] Unix system with only 64 KB, and concluded he would have to write a new compiler from scratch.<ref name=LLLCompiler /> None of the Pastel compiler code ended up in GCC, though Stallman did use the C front end he had written in Pastel.<ref name=LLLCompiler /><ref name=":6">{{cite book |last=von Hagen |first=William |date=2006 |title=The Definitive Guide to GCC |edition=2nd |series=Definitive Guides |publisher=Apress |isbn=978-1-4302-0219-6 |page=XXVII |url=https://books.google.com/books?id=wQ6r3UTivJgC |access-date=September 25, 2020 |archive-date=April 5, 2024 |archive-url=https://web.archive.org/web/20240405040135/https://books.google.com/books?id=wQ6r3UTivJgC |url-status=live }}</ref> | ||
GCC was first released March 22, 1987, available by [[File Transfer Protocol|FTP]] from [[Massachusetts Institute of Technology|MIT]].<ref>{{cite newsgroup | title = GNU C compiler beta test release | author = Richard M. Stallman (forwarded by Leonard H. Tower Jr.) | date = March 22, 1987 | newsgroup = comp.lang.c | url = https://groups.google.com/group/comp.lang.misc/msg/32eda22392c20f98 | access-date = October 9, 2011 | archive-date = June 2, 2013 | archive-url = https://web.archive.org/web/20130602041632/http://groups.google.com/group/comp.lang.misc/msg/32eda22392c20f98 | url-status = live }}</ref> Stallman was listed as the author but cited others for their contributions, including Tower for "parts of the parser, RTL generator, RTL definitions, and of the Vax machine description", Jack Davidson and [[Christopher W. Fraser]] for the idea of using [[Register transfer language|RTL]] as an intermediate language, and Paul Rubin for writing most of the preprocessor.<ref name=GccContributors>{{citation | last = Stallman | first = Richard M. | title = Using and Porting the GNU Compiler Collection (GCC) | chapter-url = https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_23.html | publisher = Free Software Foundation, Inc. | date = June 22, 2001 | orig-year = First published 1988 | chapter = Contributors to GNU CC | page = 7 | access-date = June 18, 2015 | postscript = . | archive-date = January 18, 2023 | archive-url = https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_23.html | url-status = live }}</ref> Described as the "first free software hit" by [[Peter H. Salus]], the GNU compiler arrived just at the time when [[Sun Microsystems]] was unbundling its development tools from [[SunOS|its operating system]], selling them separately at a higher combined price than the previous bundle, which led many of Sun's users to buy or download GCC instead of the vendor's tools.<ref name="penguin">{{cite book |first=Peter H. |last=Salus |author-link=Peter H. Salus |title=The Daemon, the Gnu and the Penguin |chapter=Chapter 10. SUN and gcc |chapter-url=http://www.groklaw.net/article.php?story=20050525231654621 |publisher=[[Groklaw]] |year=2005 |access-date=September 14, 2015 |archive-date=June 20, 2022 |archive-url=https://web.archive.org/web/20220620020435/http://www.groklaw.net/article.php?story=20050525231654621 |url-status=live }}</ref> While Stallman considered [[GNU Emacs]] as his main project, by 1990 GCC supported thirteen computer architectures, was outperforming several vendor compilers, and was used commercially by several companies.<ref>{{cite news|last=Garfinkel|first=Simson L.|author-link=Simson Garfinkel|date=6 August 1990|title=Get ready for GNU software|page=102|newspaper=Computerworld|url=https://books.google.com/books?id=mZ0kj6qvsvYC&pg=PT101|access-date=}}</ref> | GCC was first released March 22, 1987, available by [[File Transfer Protocol|FTP]] from [[Massachusetts Institute of Technology|MIT]].<ref>{{cite newsgroup | title = GNU C compiler beta test release | author = Richard M. Stallman (forwarded by Leonard H. Tower Jr.) | date = March 22, 1987 | newsgroup = comp.lang.c | url = https://groups.google.com/group/comp.lang.misc/msg/32eda22392c20f98 | access-date = October 9, 2011 | archive-date = June 2, 2013 | archive-url = https://web.archive.org/web/20130602041632/http://groups.google.com/group/comp.lang.misc/msg/32eda22392c20f98 | url-status = live }}</ref> Stallman was listed as the author but cited others for their contributions, including Tower for "parts of the parser, RTL generator, RTL definitions, and of the Vax machine description", Jack Davidson and [[Christopher W. Fraser]] for the idea of using [[Register transfer language|RTL]] as an intermediate language, and Paul Rubin for writing most of the preprocessor.<ref name=GccContributors>{{citation | last = Stallman | first = Richard M. | title = Using and Porting the GNU Compiler Collection (GCC) | chapter-url = https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_23.html | publisher = Free Software Foundation, Inc. | date = June 22, 2001 | orig-year = First published 1988 | chapter = Contributors to GNU CC | page = 7 | access-date = June 18, 2015 | postscript = . | archive-date = January 18, 2023 | archive-url = https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_23.html | url-status = live }}</ref> Described as the "first free software hit" by [[Peter H. Salus]], the GNU compiler arrived just at the time when [[Sun Microsystems]] was unbundling its development tools from [[SunOS|its operating system]], selling them separately at a higher combined price than the previous bundle, which led many of Sun's users to buy or download GCC instead of the vendor's tools.<ref name="penguin">{{cite book |first=Peter H. |last=Salus |author-link=Peter H. Salus |title=The Daemon, the Gnu and the Penguin |chapter=Chapter 10. SUN and gcc |chapter-url=http://www.groklaw.net/article.php?story=20050525231654621 |publisher=[[Groklaw]] |year=2005 |access-date=September 14, 2015 |archive-date=June 20, 2022 |archive-url=https://web.archive.org/web/20220620020435/http://www.groklaw.net/article.php?story=20050525231654621 |url-status=live }}</ref> While Stallman considered [[GNU Emacs]] as his main project, by 1990 GCC supported thirteen computer architectures, was outperforming several vendor compilers, and was used commercially by several companies.<ref>{{cite news|last=Garfinkel|first=Simson L.|author-link=Simson Garfinkel|date=6 August 1990|title=Get ready for GNU software|page=102|newspaper=Computerworld|url=https://books.google.com/books?id=mZ0kj6qvsvYC&pg=PT101|access-date=}}</ref> | ||
| Line 59: | Line 59: | ||
== Supported languages == | == Supported languages == | ||
{{As of|alt=As of the | {{As of|alt=As of the 16.1 release| 2023|04|post=,}} GCC includes front ends for [[C (programming language)|C]] (<code>gcc</code>), [[C++]] (<code>g++</code>), [[Objective-C]], [[Objective-C#Objective-C++|Objective-C++]], [[Fortran]] (<code>[[gfortran]]</code>), [[Ada (programming language)|Ada]] ([[GNAT]]), [[Go (programming language)|Go]] (<code>gccgo</code>), [[D (programming language)|D]] (<code>gdc</code>, since 9.1),<ref>{{cite web | url=https://gcc.gnu.org/gcc-9/changes.html#d | title=GCC 9 Release Series — Changes, New Features, and Fixes - GNU Project | access-date=May 7, 2019 | archive-date=February 19, 2022 | archive-url=https://web.archive.org/web/20220219120525/https://gcc.gnu.org/gcc-9/changes.html#d | url-status=live }}</ref><ref>{{Cite web|title=The D Language Front-End Finally Merged Into GCC 9 - Phoronix|url=https://phoronix.com/scan.php?page=news_item&px=GCC-9-Merges-D-Language|access-date=2021-01-19|website=phoronix.com|archive-date=May 17, 2022|archive-url=https://web.archive.org/web/20220517184343/https://www.phoronix.com/scan.php?page=news_item&px=GCC-9-Merges-D-Language|url-status=live}}</ref> [[Modula-2]] (<code>gm2</code>, since 13.1),<ref>{{cite web | url=https://gcc.gnu.org/gcc-13/changes.html#modula2 | title=GCC 13 Release Series — Changes, New Features, and Fixes - GNU Project | access-date=June 23, 2023 | archive-date=May 26, 2023 | archive-url=https://web.archive.org/web/20230526084642/http://gcc.gnu.org/gcc-13/changes.html#modula2 | url-status=live }}</ref><ref>{{Cite web |url=https://www.theregister.com/2022/12/16/gcc_13_will_support_modula2/ |title=GCC 13 to support Modula-2: Follow-up to Pascal lives on in FOSS form |date=2022-12-16 |access-date=2022-12-19 |last=Proven |first=Liam |archive-date=December 19, 2022 |archive-url=https://web.archive.org/web/20221219080641/https://www.theregister.com/2022/12/16/gcc_13_will_support_modula2/ |url-status=live }}</ref> [[Rust (programming language)|Rust]] (<code>gccrs</code>, since 15.1), [[COBOL]] (<code>gcobol</code>, since 15.1), and [[ALGOL 68]] (<code>ga68</code>, since 16.1) programming languages,<ref name=":7" /> with the [[OpenMP]] and [[OpenACC]] parallel language extensions being supported since GCC 5.1.<ref name=":2" /><ref>{{Cite web|url=https://gcc.gnu.org/gcc-5/changes.html|title=GCC 5 Release Series — Changes, New Features, and Fixes - GNU Project|website=gcc.gnu.org|access-date=April 23, 2015|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/gcc-5/changes.html|url-status=live}}</ref> Versions prior to GCC 7 also supported [[Java (programming language)|Java]] (<code>[[GNU Compiler for Java|gcj]]</code>), allowing compilation of Java to native machine code.<ref>{{cite web|title=GCC 7 Release Series|url=https://gcc.gnu.org/gcc-7/changes.html#java|access-date=March 20, 2018|publisher=gnu.org|archive-date=September 2, 2020|archive-url=https://web.archive.org/web/20200902223230/https://gcc.gnu.org/gcc-7/changes.html#java|url-status=live}}</ref> | ||
Third-party front ends exist for many languages, such as | Third-party front ends exist for many languages, such as [[Pascal (programming language)|Pascal]] (<code>[[GNU Pascal|gpc]]</code>), [[Mercury (programming language)|Mercury]], [[Modula-3]], [[VHDL]] (<code>GHDL</code>) and [[PL/I]].<ref name=":7" /> A few experimental branches exist to support additional languages, such as the GCC [[Unified Parallel C|UPC]] compiler for [[Unified Parallel C]].<ref>{{cite web|url=http://www.gccupc.org/|title=GCC UPC (GCC Unified Parallel C)|publisher=Intrepid Technology, Inc.|date=2006-02-20|access-date=2009-03-11|archive-date=February 11, 2010|archive-url=https://web.archive.org/web/20100211142352/http://www.gccupc.org/|url-status=dead}}</ref><ref>{{Cite web|last=Spengler|first=Brad|date=12 January 2021|title=Open Source Security, Inc. Announces Funding of GCC Front-End for Rust|url=https://opensrcsec.com/open_source_security_announces_rust_gcc_funding|access-date=|website=|archive-date=April 25, 2021|archive-url=https://web.archive.org/web/20210425170408/https://opensrcsec.com/open_source_security_announces_rust_gcc_funding|url-status=live}}</ref>{{Better source needed|date=January 2021}} | ||
The default target for C++ since GCC 15.1 is ''gnu++20'', a superset of [[C++20]], and the default target for C since GCC 15 is ''gnu23'', a superset of [[C23 (C standard revision)|C23]], with strict standard support also available. GCC also provides experimental support for [[C (programming language)#C2Y|C2Y]], [[C++23]], and [[C++26]].<ref>{{Cite web|title=C++ Standards Support in GCC|url=https://gcc.gnu.org/projects/cxx-status.html|access-date=May 17, 2021|archive-date=April 20, 2022|archive-url=https://web.archive.org/web/20220420114133/https://gcc.gnu.org/projects/cxx-status.html|url-status=live}}</ref> GCC 16.1 was released on 30 April 2026.{{refn|name="phoronix"|[https://www.phoronix.com/news/GCC-16.1-Released GCC 16.1 Released With AMD Zen 6 Support, Algol 68 & Many C++ Improvements], Michael Larabel. phoronix.com. 30 April 2026. Retrieved 30 April 2026.}}{{refn|name="gcc 16.1 released"|[https://gcc.gnu.org/gcc-16/ GCC 16 Release Series], gcc.gnu.org. 30 April 2026. Retrieved 30 April 2026.}} | |||
== Design == | == Design == | ||
| Line 99: | Line 99: | ||
The middle stage of GCC does all of the code analysis and [[optimizing compiler|optimization]], working independently of both the compiled language and the target architecture, starting from the GENERIC<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html|title=GENERIC (GNU Compiler Collection (GCC) Internals)|website=gcc.gnu.org|access-date=July 25, 2016|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html|url-status=live}}</ref> representation and expanding it to [[register transfer language]] (RTL). The GENERIC representation contains only the subset of the imperative [[computer programming|programming]] constructs optimized by the middle end. | The middle stage of GCC does all of the code analysis and [[optimizing compiler|optimization]], working independently of both the compiled language and the target architecture, starting from the GENERIC<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html|title=GENERIC (GNU Compiler Collection (GCC) Internals)|website=gcc.gnu.org|access-date=July 25, 2016|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gccint/GENERIC.html|url-status=live}}</ref> representation and expanding it to [[register transfer language]] (RTL). The GENERIC representation contains only the subset of the imperative [[computer programming|programming]] constructs optimized by the middle end. | ||
In transforming the source code to GIMPLE,<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html|title=GIMPLE (GNU Compiler Collection (GCC) Internals)|website=gcc.gnu.org|access-date=July 25, 2016|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html|url-status=live}}</ref> complex [[Expression (programming)|expressions]] are split into a [[three-address code]] using [[temporary variable]]s. This representation was inspired by the SIMPLE representation proposed in the McCAT compiler<ref>{{cite web |url=http://www-acaps.cs.mcgill.ca/info/McCAT/McCAT.html |title=McCAT |access-date=2017-09-14 |url-status= | In transforming the source code to GIMPLE,<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html|title=GIMPLE (GNU Compiler Collection (GCC) Internals)|website=gcc.gnu.org|access-date=July 25, 2016|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html|url-status=live}}</ref> complex [[Expression (programming)|expressions]] are split into a [[three-address code]] using [[temporary variable]]s. This representation was inspired by the SIMPLE representation proposed in the McCAT compiler<ref>{{cite web |url=http://www-acaps.cs.mcgill.ca/info/McCAT/McCAT.html |title=McCAT |access-date=2017-09-14 |url-status=dead|archive-url=https://web.archive.org/web/20040812030043/http://www-acaps.cs.mcgill.ca/info/McCAT/McCAT.html |archive-date=August 12, 2004 |df=mdy-all }}</ref> by Laurie J. Hendren<ref>{{Cite web|url=http://www.sable.mcgill.ca/~hendren/|title=Laurie Hendren's Home Page|website=www.sable.mcgill.ca|access-date=July 20, 2009|archive-date=September 27, 2022|archive-url=https://web.archive.org/web/20220927074148/http://www.sable.mcgill.ca/~hendren/|url-status=live}}</ref> for simplifying the analysis and [[Optimization (computer science)|optimization]] of [[Imperative programming|imperative programs]]. | ||
=== Optimization === | === Optimization === | ||
| Line 109: | Line 109: | ||
=== C++ Standard Library (libstdc++) === | === C++ Standard Library (libstdc++) === | ||
The GCC project includes an implementation of the [[C++ Standard Library]] called libstdc++,<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/libstdc++|title=The GNU C++ Library|publisher=GNU Project|accessdate=2021-02-21|archive-date=December 25, 2022|archive-url=https://web.archive.org/web/20221225041607/https://gcc.gnu.org/onlinedocs/libstdc++/|url-status=live}}</ref> licensed under the GPLv3 License with an exception to link non-GPL applications when sources are built with GCC.<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html|title=License|publisher=GNU Project|accessdate=2021-02-21|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html|url-status=live}}</ref> | The GCC project includes an implementation of the [[C++ Standard Library]] called libstdc++,<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/libstdc++|title=The GNU C++ Library|publisher=GNU Project|accessdate=2021-02-21|archive-date=December 25, 2022|archive-url=https://web.archive.org/web/20221225041607/https://gcc.gnu.org/onlinedocs/libstdc++/|url-status=live}}</ref> licensed under the GPLv3 License with an exception to link non-GPL-compatible applications when sources are built with GCC.<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html|title=License|publisher=GNU Project|accessdate=2021-02-21|archive-date=January 18, 2023|archive-url=https://web.archive.org/web/20230118185814/https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html|url-status=live}}</ref> Since GCC Version 3, the C++ ABI is based on the ABI published by Intel for the Itanium C++ ABI.<ref>{{Cite web |title=ABI Policy and Guidelines |url=https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html |access-date=2025-11-11 |website=gcc.gnu.org}}</ref> | ||
=== Other features === | === Other features === | ||
| Line 119: | Line 119: | ||
: [[Plug-in (computing)|Plugins]] extend the GCC compiler directly.<ref>{{cite web |title= Plugins |url= https://gcc.gnu.org/onlinedocs/gccint/Plugins.html |work= GCC online documentation |access-date= July 8, 2013 |archive-date= April 30, 2013 |archive-url= https://web.archive.org/web/20130430223330/http://gcc.gnu.org/onlinedocs/gccint/Plugins.html |url-status= live }}</ref> Plugins allow a stock compiler to be tailored to specific needs by external code loaded as plugins. For example, plugins can add, replace, or even remove middle-end passes operating on ''Gimple'' representations.<ref>{{cite web|last=Starynkevitch|first=Basile|title=GCC plugins thru the MELT example|url=http://gcc-melt.org/gcc-plugin-MELT-LinuxCollabSummit2014.pdf |archive-url=https://web.archive.org/web/20140413124801/http://gcc-melt.org/gcc-plugin-MELT-LinuxCollabSummit2014.pdf |archive-date=2014-04-13 |url-status=live|access-date=2014-04-10}}</ref> Several GCC plugins have already been published, notably: | : [[Plug-in (computing)|Plugins]] extend the GCC compiler directly.<ref>{{cite web |title= Plugins |url= https://gcc.gnu.org/onlinedocs/gccint/Plugins.html |work= GCC online documentation |access-date= July 8, 2013 |archive-date= April 30, 2013 |archive-url= https://web.archive.org/web/20130430223330/http://gcc.gnu.org/onlinedocs/gccint/Plugins.html |url-status= live }}</ref> Plugins allow a stock compiler to be tailored to specific needs by external code loaded as plugins. For example, plugins can add, replace, or even remove middle-end passes operating on ''Gimple'' representations.<ref>{{cite web|last=Starynkevitch|first=Basile|title=GCC plugins thru the MELT example|url=http://gcc-melt.org/gcc-plugin-MELT-LinuxCollabSummit2014.pdf |archive-url=https://web.archive.org/web/20140413124801/http://gcc-melt.org/gcc-plugin-MELT-LinuxCollabSummit2014.pdf |archive-date=2014-04-13 |url-status=live|access-date=2014-04-10}}</ref> Several GCC plugins have already been published, notably: | ||
:* The Python plugin, which links against libpython, and allows one to invoke arbitrary Python scripts from inside the compiler. The aim is to allow GCC plugins to be written in Python. | :* The Python plugin, which links against libpython, and allows one to invoke arbitrary Python scripts from inside the compiler. The aim is to allow GCC plugins to be written in Python. | ||
:* The MELT plugin provides a high-level [[Lisp (programming language)|Lisp]]-like language to extend GCC.<ref>{{cite web|title=About GCC MELT|url=http://gcc-melt.org/|access-date=July 8, 2013|archive-url= https://archive. | :* The MELT plugin provides a high-level [[Lisp (programming language)|Lisp]]-like language to extend GCC.<ref>{{cite web|title=About GCC MELT|url=http://gcc-melt.org/|access-date=July 8, 2013|archive-url= https://web.archive.org/web/20130925194354if_/http://gcc-melt.org/|archive-date=2013-09-25|url-status=usurped}}</ref> | ||
: The support of plugins was once a contentious issue in 2007.<ref>{{cite web |last1=Corbet |first1=Jonathan |title=GCC unplugged [LWN.net] |url=https://lwn.net/Articles/259157/ |website=lwn.net |date=November 19, 2007 |access-date=March 28, 2021 |archive-date=November 9, 2020 |archive-url=https://web.archive.org/web/20201109001410/https://lwn.net/Articles/259157/ |url-status=live }}</ref> | : The support of plugins was once a contentious issue in 2007.<ref>{{cite web |last1=Corbet |first1=Jonathan |title=GCC unplugged [LWN.net] |url=https://lwn.net/Articles/259157/ |website=lwn.net |date=November 19, 2007 |access-date=March 28, 2021 |archive-date=November 9, 2020 |archive-url=https://web.archive.org/web/20201109001410/https://lwn.net/Articles/259157/ |url-status=live }}</ref> | ||
; C++ [[Software transactional memory|transactional memory]] | ; C++ [[Software transactional memory|transactional memory]] | ||
| Line 253: | Line 253: | ||
GCC is licensed under the [[GNU General Public License]] version 3.<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gcc/Copying.html#Copying|title=Using the GNU Compiler Collection|website=gnu.org|access-date=2019-11-05|archive-date=November 16, 2023|archive-url=https://web.archive.org/web/20231116021350/https://gcc.gnu.org/onlinedocs/gcc/Copying.html#Copying|url-status=live}}</ref> The ''GCC runtime exception'' permits compilation of proprietary programs (in addition to free software) with GCC headers and runtime libraries. This does not impact the license terms of GCC source code.<ref>{{cite web|publisher=FSF|title=GCC Runtime Exception|url=https://www.gnu.org/licenses/gcc-exception|access-date=2014-04-10|archive-date=April 16, 2014|archive-url=https://web.archive.org/web/20140416192813/https://www.gnu.org/licenses/gcc-exception|url-status=live}}</ref> | GCC is licensed under the [[GNU General Public License]] version 3.<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gcc/Copying.html#Copying|title=Using the GNU Compiler Collection|website=gnu.org|access-date=2019-11-05|archive-date=November 16, 2023|archive-url=https://web.archive.org/web/20231116021350/https://gcc.gnu.org/onlinedocs/gcc/Copying.html#Copying|url-status=live}}</ref> The ''GCC runtime exception'' permits compilation of proprietary programs (in addition to free software) with GCC headers and runtime libraries. This does not impact the license terms of GCC source code.<ref>{{cite web|publisher=FSF|title=GCC Runtime Exception|url=https://www.gnu.org/licenses/gcc-exception|access-date=2014-04-10|archive-date=April 16, 2014|archive-url=https://web.archive.org/web/20140416192813/https://www.gnu.org/licenses/gcc-exception|url-status=live}}</ref> | ||
However this exception is limited. | However this exception is limited. For example, when non-[[GNU General Public License|GPL]]-compatible software is used together with GCC within the [[Compiler|Compile Process]], following the [[GNU General Public License|GPLv3]] for all of the propagated object code GCC generates, becomes mandatory as it is derived from the [[GNU General Public License|GPL]]-licensed libraries.<ref>{{Cite web |title=GCC Runtime Library Exception Rationale and FAQ - GNU Project - Free Software Foundation |url=https://www.gnu.org/licenses/gcc-exception-3.1-faq.html |archive-url=https://web.archive.org/web/20250725141736/https://www.gnu.org/licenses/gcc-exception-3.1-faq.html |archive-date=2025-07-25 |access-date=2025-07-31 |website=www.gnu.org |publisher=[[Free Software Foundation]] |at=Section "How the Exception Works" |language=en |quote=How the Exception Works (...) You have permission to propagate a work of Target Code formed by combining the Runtime Library with Independent Modules, even if such propagation would otherwise violate the terms of GPLv3, provided that all Target Code was generated by Eligible Compilation Processes. You may then convey such a combination under terms of your choice, consistent with the licensing of the Independent Modules. (...) However, if you used GCC in conjunction with GPL-incompatible software during the process of transforming high-level code to low-level code, that would not be an Eligible Compilation Process. This would happen if, for example, you used GCC with a proprietary plugin. (...) As long as you use an Eligible Compilation Process, then you have permission to take the Target Code that GCC generates and propagate it “under terms of your choice.” If you did use GPL-incompatible software in conjunction with GCC during the Compilation Process, you would not be able to take advantage of this permission. Since all of the object code that GCC generates is derived from these GPLed libraries, that means you would be required to follow the terms of the GPL when propagating any of that object code. You could not use GCC to develop your own GPL-incompatible software.}}</ref> | ||
== See also == | == See also == | ||
| Line 280: | Line 280: | ||
=== Other === | === Other === | ||
* [ | * [https://www.cse.iitb.ac.in/grc/ Collection of GCC 4.0.2 architecture and internals documents] at I.I.T. Bombay | ||
* {{cite news |date=March 2, 2006 |title=New GCC Heavy on Optimization |publisher= internetnews.com |last= Kerner |first=Sean Michael |url = | * {{cite news |date=March 2, 2006 |title=New GCC Heavy on Optimization |publisher= internetnews.com |last= Kerner |first=Sean Michael |url = https://www.internetnews.com/dev-news/article.php/3588926 |postscript=none}} | ||
* {{cite news |date=April 22, 2005 |title=Open Source GCC 4.0: Older, Faster |publisher=internetnews.com |last=Kerner |first=Sean Michael |url= | * {{cite news |date=April 22, 2005 |title=Open Source GCC 4.0: Older, Faster |publisher=internetnews.com |last=Kerner |first=Sean Michael |url=https://www.internetnews.com/dev-news/article.php/3499881 |postscript=none |access-date=October 21, 2006 |archive-date=September 17, 2006 |archive-url=https://web.archive.org/web/20060917233745/https://www.internetnews.com/dev-news/article.php/3499881 |url-status=dead }} | ||
* [https://web.archive.org/web/20090401215553/ | * [https://web.archive.org/web/20090401215553/https://www.redhat.com/magazine/002dec04/features/gcc/ From Source to Binary: The Inner Workings of GCC], by Diego Novillo, ''[[Red Hat#Opensource.com|Red Hat Magazine]]'', December 2004 | ||
* [ | * [https://gcc.gnu.org/pub/gcc/summit/2003/GENERIC%20and%20GIMPLE.pdf A 2003 paper on GENERIC and GIMPLE] | ||
* [https://web.archive.org/web/20171022105307/ | * [https://web.archive.org/web/20171022105307/https://www.toad.com/gnu/cygnus/index.html Marketing Cygnus Support], an essay covering GCC development for the 1990s, with 30 monthly reports for in the "Inside Cygnus Engineering" section near the end | ||
* [ | * [https://oldhome.schmorp.de/egcs.html EGCS 1.0 announcement] | ||
* [https://gcc.gnu.org/egcs-1.0/features.html EGCS 1.0 features list] | * [https://gcc.gnu.org/egcs-1.0/features.html EGCS 1.0 features list] | ||
* [ | * [https://linuxmafia.com/faq/Licensing_and_Law/forking.html Fear of Forking], an essay by Rick Moen recording seven well-known forks, including the GCC/EGCS one | ||
{{GNU}} | {{GNU}} | ||