GNU C函式庫

本页使用了标题或全文手工转换,现处于台湾繁体模式
求聞百科,共筆求聞
GNU C庫
原作者Roland McGrath
開發者GNU計劃
首次發布1987年,​37年前​(1987[1]
程式語言C語言
作業系統類UNIX系統
類型
許可協定LGPLv2.1[2]
網站www.gnu.org/software/libc/
Linux API由Linux核心的系統呼叫介面、GNU C庫(GNU)、libdrm、libalsa和libevdev組成。
Glibc是Linux核心系統呼叫的封裝器。
Linux核心和GNU C庫共同構成了Linux API。編譯後,二進位檔案提供ABI。

GNU C庫,又名glibc,是GNU計劃所實現的C標準庫。儘管其名字中帶有「C庫」,但它現在也直接支援C++(以及間接支援其他程式語言)。它是自由軟體基金會(FSF)在20世紀90年代初為他們的GNU作業系統設計的。它為GNU系統GNU/Linux系統和一些其他的類Unix系統提供了系統核心庫。這些庫提供了關鍵的API,包括ISO C11、POSIX.1-2008和BSD所規定的API和一些底層API,包括open、read、write、malloc、printf、getaddrinfo、dlopen、pthread_create、crypt、login、exit等。

glibc在GNU寬通用公共許可證下發布。[2]

歷史

glibc專案最初主要由Roland McGrath編寫,他在20世紀80年代為自由軟體基金會(FSF)工作。[3]

1988年,FSF稱glibc已基本實現ANSI C所規定的內容[4];到1992年,它已經實現了ANSI C-1989POSIX.1-1990所規定的功能,並正在進行關於實現POSIX.2的工作。[5]

1995年9月,Ulrich Drepper為glibc專案做出了他的第一個貢獻,並在20世紀90年代逐漸成為glibc的核心貢獻者和維護者。[6]Drepper擔任維護員一職多年,直到2012年累計占專案總貢獻的63%。[7]

Linux libc

在20世紀90年代初,Linux核心的開發團隊分叉了Glibc,名為「Linux libc」並單獨維護。

當FSF在1997年1月發布glibc 2.0時,由於glibc 2.0更符合POSIX標準,核心開發者停止了Linux libc的開發。[8]glibc 2.0還具有更好的國際化和翻譯、IPv6功能、64位元資料存取、多執行緒支援、未來版本的相容性,而且代碼更加可移植。[9]

最後版本的Linux libc使用的庫檔名是libc.so.5。因此,Linux上的glibc 2.x使用的庫檔案名稱為libc.so.6[10]AlphaIA64 平台的glibc使用libc.so.6.1代替). 這些以.so為字尾的檔案通常被縮寫為libc6 (例如在Debian的軟體套件名中),遵循一般庫的慣例。

根據Richard Stallman的說法,由於開發者們的身分模糊,FSF無法將Linux libc做出的改動合併到glibc中。GNU專案對版權相關的要求十分嚴格。[11]

成立委員會

自2001年起,庫的開發由 [12]一個監管委員會負責,[13]但保留了Drepper主要貢獻者和維護者的身分。委員會的設立被Drepper公然說成是Richard Stallman的陰謀詭計,因而被公共爭議所包圍。[14][15][16]

遷移到git

glibc以前被儲存在CVS倉庫中,2009年被遷移到Sourceware上的Git倉庫。.[17]


委員會解散

2012年3月,委員會投票決定解散,並撤銷Drepper的職務,轉而由Ryan Arnold、Maxim Kuvyrkov、Joseph Myers、Carlos O'Donell和Alexandre Oliva負責glibc的維護工作。但是,他們對於glibc沒有額外的決策權。[18][19]

在委員會解散後,Debian和其他使用glibc替代品的專案又遷移回到了glibc。[20]從2014年開始,EGLIBC不再開發,因為它「現在的目標是在glibc上直接解決問題」。[21]

2017年7月,在glibc創立30年時,Roland McGrath宣布不再直接參與專案,並宣布自己為名譽維護者。「過去這幾個月,甚至過去幾年,已經證明你們不再需要我了」。[3]

版本歷史

對於大多數系統來說,glibc的版本可以通過解析lib檔案(例如,/lib/libc.so.6)獲得。

功能

glibc實現了單一UNIX規範、POSIX(1c、1d和1j)所要求的功能,並實現了ISO C11、ISO C99Berkeley Unix(BSD)介面、System V介面定義(SVID)和X/Open Portability Guide(XPG)4.2所要求的部分功能,並提供了所有符合XSI(X/Open System Interface)的系統所共有的擴充以及所有X/Open UNIX擴充。

此外,glibc還提供了在開發GNU時被認為有用或必要的擴充。

受支援的硬體和核心

glibc可以執行在許多不同的核心和不同的硬體架構上。官方支援的硬體架構[37]包括: 32位元ARM,AArch64C-SKYDEC AlphaIA-64Motorola m68kMicroBlazeMIPSNios IIPA-RISCPowerPCRISC-Vs390SPARC, 和 x86 (舊版本支援 TILE)。Glibc官方支援HurdLinux核心。此外,還有大量打過修補程式的版本可以執行在FreeBSDNetBSD上(因此glibc也相應地支援Debian GNU/kFreeBSDDebian GNU/NetBSD,因為這些核心與FreeBSD和NetBSD的關聯很大),以及OpenSolaris的分支版本。[38]Glibc的一個修改過的版本也被用在 BeOSHaiku中。[39]

在小型裝置中的使用

Glibc在過去因過於臃腫且速度比其他C庫較慢,遭到一些開發者們的批評,如Linus Torvalds[40]和一些嵌入式開發程式設計師。 出於這個原因,人們建立了幾個用於在嵌入式平台替代Glibc的C標準庫。這些庫較Glibc更小。然而,許多嵌入式開發專案仍使用Glibc,因為它更加符合標準且相容性更好。例如Openmoko[41]和由iPaq使用的Familiar Linux(在使用GPE顯示軟體時)[42]

相關條目

參考資料

  1. Corbet, Jonathan. A turning point for GNU libc. LWN.net. 2012-03-28 [2013-02-05]. 
  2. 2.0 2.1 sourceware.org Git - glibc.git/blob - COPYING.LIB. sourceware.org. [2017-09-23]. 
  3. 3.0 3.1 Roland McGrath bows out as glibc maintainer [LWN.net]. lwn.net. 2017-07-07 [2017-07-08]. 
  4. GNU's Bulletin, vol. 1 no. 4, February, 1988. [2020-10-24]. 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. 
  5. GNU's Bulletin, vol. 1 no. 12. [2020-10-24]. 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) 
  6. glibc changelog on GitHub.
  7. Corbet, Jonathan. A turning point for GNU libc. LWN.net. 2012-03-28 [2013-02-05]. 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. 
  8. Forking: it could even happen to you. 2008-09-12 [2020-10-24]. 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 
  9. Lee, Elliot. A Technical Comparison of glibc 2.x With Legacy System Libraries. 2001 [2020-10-24]. 
  10. Fear of Forking essay, see "6. glibc --> Linux libc --> glibc". [2020-10-24]. 
  11. Fear of Forking, footnote on Stallman's merge comments. [2020-10-24]. 
  12. Ulrich Drepper. LinkedIn. [2012-06-13]. 
  13. glibc homepage. [2020-10-24]. 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. 
  14. Drepper, Ulrich. RMS is at it again. sourceware.org. 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. 
  15. Drepper, Ulrich. glibc 2.2.4. sourceware.com. 2001-08-15 [2015-11-29]. 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). 
  16. rms-accused-of-attempting-glibc-hostile-takeover on slashdot.com on August 19, 2001
  17. glibc repo on Sourceware.com
  18. McGrath, Roland. glibc steering committee dissolving. Sourceware.org. 2012-03-26 [2012-06-13]. 
  19. Myers, Joseph S. GNU C Library development and maintainers. Sourceware.org. 2012-03-26 [2012-06-13]. 
  20. Debian is switching (back) to GLIBC. Aurélien. 2014-06-19 [2014-06-19]. 
  21. Debian package changelog. [2020-10-24]. 
  22. CosmicCuttlefish/ReleaseNotes - Ubuntu Wiki. wiki.ubuntu.com. [2020-10-24]. 
  23. Chapter 5. RHEL 8.0.0 release Red Hat Enterprise Linux 8. Red Hat Customer Portal. [2020-10-24]. 
  24. Chapter 2. What's new in Debian 10. www.debian.org. [2020-10-24]. 
  25. Changes/GLIBC228. [2020-10-24]. 
  26. Red Hat Bugzilla – Bug 1598403. [2020-10-24]. 
  27. sourceware.org Git - glibc.git/blob - NEWS. 
  28. DiscoDingo/ReleaseNotes - Ubuntu Wiki. wiki.ubuntu.com. [2020-10-24]. 
  29. Changes/GLIBC229. [2020-10-24]. 
  30. Red Hat Bugzilla – Bug 1653403. [2020-10-24]. 
  31. sourceware.org Git - glibc.git/blob - NEWS. [2020-10-24]. 
  32. EoanErmine/ReleaseNotes - Ubuntu Wiki. wiki.ubuntu.com. [2020-10-24]. 
  33. Changes/GLIBC230 - Fedora Project Wiki. fedoraproject.org. [2020-10-24]. 
  34. Focal (20.04) : glibc package : Ubuntu. Launchpad. 
  35. Changes/GLIBC231 - Fedora Project Wiki. fedoraproject.org. [2020-10-24]. 
  36. The GNU C Library version 2.32 is now available. sourceware.org. [2020-08-13]. 
  37. The GNU C Library machine maintainers.. [2020-10-24]. 
  38. Bartley, David; Spang, Michael. GNU/kOpenSolaris (GNU libc/base + OpenSolaris kernel). [2008-12-16]. 
  39. Haiku Source. [2020-10-24]. libroot.so is not part of GNU project and is included in Haiku source code. 
  40. Torvalds, Linus. Posting to the glibc mailing list. 2002-01-09 [2020-10-24]. 
  41. OpenMoko components. [2020-10-24]. 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 
  42. 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 

外部連結