You should check if your distribution is using the vanilla GLIBC or the EGLIBC fork (Debian and Ubuntu have switched to EGLIBC EDIT: they switched back around 2014).

Anyway, the repository browser for GLIBC is at http://sourceware.org/git/?p=glibc.git

http://code.woboq.org/userspace/glibc/, posted by @guruz below, is a good alternative.

The source is a bit complicated by the presence of multiple versions of the same files.

Answer from Jacopo on Stack Overflow
🌐
GitHub
github.com › bminor › glibc
GitHub - bminor/glibc: Unofficial mirror of sourceware glibc repository. · GitHub
Unofficial mirror of sourceware glibc repository. Contribute to bminor/glibc development by creating an account on GitHub.
Starred by 1.9K users
Forked by 469 users
Languages   C 71.0% | Assembly 12.4% | C++ 7.2% | Pawn 6.0% | Makefile 1.1% | Python 1.0%
Discussions

documentation - Where can I browse the sourcecode for libc online (like doxygen) - Stack Overflow
You can also get actual ...s.org/dox/glibc. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... New site design and philosophy for Stack Overflow: Starting February 24, 2026... 23 libc source location - for download or online ... More on stackoverflow.com
🌐 stackoverflow.com
c - libc source location - for download or online viewing? - Stack Overflow
Sorry I know this is stupid but where is linux libc source code available? What I downloaded from GNU didn't seem to be what I wanted, specifically I could find nothing in the pthreads function family. Is there an online (hypertexted cross-referenced) version somewhere? ... glibc has to run ... More on stackoverflow.com
🌐 stackoverflow.com
linux - Where is the source code for the GNU C library? - Stack Overflow
How do I go about finding the source code behind standard C functions (under Linux/Ubuntu 13)? Case in point, chdir(). I know I have to #include but then I encounter a bug, and I More on stackoverflow.com
🌐 stackoverflow.com
c - How to navigate glibc source? - Stack Overflow
I'm trying to learn the glibc source, and I've found navigation to be quite formidable. I'm not referring to the code itself, but simply finding it: it seems to be a maze of macros and wrappers, s... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Internet Archive
archive.org › software
glibc-2.35 source code : GNU project : Free Download, Borrow, and Streaming : Internet Archive
https://sourceware.org/git/glibc.git · Scanner · Internet Archive HTML5 Uploader 1.6.4 · Website · https://www.gnu.org/software/libc/ 240 Views · 1 Favorite · download 1 file GZIP download · download 1 file TORRENT download · download ...
🌐
GNU
gnu.org › software › libc › sources.html
The GNU C Library (glibc) Documentation
The GNU C Library can be found on the main GNU ftp server (download glibc via HTTPS, download glibc via HTTP or download glibc via FTP), and its mirrors; please use a mirror if possible. Documentation for the GNU C Library is online, as is documentation for most GNU software.
🌐
GNU
gnu.org › software › libc › libc.html
The GNU C Library - GNU Project - Free Software Foundation
The GNU C Library can be found on the main GNU ftp server (download glibc via HTTPS, download glibc via HTTP or download glibc via FTP), and its mirrors; please use a mirror if possible. Documentation for the GNU C Library is online, as is documentation for most GNU software.
Find elsewhere
🌐
Launchpad
code.launchpad.net › glibc
Git : Code : GLibC
This repository is an import of the Git repository at git://sourceware.org/git/glibc.git. The next import is scheduled to run in 44 minutes. Last successful import was 5 hours ago.
🌐
Ask Ubuntu
askubuntu.com › questions › 696139 › how-can-i-get-glibc-source-code
system installation - How can i get glibc source code ? - Ask Ubuntu
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Closed 10 years ago. i have download one source code (glibc,linuxthreads) form GNU site .and install it in /usr/local.
Top answer
1 of 4
27

Most linuxes use a libc version named glibc.

The LXR (online cross-reference system) for glibc is e.g. here http://koala.cs.pub.ro/lxr/glibc/ for 2.9 version (link is broken). I must say that something may be not lxr'ed because some sources are generated in the build process, for example - as i can remember - wrappers around a system calls.

Pthreads are in nptl/ folder. Right link to libc sources is http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.bz2 (or change 2.14 to your version)

Update: After closing of koala's lxr, there are:

  1. Metager with glibc: http://code.metager.de/source/xref/gnu/glibc/ (Served with Sun's OpenGrok, which was originally used to generate online x-ref for Solaris/OpenSolaris)

  2. Google code search (I know that it was closed; but I also know it's other version which is up): http://code.google.com/codesearch and try to search something glibc-specific

UPD (march 2013) They killed codesearch again:

404. That’s an error.

The requested URL /codesearch was not found on this server. That’s all we know.

UPD 2017

  1. Metager with glibc: http://code.metager.de/source/xref/gnu/glibc/

  2. There is online git by glibc authors: https://sourceware.org/git/?p=glibc.git (tree is browserable at https://sourceware.org/git/?p=glibc.git;a=tree)

  3. Glibc git is mirrored to github (which has some searching functions) https://github.com/bminor/glibc Buildroot 2018.05 notably uses this mirror.

  4. There is search like google's codesearch in all debian packages: https://codesearch.debian.net/. It can search in glibc sources by "package:glibc request" request and also have file browser: http://sources.debian.net/src/glibc/

2 of 4
15

Info on the glibc repository: http://sourceware.org/glibc/wiki/GlibcGit

Clone it to get your own copy and search it however you like:

git clone git://sourceware.org/git/glibc.git

I load it up in an IDE project (using whatever preferred IDE) and the code navigation works quite well to let me find what I'm interested in.

Browse the source online http://sourceware.org/git/?p=glibc.git

🌐
Internet Archive
archive.org › software
glibc-2.28 source code : Free Download, Borrow, and Streaming : Internet Archive
glibc-2.28 · Scanner · Internet Archive HTML5 Uploader 1.6.3 · 579 Views · download 1 file GZIP download · download 1 file TORRENT download · download 5 Files download 5 Original SHOW ALL · Game Source Code: Miscellaneous Game Source Code Collection Software History Collection ·
🌐
GitHub
github.com › lattera › glibc
GitHub - lattera/glibc: GNU Libc - Extremely old repo used for research purposes years ago. Please do not rely on this repo. · GitHub
GNU Libc - Extremely old repo used for research purposes years ago. Please do not rely on this repo. - lattera/glibc
Starred by 2K users
Forked by 962 users
Languages   C 65.8% | Assembly 14.2% | C++ 9.4% | Objective-C 4.4% | Roff 3.4% | Makefile 0.8%
🌐
GNU
sourceware.org › glibc › sources.html
The GNU C Library (glibc)
Releases are available by source branch checkout (gitweb) and tarball via ftp. ... Release tarballs are available via anonymous ftp at https://ftp.gnu.org/gnu/glibc/ and its mirrors.
Top answer
1 of 1
1

How can I navigate glibc and find the actual implementation for lib functions?

Type the function in the search bar at https://code.woboq.org/userspace/glibc or at https://github.com/bminor/glibc . Navigate the results manually until you find the definition.

If you want to index the project locally, use cscope, ctags, GLOBAL tags or clangd to index the project and then use that tools specific interface to search for the definition.

As an example, try looking up the definition of hidden_def in glibc

Type hidden_def glibc into google. My first hit is woboq.org https://code.woboq.org/userspace/glibc/include/libc-symbols.h.html#550 .

I use firefox. I type ctrl+f and type hidden_def. Type Enter until I find # define hidden_def at https://code.woboq.org/userspace/glibc/include/libc-symbols.h.html#550 .

Then select __hidden_ver1 and type ctrl+c ctrl+f and ctrl+v and search for it. In the web browser. I type enter until I find https://code.woboq.org/userspace/glibc/include/libc-symbols.h.html#540 . __hidden_ver2 is just below on line 542.

For most cases all you need is a browser, google, coboq.org and github.org.

It's a macro taking you to hidden_def1

There are no such macros as you mentioned, at least at the version hosted at woboq.org.

How does anyone follow it?

While IDE is a powerful help, each project is unique and requires different settings, that take time to figure out. Mostly browsing the source code is grep (or faster alternatives, like ag, very useful for big projects like glibc) and going through the result list.

Not only system dependent things, like setjmp

Developers are (shoudl be :) sane people - in most cases a function named setjmp will be in a file named setjmp.c. or setjmp.S. Or in the same directory as setjmp.h. Or inside directory named stdlib or setjmp.

Type setjmp in github search bar. https://github.com/bminor/glibc/search?q=setjmp You see there are multiple definitions for each architecture powerpc s390 etc. But files are all named setjmp. Go back. Type "Go to file" on https://github.com/bminor/glibc . Search for a file named x86/setjmp. There are 3 implementations, the most standard one seems to be https://github.com/bminor/glibc/blob/master/sysdeps/x86_64/setjmp.S .

even portable functions like fprintf

As above, saerch for file named fprintf . You quickly find https://github.com/bminor/glibc/blob/master/stdio-common/fprintf.c .

🌐
GNU
sourceware.org › glibc
The GNU C Library (glibc)
You can contact the developer community by emailing the developer list libc-alpha@sourceware.org. The GNU C Library releases every 6 months. See the NEWS file in the glibc sources for more information.
🌐
Gentoo Forums
forums.gentoo.org › board index › assistance › portage & programming
how to find glibc sorce code - Gentoo Forums
October 27, 2019 - The downloaded sources of the installed packages are kept in the DISTDIR directory, defined in make.conf. There is a good chance that it is /usr/portage/distfiles. The C library code is in the glibc archive.
Top answer
1 of 2
11

The simplest way is to extract the package source code somewhere: go to an appropriate directory, then run

apt source glibc

In gdb, add the corresponding directory to the source path by using the directory command.

You may also want the detached debug symbols; I don’t know whether Devuan provides debug symbol packages in general (dbgsym packages), but I see it ships libc6-dbg which has the same purpose:

sudo apt install libc6-dbg

Here’s an example gdb session:

$ gdb ls
...
(gdb) directory ~/Debian/glibc
Source directories searched: /home/steve/Debian/glibc:$cdir:$cwd
(gdb) break malloc
Breakpoint 1 at 0x46c8
(gdb) run
Starting program: /bin/ls 

Breakpoint 1, malloc (n=1441) at dl-minimal.c:50
50    if (alloc_end == 0)
2 of 2
1

Some further indications for Ubuntu 22.04 beyond what Stephen said.

To get debug symbols and source, some setup is needed as in:

# Get debug symbols.
printf "deb http://ddebs.ubuntu.com %s main restricted universe multiverse\n" $(lsb_release -cs){,-updates,-security,-proposed} | \
 sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt install ubuntu-dbgsym-keyring
sudo apt update
sudo apt install coreutils-dbgsym

# Get source as per: https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
# Produces directory "coreutils-8.32"
sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /'
/etc/apt/sources.list sudo apt-get update
apt source coreutils

Then, to get GDB to actually find the sources, you might need to either cd into the downloaded source, or play with stuff like:

set substitute-path . glibc-2.35

as mentioned at: https://askubuntu.com/questions/487222/how-to-install-debug-symbols-for-installed-packages/1434174#1434174

🌐
Reddit
reddit.com › r/c_programming › how to navigate source code of c language/standard?
r/C_Programming on Reddit: How to navigate source code of C language/standard?
February 9, 2022 -

Out of curiosity, I really want to dig into the source code implementation of various C features like how is int, function, switch, ... implemented by C. Can you help me get started and point to where the actual source code is located so I can try to understand it?

Also, I want to know if the functions defined by the header files like math.h, stdio.h, ... are actually implemented by C or are they implemented by the compiler (gcc/clang). And where to locate the source code of these? (like where to find source code of qsort for example)

Are there any resources for learning about the internals of the language at this depth (other than the actual source code)?

And, it would really help me if you can expand the answer for the above questions to C++ also. For example, in C++ string contains the actual character array and the length of the array. But where to find the source code of string to see all the things that string does internally.