Glibc Explained

GNU C Library
Logo Size:100px
Author:Roland McGrath
Developer:GNU Project, most contributions by Ulrich Drepper
Released:[1]
Programming Language:C
Operating System:Unix-like
Genre:Runtime library
License:2001: LGPL-2.1-or-later
1992: LGPL-2.0-or-later

The GNU C Library, commonly known as glibc, is the GNU Project implementation of the C standard library. It is a wrapper around the system calls of the Linux kernel for application use. Despite its name, it now also directly supports C++ (and, indirectly, other programming languages). It was started in the 1980s by the Free Software Foundation (FSF) for the GNU operating system.

glibc is free software released under the GNU Lesser General Public License. The GNU C Library project provides the core libraries for the GNU system, as well as many systems that use Linux as the kernel. These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD, OS-specific APIs and more. These APIs include such foundational facilities as open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt, login, exit and more.

History

Version Date Highlights
0.1 – 0.6 October 1991 – February 1992
1.0 February 1992
1.01 – 1.09.3 March 1992 – December 1994
1.90 – 1.102 May 1996 – January 1997
2.0 January 1997
2.0.1 January 1997
2.0.2 February 1997
2.0.91 December 1997
2.0.95 July 1998
2.1 February 1999
2.1.1 March 1999
2.2 November 2000
2.2.1 January 2001
2.2.2 February 2001
2.2.3 March 2001
2.2.4 July 2001
2.3 October 2002
2.3.1 October 2002
2.3.2 February 2003
2.3.3 December 2003
2.3.4 December 2004 Minimum for Linux Standard Base (LSB) 3.0
2.3.5 April 2005
2.3.6 November 2005
2.4 March 2006 Minimum for LSB 4.0, initial inotify support
2.5 September 2006 Full inotify support. RHEL5 end of support was
2.6 May 2007
2.7 October 2007
2.8 April 2008
2.9 November 2008
2.10 May 2009 Minimum for LSB 5.0. Initial psiginfo support.
2.11 October 2009 SLES11 reached end of long-term support in March 2022.
2.12 May 2010
2.13 January 2011
2.14 June 2011
2.15 March 2012
2.16 June 2012
2.17 December 2012 64-bit ARM support
2.18 August 2013 Improved C++11 support. Support for Intel TSX lock elision. Support for the Xilinx MicroBlaze and IBM POWER8 microarchitectures.
2.19 February 2014 SystemTap probes for malloc. GNU Indirect Function (IFUNC) support for ppc32 and ppc64. New feature test macro _DEFAULT_SOURCE to replace _SVID_SOURCE and _BSD_SOURCE. Preliminary safety documentation for all functions in the manual. ABI change in ucontext and jmp_buf for s390/s390x.
2.20 September 2014 Support for file description locks
2.21 February 2015 New semaphore implementation
2.22 August 2015 Support to enable Google Native Client (NaCl), that originally ran on x86, running on ARMv7-A, Unicode 7.0
2.23 February 2016 Unicode 8.0
2.24 August 2016 Some deprecated features have been removed
2.25 February 2017 The getentropy and getrandom functions, and the <sys/random.h> header file have been added.
2.26 August 2017 Improved performance (per-thread cache for malloc), Unicode 10 support
2.27 February 2018 Performance optimizations. RISC-V support.
2.28 August 2018 statx, renameat2, Unicode 11.0.0
2.29 February 2019
  • getcpu wrapper
  • build and install all locales as directories with files
  • optimized trigonomical functions
  • Transactional Lock Elision for powercp64le ABI
  • posix_spawn_file_actions_addchdir_np and posix_spawn_file_actions_addfchdir_np
  • popen and system do not run atfork handlers anymore
  • support for the C-SKY ABIV2 running on Linux
  • strftime's default formatting of a locale's alternative year; the '_' and '-' flags can now be applied to its "%EY"[2]
2.30 August 2019 Unicode 12.1.0, the dynamic linker accepts the --preload argument to preload shared objects, the gettid function has been added on Linux, Minguo (Republic of China) calendar support, new Japanese era added to ja_JP locale, memory allocation functions fail with total object size larger than PTRDIFF_MAX; fixed[3]
2.31 February 2020 Initial C23 standard support
2.32 August 2020 Unicode 13.0, 'access' attribute for better warnings in GCC 10, i.e. to "help detect buffer overflows and other out-of-bounds accesses"[4]
2.33 February 2021 HWCAPS
2.34 August 2021 libpthread, libdl, libutil, libanl has been integrated into libc.
2.35 February 2022 Unicode 14.0, C.UTF-8 locale, restartable sequences. Removed Intel MPX support.
2.36 August 2022
2.37 February 2023
2.38 August 2023 The strlcpy and strlcat functions added. libmvec support for ARM64.
2.39 January 2024 The stdbit.h header has been added from ISO C2X. Support for shadow stacks on x86_64, new security features, and the removal of libcrypt.
2.40 July 2024 Partial support for the ISO C23 standard, a new tunable for the testing of programs, improved 64-bit ARM vector support.

The glibc project was initially written mostly by Roland McGrath, working for the Free Software Foundation (FSF) in the summer of 1987 as a teenager.[5] [6] In February 1988, FSF described glibc as having nearly completed the functionality required by ANSI C.[7] By 1992, it had the ANSI C-1989 and POSIX.1-1990 functions implemented and work was under way on POSIX.2.[8] In September 1995 Ulrich Drepper made his first contribution to the glibc and by 1997 most commits were made by him. Drepper held the maintainership position for many years and until 2012 accumulated 63% of all commits to the project.[9]

In May 2009 glibc was migrated to a Git repository.

In 2010, a licensing issue was resolved which was caused by the Sun RPC implementation in glibc that was not GPL compatible. It was fixed by re-licensing the Sun RPC components under the BSD license.[10] [11]

In 2014, glibc suffered from an ABI breakage bug on s390.[12]

In July 2017, 30 years after he started glibc, Roland McGrath announced his departure, "declaring myself maintainer emeritus and withdrawing from direct involvement in the project. These past several months, if not the last few years, have proven that you don't need me anymore".

In 2018, maintainer Raymond Nicholson removed a joke about abortion from the glibc source code. It was restored later by Alexandre Oliva after Richard Stallman demanded to have it returned.[13]

In 2021, the copyright assignment requirement to the Free Software Foundation was removed from the project.[14]

Fork and variant

In 1994, the developers of the Linux kernel forked glibc. Their fork, "Linux libc", was maintained separately until around 1998. Because the copyright attribution was insufficient, changes could not be merged back to the GNU Libc.[15] When the FSF released glibc 2.0 in January 1997, the kernel developers discontinued Linux libc due to glibc 2.0's superior compliance with POSIX standards.[16] glibc 2.0 also had better internationalisation and more in-depth translation, IPv6 capability, 64-bit data access, facilities for multithreaded applications, future version compatibility, and the code was more portable.[17] The last-used version of Linux libc used the internal name (soname) . Following on from this, glibc 2.x on Linux uses the soname [18]

In 2009, Debian and a number of derivatives switched from glibc to the variant eglibc.[19] Eglibc was supported by a consortium consisting of Freescale, MIPS, MontaVista and Wind River.[20] It contained changes that made it more suitable for embedded usage and had added support for architectures that were not supported by glibc, such as the PowerPC e500. The code of eglibc was merged back into glibc at version 2.20.[21] Since 2014, eglibc is discontinued. The Yocto Project and Debian also moved back to glibc since the release of Debian Jessie.[22]

Steering committee

Starting in 2001 the library's development had been overseen by a committee,[23] with Ulrich Drepper[24] kept as the lead contributor and maintainer. The steering committee installation was surrounded by a public controversy, as it was openly described by Ulrich Drepper as a failed hostile takeover maneuver by Richard Stallman.[25] [26] [27] [28]

In March 2012, the steering committee voted to disband itself and remove Drepper in favor of a community-driven development process, with Ryan Arnold, Maxim Kuvyrkov, Joseph Myers, Carlos O'Donell, and Alexandre Oliva holding the responsibility of GNU maintainership (but no extra decision-making power).[29] [30] [31]

Functionality

glibc provides the functionality required by the Single UNIX Specification, POSIX (1c, 1d, and 1j) and some of the functionality required by ISO C11, ISO C99, Berkeley Unix (BSD) interfaces, the System V Interface Definition (SVID) and the X/Open Portability Guide (XPG), Issue 4.2, with all extensions common to XSI (X/Open System Interface) compliant systems along with all X/Open UNIX extensions.

In addition, glibc also provides extensions that have been deemed useful or necessary while developing GNU.

Supported hardware and kernels

glibc is used in systems that run many different kernels and different hardware architectures. Its most common use is in systems using the Linux kernel on x86 hardware, however, officially supported hardware[32] includes: ARM, ARC, C-SKY, DEC Alpha, IA-64, Motorola m68k, MicroBlaze, MIPS, Nios II, PA-RISC, PowerPC, RISC-V, s390, SPARC, and x86 (old versions support TILE). It officially supports the Hurd and Linux kernels. Additionally, there are heavily patched versions that run on the kernels of FreeBSD and NetBSD (from which Debian GNU/kFreeBSD and Debian GNU/NetBSD systems are built, respectively), as well as a forked-version of OpenSolaris.[33] It is also used (in an edited form) and named in BeOS and Haiku.[34]

Use in small devices

glibc has been criticized as being "bloated" and slower than other libraries in the past, e.g. by Linus Torvalds[35] and embedded Linux programmers. For this reason, several alternative C standard libraries have been created which emphasize a smaller footprint. However, many small-device projects use GNU libc over the smaller alternatives because of its application support, standards compliance, and completeness. Examples include Openmoko[36] and Familiar Linux for iPaq handhelds (when using the GPE display software).[37]

Secure string functions

glibc does not implement bounds-checking interfaces defined in C11 and did not implement strlcpy and strlcat[38] [39] until 2023 on the grounds that "in practice these functions can cause trouble, as their intended use encourages silent data truncation, adds complexity and inefficiency, and does not prevent all buffer overruns in the destinations."[40] The FAQ pointed out that the bounds-checking interfaces were optional in the ISO standard and that snprintf was available as an alternative.

Compatibility layers

There are compatibility layers ("shims") to allow programs written for other ecosystems to run on glibc interface offering systems. These include libhybris, a compatibility layer for Android's Bionic, and Wine, which can be seen as a compatibility layer from Windows APIs to glibc and other native APIs available on Unix-like systems.

See also

Notes and References

  1. Web site: A turning point for GNU libc . Corbet . Jonathan . 28 March 2012 . LWN.net . 5 April 2012 . 23 April 2016 . https://web.archive.org/web/20160423100007/https://lwn.net/Articles/488847/ . live .
  2. Web site: sourceware.org Git – glibc.git/blob – NEWS . 26 April 2019 . 21 March 2022 . https://web.archive.org/web/20220321041644/https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;hb=de44ab67aa4eec369deea828733567c35a0611c0 . live .
  3. Web site: sourceware.org Git – glibc.git/blob – NEWS . 26 April 2019 . 26 September 2019 . https://web.archive.org/web/20190926020352/https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;hb=HEAD . live .
  4. Web site: The GNU C Library version 2.32 is now available. 2020-08-13. sourceware.org. 28 September 2020. https://web.archive.org/web/20200928195441/https://sourceware.org/pipermail/libc-announce/2020/000029.html. live.
  5. Web site: Roland McGrath bows out as glibc maintainer [LWN.net]]. 2017-07-07. lwn.net. 2017-07-08. 1 August 2020. https://web.archive.org/web/20200801031334/https://lwn.net/Articles/727383/. live.
  6. News: Roland McGrath steps down as glibc maintainer after 30 years . 10 July 2017 . 1 June 2024 . Richard . Chirgwin . . Situation Publishing . 7 March 2024 . https://web.archive.org/web/20240307163613/https://www.theregister.com/2017/07/10/glibc_maintainer_roland_mcgrath_steps_down/ . live .
  7. Web site: GNU's Bulletin, vol. 1 no. 4, February, 1988 . Most libraries are done. Roland McGrath [...] has a nearly complete set of ANSI C library functions. We hope they will be ready some time this spring. . 16 April 2014 . 16 April 2016 . https://web.archive.org/web/20160416163749/https://gnu.org/bulletins/bull4.html . live .
  8. Web site: GNU's Bulletin, vol. 1 no. 12 . It now contains all of the ANSI C-1989 and POSIX.1-1990 functions, and work is in progress on POSIX.2 and Unix functions (BSD and System V) . 16 April 2014 . 11 March 2016 . https://web.archive.org/web/20160311170312/https://www.gnu.org/bulletins/bull12.html . live .
  9. Web site: A turning point for GNU libc. Corbet. Jonathan. 28 March 2012. LWN.net. Of the nearly 19,000 commits found in the project's git repository (which contains changes back to 1995), over 12,000 were made by Ulrich.. 5 April 2012. 23 April 2016. https://web.archive.org/web/20160423100007/https://lwn.net/Articles/488847/. live.
  10. Web site: Glibc finally free software – The H Open: News and Features. 2021-09-19. H-online. 21 March 2022. https://web.archive.org/web/20220321041635/http://www.h-online.com/open/news/item/Glibc-finally-free-software-1068035.html. live.
  11. Web site: Phipps. Simon. 2010-09-02. Gnu/Linux: Finally, it's really free software. 2021-09-19. InfoWorld. en. 28 October 2021. https://web.archive.org/web/20211028174447/https://www.infoworld.com/article/2626417/gnu-linux--finally--it-s-really-free-software.html. live.
  12. Web site: Corbet . Jonathan . The glibc s390 ABI break [LWN.net] ]. 2022-03-17 . . 17 March 2022 . https://web.archive.org/web/20220317160239/https://lwn.net/Articles/605607/ . live .
  13. Web site: Claburn . Thomas . Glibc 'abortion joke' diff tiff leaves Richard Stallman miffed . 2023-01-17 . . en . 17 January 2023 . https://web.archive.org/web/20230117154113/https://www.theregister.com/2018/05/09/gnu_glic_abort_stallman/ . live .
  14. Web site: Halfacree . Gareth . Open-source projects glibc and gnulib look to sever copyright ties with Free Software Foundation . 2023-01-17 . . en . 17 January 2023 . https://web.archive.org/web/20230117154446/https://www.theregister.com/2021/06/16/glibc_gnulib_fsf_copyright/ . live .
  15. Web site: History of glibc and Linux libc. 2021-05-10. Free Software Magazine. 26 September 2021. https://web.archive.org/web/20210926154743/http://freesoftwaremagazine.com/articles/history_of_glibc_and_linux_libc/. live.
  16. Web site: 24 October 2000 . Forking: it could even happen to you . https://web.archive.org/web/20090915191339/https://www.linux.com/archive/feature/3874 . 15 September 2009 . the split between GNU LIBC and the Linux LIBC -- it went on for years while Linux stabilized, and then the forks re-merged into one project.
  17. Web site: A Technical Comparison of glibc 2.x With Legacy System Libraries. Lee . Elliot . Jul 9, 1998 . https://web.archive.org/web/20040411191201/https://people.redhat.com/~sopwith/old/glibc-vs-libc5.html . 11 April 2004.
  18. Web site: Fear of Forking essay . 6. glibc --> Linux libc --> glibc . Rick . Moen . May 20, 2021 . 14 Nov 1999 . linuxmafia.com . live . https://web.archive.org/web/20231127145135/http://linuxmafia.com/faq/Licensing_and_Law/forking.html . Nov 27, 2023 .
  19. Book: Vaduva, Alexandru. Linux : embedded development: leverage the power of Linux to develop captivating and powerful embedded Linux projects : a course in three modules. Packt Publishing . 2016. Alex Gonzalez, Chris Simmonds. 978-1-78712-445-5. Birmingham, UK. 24. 960471438.
  20. Web site: Stiebert. Julius. 6 May 2009. Debian wechselt zur Eglibc. 2021-09-16. golem.de. 16 September 2021. https://web.archive.org/web/20210916141335/https://www.golem.de/0905/66930.html. live.
  21. Book: Simmonds, Chris. Mastering embedded Linux programming: unleash the full potential of embedded Linux. 2017. 978-1-78728-885-0. 2nd. Birmingham, UK. 26. 995052708.
  22. Book: Vaduva, Alexandru. Learning embedded Linux using the Yocto project: develop powerful embedded Linux systems with the Yocto project components. 2015. 978-1-78439-519-3. Birmingham, UK. 29. 914797028.
  23. Web site: glibc homepage . In 2001 The GNU C Library Steering Committee ..., was formed and currently consists of Mark Brown, Paul Eggert, Andreas Jaeger, Jakub Jelinek, Roland McGrath and Andreas Schwab. . 16 April 2014 . 22 April 2016 . https://web.archive.org/web/20160422061403/http://www.gnu.org/software/libc/ . live .
  24. Web site: Ulrich Drepper . LinkedIn . 2012-06-13 . 10 September 2014 . https://web.archive.org/web/20140910084037/http://www.linkedin.com/in/ulrichdrepper . live .
  25. Web site: online. heise. Open-Source-Entwickler kritisiert Stallman. 2021-09-16. heise online. 19 August 2001. de. 16 September 2021. https://web.archive.org/web/20210916142850/https://www.heise.de/newsticker/meldung/Open-Source-Entwickler-kritisiert-Stallman-48836.html. live.
  26. Web site: RMS is at it again. Ulrich. Drepper. 2000-06-26. 2015-11-20. A few weeks ago RMS started the next attack on me (a single mail, followed by indirect tries to take influence, followed by another mail today). The essence is that he complains I am not following "GNU policies" and therefore have to be replaced by a steering committee of which I could be a part. Some of you (namely Roland and Andreas S.) probably know about this since he proposed both as other members of the committee. In addition there was Mark Brown listed (I know somebody of this name at IBM who would also fit in this group but I'm not sure whether it is really him.) Anyhow, I completely reject this. It is not helping at all, the opposite is true. First, I am not aware of any essential policies I'm violating. The only ones are that I'm not following orders from RMS which clearly have political intends (which is of course a sacrilege) and possibly that I do not care about Winblowz (if the latter counts at all). None of this will change in any way.. sourceware.org. 28 December 2012. https://web.archive.org/web/20121228210747/http://sourceware.org/ml/libc-hacker/2000-06/msg00180.html. live.
  27. Web site: glibc 2.2.4 . Ulrich . Drepper . 2001-08-15 . 2015-11-29 . sourceware.com . And now for some not so nice things. Stallman recently tried what I would call a hostile takeover of the glibc development. He tried to conspire behind my back and persuade the other main developers to take control so that in the end he is in control and can dictate whatever pleases him. This attempt failed but he kept on pressuring people everywhere and it got really ugly. In the end I agreed to the creation of a so-called "steering committee" (SC). . 9 April 2016 . https://web.archive.org/web/20160409074117/http://sourceware.org/ml/libc-announce/2001/msg00000.html . live .
  28. https://slashdot.org/story/01/08/19/2039211/rms-accused-of-attempting-glibc-hostile-takeover rms-accused-of-attempting-glibc-hostile-takeover
  29. Web site: The GNU C Library Steering Committee disbands – The H Open: News and Features . 2023-03-16 . . 21 March 2023 . https://web.archive.org/web/20230321065852/http://www.h-online.com/open/news/item/The-GNU-C-Library-Steering-Committee-disbands-1484707.html . live .
  30. Web site: McGrath. Roland. 26 March 2012. glibc steering committee dissolving. 2012-06-13. Sourceware.org. 26 September 2019. https://web.archive.org/web/20190926010751/http://sourceware.org/ml/libc-alpha/2012-03/msg01038.html. live.
  31. Web site: Myers. Joseph S.. 26 March 2012. GNU C Library development and maintainers. 2012-06-13. Sourceware.org. 26 September 2019. https://web.archive.org/web/20190926010751/http://sourceware.org/ml/libc-alpha/2012-03/msg01040.html. live.
  32. Web site: The GNU C Library machine maintainers. . 8 October 2015 . 18 April 2016 . https://web.archive.org/web/20160418170046/https://sourceware.org/glibc/wiki/MAINTAINERS#Machine_maintainers . live .
  33. Web site: GNU/kOpenSolaris (GNU libc/base + OpenSolaris kernel). Bartley. David. Spang. Michael. 2008-12-16. 6 November 2019. https://web.archive.org/web/20191106181358/http://csclub.uwaterloo.ca/~dtbartle/opensolaris/. dead.
  34. Web site: Haiku Source . . libroot.so is not part of GNU project and is included in Haiku source code. . 15 October 2014 . 1 May 2016 . https://web.archive.org/web/20160501130749/https://github.com/haiku/haiku/tree/master/src/system/libroot . live .
  35. Web site: Torvalds. Linus. Posting to the glibc mailing list. 9 January 2002. 22 July 2007. 12 October 2015. https://web.archive.org/web/20151012215444/http://ecos.sourceware.org/ml/libc-alpha/2002-01/msg00079.html. live.
  36. Web site: OpenMoko components . We will use glibc (not uClibC) ... The alternatives may save more space and be more optimized, but are more likely to give us integration headaches . 13 May 2008 . 22 April 2016 . https://web.archive.org/web/20160422073925/http://wiki.openmoko.org/wiki/Openmoko . live .
  37. Web site: Re: [Familiar] Which glibc for Familiar 0.8.4  ? ]. Question: which version of the GLIBC was used to build the Familiar 0.8.4 ? Answer: 2.3.3 . 26 November 2018 . 12 March 2022 . https://web.archive.org/web/20220312062719/https://marc.info/?l=familiar&m=118666899424374&w=2 . live .
  38. Web site: Kerrisk . Michael . The ups and downs of strlcpy . 2023-12-09 . . 9 December 2023 . https://web.archive.org/web/20231209152233/https://lwn.net/Articles/507319/ . live .
  39. Web site: Corbet . Jonathan . Adding strlcpy to glibc . 2023-12-09 . . 9 December 2023 . https://web.archive.org/web/20231209152233/https://lwn.net/Articles/612244/ . live .
  40. Web site: FAQ . 2023-12-09 . sourceware.org . 9 December 2023 . https://web.archive.org/web/20231209151431/https://sourceware.org/glibc/wiki/FAQ#Why_no_strlcpy_.2F_strlcat.3F . live .