Commit graph

39 commits

Author SHA1 Message Date
Alex Rønne Petersen
5702d67af6
glibc: Update source files to 2.41. 2025-01-31 14:38:21 +01:00
Andrew Kelley
b31a2c9555
Merge pull request #22541 from ziglang/pipeline
Compilation pipeline: spawn Jobs earlier that produce linker inputs
2025-01-21 14:27:05 -05:00
Alex Rønne Petersen
f1f269c6ee libc: Remove a bunch of code for architectures we don't actually support.
Namely:

* alpha
* hppa
* ia64
* microblaze
* nios2
* or1k
* s390
* sh
2025-01-21 09:30:16 +01:00
Andrew Kelley
f5485a52bc reject crti.o/crtn.o, embrace the future
crti.o/crtn.o is a legacy strategy for calling constructor functions
upon object loading that has been superseded by the
init_array/fini_array mechanism.

Zig code depends on neither, since the language intentionally has no way
to initialize data at runtime, but alas the Zig linker still must
support this feature since popular languages depend on it.

Anyway, the way it works is that crti.o has the machine code prelude of
two functions called _init and _fini, each in their own section with the
respective name. crtn.o has the machine code instructions comprising the
exitlude for each function. In between, objects use the .init and .fini
link section to populate the function body.

This function is then expected to be called upon object initialization
and deinitialization.

This mechanism is depended on by libc, for example musl and glibc, but
only for older ISAs. By the time the libcs gained support for newer
ISAs, they had moved on to the init_array/fini_array mechanism instead.

For the Zig linker, we are trying to move the linker towards
order-independent objects which is incompatible with the legacy
crti/crtn mechanism.

Therefore, this commit drops support entirely for crti/crtn mechanism,
which is necessary since the other commits in this branch make it
nondeterministic in which order the libc objects and the other link
inputs are sent to the linker.

The linker is still expected to produce a deterministic output, however,
by ignoring object input order for the purposes of symbol resolution.
2025-01-20 20:59:52 -08:00
Alex Rønne Petersen
50cae505f7
glibc: Fix an LP_SIZE redefinition warning for gnux32. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
c1cc63e5ff libc: Work around LLVM's misassembly of j <reg> on mips r6.
See: https://github.com/ziglang/zig/issues/21315
2024-09-23 17:26:30 -07:00
Andrew Kelley
96fcc8d63b
Merge pull request #21195 from alexrp/glibc-fixes
`glibc`: Some bug fixes, plus arc and csky start files
2024-09-06 10:50:56 -07:00
Alex Rønne Petersen
b230e4f598 glibc: Patch to work around missing features in LLVM's s390x assembler.
Revert this with LLVM 20.
2024-09-06 10:39:30 -07:00
Alex Rønne Petersen
747460025e
glibc: Add csky start files. 2024-09-05 06:16:26 +02:00
Alex Rønne Petersen
06945d5eb7
glibc: Add arc start files. 2024-09-05 06:16:26 +02:00
Alex Rønne Petersen
945fc7064b glibc: Add missing xstatver.h for some linux architectures.
Specifically for alpha, arm, hppa, microblaze, and sh.

Closes #20054.
2024-08-23 00:58:16 -07:00
YANG Xudong
0f0f543a9a
loongarch: add glibc start.S to make zig-bootstrap work for loongarch64-linux-gnu (#21015) 2024-08-14 21:32:03 +00:00
Alex Rønne Petersen
21ff35590c
Update glibc start files to 2.40. 2024-08-08 04:41:04 +02:00
Andrew Kelley
fd8b50ca5c glibc patch: remove some static asserts from fstatat
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.
2024-06-05 22:43:53 -07:00
Andrew Kelley
090025c457 glibc patch: add missing includes for inttypes.h
I don't know where glibc thinks uintptr_t is coming from, but here it
is.
2024-06-05 22:43:53 -07:00
Andrew Kelley
eead70f2d6 glibc patch: make fstatat.c and fstatat64.c compile
instead of importing every header file under the sun, I copied a couple
inline functions into these files to make them work.
2024-06-05 22:43:53 -07:00
Andrew Kelley
4c068c3be1 glibc patch: inline x86-lp_size.h
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.
2024-06-05 22:43:53 -07:00
Andrew Kelley
ad34de32a8 update glibc start files to 2.39
README file stays intact.
2024-06-05 22:43:53 -07:00
Kang Seonghoon
f1bd218a88 glibc: remove unused stat-related files for 2.33+
Effectively reverts 3dcd3612dc.
2024-01-04 17:12:07 -07:00
Andrew Kelley
701ef1f8c2 glibc patch: remove some static asserts from fstatat
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.
2023-10-13 19:32:54 -07:00
Andrew Kelley
6d8b7e95b5 glibc patch: add missing includes for inttypes.h
I don't know where glibc thinks uintptr_t is coming from, but here it
is.
2023-10-13 18:12:00 -07:00
Andrew Kelley
50e18343a9 glibc patch: make fstatat.c and fstatat64.c compile
instead of importing every header file under the sun, I copied a couple
inline functions into these files to make them work.
2023-10-13 18:06:12 -07:00
Andrew Kelley
89aa63bec7 glibc patch: inline x86-lp_size.h
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.
2023-10-13 18:03:00 -07:00
Andrew Kelley
2314051aca update glibc start files to 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.
2023-10-13 17:44:27 -07:00
sv99
d9a754e5e3
add arm-features.h from glibc source (#12346) 2022-11-25 12:43:37 +01:00
Andrew Kelley
3ed0741718 glibc: clean up build logic
also use the common naming convention for glibc versions ("2.33" rather
than "2-33").

I also verified that these files are exactly identical to the previous
files from before zig updated to glibc 2.34.
2022-01-14 12:39:06 -07:00
xavier
f1b14b91f1 glibc: restore compatibility with glibc<=2.33 for global initializers
__libc_start_main() from glibc.2.33.so or older needs to have a __libc_csu_init function callback parameter.

glibc-2.34 on the other hand has a different __libc_start_main() that does not use it,
and the start.S file from glibc-2.34 no longer construct the init function and pass null when calling __libc_start_main.

So, When targetting an older glibc, use the start.s files as they were in glibc-2.33 and construct the __libc_csu_init function.

fixes #10386 #10512
2022-01-14 11:48:37 -07:00
Andrew Kelley
e03c951a79 glibc: libc_nonshared.a: add missing includes for inttypes.h
I don't know where glibc thinks uintptr_t is coming from, but here it
is.
2021-12-16 03:01:13 -07:00
Andrew Kelley
37fa6f955d glibc: add stat_t64_cp.c to libnonshared.a
Fixes 32-bit architectures.
2021-12-16 03:01:13 -07:00
Andrew Kelley
bf2bd8e722 glibc: patches to make fstatat.c and fstatat64.c compile
instead of importing every header file under the sun, I copied a couple
inline functions into these files to make them work.
2021-12-16 03:01:13 -07:00
Andrew Kelley
5aeffab693 glibc: import sysdep.h from upstream
it's needed for mipsel-linux-gnueabihf
2021-12-15 19:12:24 -07:00
Andrew Kelley
e977455f7c glibc: improve RISC-V support
* omit crti.o / crtn.o for this architecture
 * add missing entry.h header from upstream
2021-12-15 18:34:27 -07:00
Andrew Kelley
3dcd3612dc glibc: use linux-specific files for nonshared
Upstream, some of the nonshared functions moved to be different for hurd
and for linux. Since our glibc is linux-only we update to use the
linux-specific files.

This fixes std lib tests for x86_64 when linking glibc.
2021-12-15 15:23:56 -07:00
Andrew Kelley
19ca2415f2 update glibc start files to 2.34
This commit introduces tools/update_glibc.zig to update the start files
for next time.

Some notable changes in recent glibc:

 * abi-note.S has been changed to abi-note.c but we resist the change to
   keep it easier to compile the start files.
 * elf-init.c has been deleted upstream. Further testing should be done
   to verify that binaries against glibc omitting elf-init.c still run
   properly on oldel glibc linux systems.

Closes #4926
2021-12-15 14:30:03 -07:00
Koakuma
f24d0fbb07 Remove SPARC pthreadtypes-arch.h to match upstream glibc
This is only a temporary measure, we need to properly update the bundled glibc.
2021-05-12 14:54:13 +07:00
LemonBoy
28a9e4c4aa libc: Add workaround for #4926
This change was cherry-picked from an updated version of the sysdep
folder contents, we're still shipping an outdated and incomplete set of
files.
2021-05-11 12:33:47 +02:00
Andrew Kelley
3ff2381042
update glibc source files to 2.31
This is mostly minor modifications to license text.
2020-03-04 14:59:09 -05:00
Andrew Kelley
7101e583d6
update glibc src files to 2.30 2019-09-10 16:40:54 -04:00
Andrew Kelley
49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00