diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2024-08-02 09:09:48 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2024-08-02 09:54:08 +0200 |
| commit | 923f114bdb4e1808d7f6f424a292c9775ada6f25 (patch) | |
| tree | 80a2ae3e45a9acd88f420207527250fa25767485 /src/glibc.zig | |
| parent | 3ebb8806635b8fb707dc0f260be902a9ae592ee0 (diff) | |
| download | zig-923f114bdb4e1808d7f6f424a292c9775ada6f25.tar.gz zig-923f114bdb4e1808d7f6f424a292c9775ada6f25.zip | |
glibc: Define NO_INITFINI for non-legacy architectures.
Diffstat (limited to 'src/glibc.zig')
| -rw-r--r-- | src/glibc.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/glibc.zig b/src/glibc.zig index 85f1828ad4..f61c8e5757 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -164,6 +164,21 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI return abi; } +fn useElfInitFini(target: std.Target) bool { + // Legacy architectures use _init/_fini. + return switch (target.cpu.arch) { + .arm, .armeb, .thumb, .thumbeb => true, + .aarch64, .aarch64_be => true, + .m68k => true, + .mips, .mipsel, .mips64, .mips64el => true, + .powerpc, .powerpcle, .powerpc64, .powerpc64le => true, + .s390x => true, + .sparc, .sparc64 => true, + .x86, .x86_64 => true, + else => false, + }; +} + pub const CRTFile = enum { crti_o, crtn_o, @@ -369,6 +384,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progre }); try add_include_dirs(comp, arena, &args); + if (!useElfInitFini(target)) { + try args.append("-DNO_INITFINI"); + } + if (target.cpu.arch == .x86) { // This prevents i386/sysdep.h from trying to do some // silly and unnecessary inline asm hack that uses weird |
