Skip to content

add glibc 2.35, 2.36, 2.37, and 2.38#17489

Merged
andrewrk merged 15 commits intomasterfrom
glibc-update
Oct 14, 2023
Merged

add glibc 2.35, 2.36, 2.37, and 2.38#17489
andrewrk merged 15 commits intomasterfrom
glibc-update

Conversation

@andrewrk
Copy link
Member

@andrewrk andrewrk commented Oct 12, 2023

Merge Checklist

  • Update the headers to 2.38.
  • Inspect git log -- lib/libc/glibc lib/libc/include and look for glibc patches and reapply them.
  • Test cross compiling hello.c against every version of glibc x every architecture
  • Test the std lib tests for every architecture against 2.38 using qemu

Closes #12808
Closes #12809
Closes #14798
Closes #16668

@andrewrk
Copy link
Member Author

As part of this process I have uploaded 3 tarballs of glibc compiled for all targets:

@motiejus
Copy link
Contributor

cc @linzhp / @sywhang you may be interested in checking this out soon after landing (or now).

andrewrk and others added 15 commits October 13, 2023 17:44
generated from the latest commits of ziglang/glibc-abi-tool which
contains glibc 2.35, 2.36, 2.37, and 2.38.
I went ahead and left the README.md file deleted because it had broken
git hashes. Better to use `git log -- lib/libc/glibc/` to find out the
patches.
so let's not include those headers until more investigation happens.
Instead Zig passes it based on the target.
This is a patch to glibc features.h which makes
_DYNAMIC_STACK_SIZE_SOURCE undefined unless the version is >= 2.34.

This feature was introduced with glibc 2.34 and without this patch, code
built against these headers but then run on an older glibc will end up
making a call to sysconf() that returns -1 for the value of SIGSTKSZ
and MINSIGSTKSZ.
- `fcntl` was renamed to `fcntl64` in glibc 2.28 (see #9485)
- `res_{,n}{search,query,querydomain}` became "their own" symbols since
  glibc 2.34: they were prefixed with `__` before.

This PR makes it possible to use `fcntl` with glibc 2.27 or older and
the `res_*` functions with glibc 2.33 or older.

These patches will become redundant with universal-headers and can be
dropped. But we have to do with what we have now.
This is necessary to build glib.
I could have just included the file from upstream glibc, but it was too
silly so I just inlined it. This patch could be dropped in a future
glibc update if desired. If omitted it will cause easily solvable
C compilation failures building glibc nonshared.
instead of importing every header file under the sun, I copied a couple
inline functions into these files to make them work.
I don't know where glibc thinks uintptr_t is coming from, but here it
is.
This is the only place in all of glibc that this macro is referenced.
What is it doing? Only preventing fstatat.c from knowing the type
definition of `__time64_t`, apparently.

Fixes compilation of fstatat.c on 32-bit x86.
These are tripping on 32-bit x86 but are intended to prevent glibc
itself from being built with a bad configuration. Zig is only using this
file to create libc_nonshared.a, so it's not relevant.
@andrewrk
Copy link
Member Author

All these checks pass:

stage4/bin/zig build-exe hello.c -lc -target      x86_64-linux-gnu.2.38
stage4/bin/zig build-exe hello.c -lc -target     aarch64-linux-gnu.2.38
stage4/bin/zig build-exe hello.c -lc -target         x86-linux-gnu.2.38
stage4/bin/zig build-exe hello.c -lc -target powerpc64le-linux-gnu.2.38

stage4/bin/zig build-exe hello.c -lc -target      x86_64-linux-gnu.2.37
stage4/bin/zig build-exe hello.c -lc -target     aarch64-linux-gnu.2.37
stage4/bin/zig build-exe hello.c -lc -target         x86-linux-gnu.2.37
stage4/bin/zig build-exe hello.c -lc -target powerpc64le-linux-gnu.2.37

stage4/bin/zig build-exe hello.c -lc -target      x86_64-linux-gnu.2.36
stage4/bin/zig build-exe hello.c -lc -target     aarch64-linux-gnu.2.36
stage4/bin/zig build-exe hello.c -lc -target         x86-linux-gnu.2.36
stage4/bin/zig build-exe hello.c -lc -target powerpc64le-linux-gnu.2.36

stage4/bin/zig build-exe hello.c -lc -target      x86_64-linux-gnu.2.35
stage4/bin/zig build-exe hello.c -lc -target     aarch64-linux-gnu.2.35
stage4/bin/zig build-exe hello.c -lc -target         x86-linux-gnu.2.35
stage4/bin/zig build-exe hello.c -lc -target powerpc64le-linux-gnu.2.35

stage4/bin/zig build-exe hello.c -lc -target      x86_64-linux-gnu.2.34
stage4/bin/zig build-exe hello.c -lc -target     aarch64-linux-gnu.2.34
stage4/bin/zig build-exe hello.c -lc -target         x86-linux-gnu.2.34
stage4/bin/zig build-exe hello.c -lc -target powerpc64le-linux-gnu.2.34

These architectures correspond to the test matrix in test/tests.zig.

Next I will run the behavior tests and std lib tests against the full test matrix for glibc 2.38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants