diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-08-07 01:14:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-07 01:14:54 -0700 |
| commit | cd5f673cae598decce04bc1d0e85775698ea48d9 (patch) | |
| tree | de34047700aa4bc727ce88aa5dd096eb3b8e14cf /src/glibc.zig | |
| parent | 8184912a9895523d23d03aa9bdcf607a56122a20 (diff) | |
| parent | f43c05690ed7f5a5f2db7dede06bba50016fa857 (diff) | |
| download | zig-cd5f673cae598decce04bc1d0e85775698ea48d9.tar.gz zig-cd5f673cae598decce04bc1d0e85775698ea48d9.zip | |
Merge pull request #20909 from alexrp/glibc-riscv
Support building glibc for riscv32/riscv64
Diffstat (limited to 'src/glibc.zig')
| -rw-r--r-- | src/glibc.zig | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/glibc.zig b/src/glibc.zig index b218b98fd8..a2c8e17430 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -153,6 +153,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, @@ -348,8 +363,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progre "-std=gnu11", "-fgnu89-inline", "-fmerge-all-constants", - // glibc sets this flag but clang does not support it. - // "-frounding-math", + "-frounding-math", "-fno-stack-protector", "-fno-common", "-fmath-errno", @@ -358,6 +372,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 |
