UNDER CONSTRUCTION
glibc
- Repository: https://sourceware.org/git/gitweb.cgi?p=glibc.git
- Wiki: https://sourceware.org/glibc/wiki/
- Bugzilla: https://sourceware.org/bugzilla/
- Mailing lists:
{libc-announce,libc-alpha,libc-locale,libc-stable,libc-help}@sourceware.org
- Patchwork: https://patchwork.sourceware.org/project/glibc/list/ Patch Review Workflow
glibc is an implementation of the user-space side of standard C/POSIX functions with Linux extensions.
Build system
Cross compilation
To cross compile for aarch64:
1 | ../../configure --prefix=/tmp/glibc/aarch64 --host=aarch64-linux-gnu |
To cross compile for i686:
1 | ../../configure --prefix=/tmp/glibc/i686 --host=i686-linux-gnu CC='gcc -m32' CXX='g++ -m32' && make -j 50 && make -j 50 install && cp -f /usr/lib/i386-linux-gnu/{libgcc_s.so.1,libstdc++.so.6} /tmp/glibc/i686/ |
For cross compiling, run-built-tests
is yes only if test-wrapper
is set.
Misc
If you don't have a C++ compiler, specify CXX=false
.
A very unfortunate fact: glibc can only be built with -O2
, not -O0
or -O1
. If you want to have an un-optimized debug build, deleting an object file and recompiling it with -g
usually works. Another workaround is #pragma GCC optimize ("O0")
.
The -O2
issue is probably related to (1) expected inlining and (2) avoiding dynamic relocations.
To build a directory:
1 | make -r -C ~/Dev/glibc/stdlib objdir=$PWD subdir=stdlib subdir_lib |
The run a program with the built dynamic loader:
1 | $build/testrun.sh $program |
To test one directory (say, libio
), delete libio/*.out
files and run
1 | make -r -C ~/Dev/glibc/libio objdir=$PWD check -j 20 |
(
1 | ../../configure --prefix=/tmp/glibc/lld && make -j 50 && make -j 50 install && 'cp' -f /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 /tmp/glibc/lld/lib/ |
)
Delete failed tests so that the next make check
invocation will re-run them:
1 | rg -lg '*.test-result' '^FAIL' | while read i; do rm -f ${i/.test-result/.out} $i; done |
GRTE
In a llvm-project build directory, build clang, lld, and clang_rt.crtbegin*.o
1 | ninja -C /tmp/out/custom1 clang crt lld |
1 | git checkout origin/google/grte/v5-2.27/master |
build-many-glibcs.py
Run the following commands to populate /tmp/glibc-many
with toolchains. Caution: please make sure the target file system has tens of gigabytes.
Preparation:
1 | scripts/build-many-glibcs.py /tmp/glibc-many checkout --shallow |
--shallow
passes--depth 1
to the git clone command.--keep all
keeps intermediary build directories intact. You may want this option to investigate build issues.
The glibcs
command will delete the glibc build directory, build glibc, and run make check
.
1 |
|
For the glibcs
command, add --full-gcc
to build C++.
1 | many=/tmp/glibc-many |
"On build-many-glibcs.py and most stage1 compiler bootstrap, gcc is build statically against newlib. the static linked gcc (with a lot of disabled features) is then used to build glibc and then the stage2 gcc (which will then have all the features that rely on libc enabled) so the stage1 gcc might not have the require started files"
During development, some interesting targets:
1 | make -C out/debug check-abi |
Building with Clang is not an option.
- Clang does not support GCC nested functions BZ #27220
- x86
PRESERVE_BND_REGS_PREFIX
: integrated assembler does not support thebnd
prefix. sysdeps/powerpc/powerpc64/Makefile
: Clang does not support-ffixed-vrsave -ffixed-vscr
Misc
To regenerate configure
from configure.ac
: https://sourceware.org/glibc/wiki/Regeneration. Consider installing an autoconf somewhere with the required version.
In elf/
, .o
objects use -fpie -DPIC -DMODULE_NAME=libc
, while .os
objects use -fPIC -DPIC -DMODULE_NAME=rtld
.