authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-21 14:27:05-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-01-21 14:27:05-05:00
logb31a2c95550e0fd6ee0b1e8908fad69d364ce6ab
treef21c96068ecc965008adf0bd58633b1c7274a02b
parent0bacb79c090aabb367987ed0cff3982b84b8a4f7
parent874e17fe608a7b8d4324dada32664fcfe44978cd
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #22541 from ziglang/pipeline

Compilation pipeline: spawn Jobs earlier that produce linker inputs

61 files changed, 235 insertions(+), 2494 deletions(-)

lib/libc/glibc/sysdeps/aarch64/crti.S deleted-103
...@@ -1,103 +0,0 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37/* crti.S puts a function prologue at the beginning of the .init and
38 .fini sections and defines global symbols for those addresses, so
39 they can be called as functions. The symbols _init and _fini are
40 magic and cause the linker to emit DT_INIT and DT_FINI. */
41
42#include <sysdep.h>
43#include <libc-symbols.h>
44
45#ifndef PREINIT_FUNCTION
46# define PREINIT_FUNCTION __gmon_start__
47#endif
48
49#ifndef PREINIT_FUNCTION_WEAK
50# define PREINIT_FUNCTION_WEAK 1
51#endif
52
53#if PREINIT_FUNCTION_WEAK
54 weak_extern (PREINIT_FUNCTION)
55#else
56 .hidden PREINIT_FUNCTION
57#endif
58
59#if PREINIT_FUNCTION_WEAK
60 .align 2
61 .type call_weak_fn, %function
62call_weak_fn:
63 adrp x0, :got:PREINIT_FUNCTION
64 ldr PTR_REG (0), [x0, #:got_lo12:PREINIT_FUNCTION]
65 cbz x0, 1f
66 b PREINIT_FUNCTION
671:
68 RET
69 .size call_weak_fn, .-call_weak_fn
70#endif
71
72 .section .init,"ax",%progbits
73 .align 2
74 .global _init
75 .hidden _init
76 .type _init, %function
77_init:
78#if HAVE_AARCH64_PAC_RET
79 PACIASP
80#else
81 BTI_C
82#endif
83 stp x29, x30, [sp, -16]!
84 mov x29, sp
85#if PREINIT_FUNCTION_WEAK
86 bl call_weak_fn
87#else
88 bl PREINIT_FUNCTION
89#endif
90
91 .section .fini,"ax",%progbits
92 .align 2
93 .global _fini
94 .hidden _fini
95 .type _fini, %function
96_fini:
97#if HAVE_AARCH64_PAC_RET
98 PACIASP
99#else
100 BTI_C
101#endif
102 stp x29, x30, [sp, -16]!
103 mov x29, sp
lib/libc/glibc/sysdeps/aarch64/crtn.S deleted-54
...@@ -1,54 +0,0 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37/* crtn.S puts function epilogues in the .init and .fini sections
38 corresponding to the prologues in crti.S. */
39
40#include <sysdep.h>
41
42 .section .init,"ax",%progbits
43 ldp x29, x30, [sp], 16
44#if HAVE_AARCH64_PAC_RET
45 AUTIASP
46#endif
47 RET
48
49 .section .fini,"ax",%progbits
50 ldp x29, x30, [sp], 16
51#if HAVE_AARCH64_PAC_RET
52 AUTIASP
53#endif
54 RET
lib/libc/glibc/sysdeps/arm/crti.S deleted-97
...@@ -1,97 +0,0 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41/* Always build .init and .fini sections in ARM mode. */
42#define NO_THUMB
43#include <libc-symbols.h>
44#include <sysdep.h>
45
46#ifndef PREINIT_FUNCTION
47# define PREINIT_FUNCTION __gmon_start__
48#endif
49
50#ifndef PREINIT_FUNCTION_WEAK
51# define PREINIT_FUNCTION_WEAK 1
52#endif
53
54#if PREINIT_FUNCTION_WEAK
55 weak_extern (PREINIT_FUNCTION)
56#else
57 .hidden PREINIT_FUNCTION
58#endif
59
60#if PREINIT_FUNCTION_WEAK
61 .p2align 2
62 .type call_weak_fn, %function
63call_weak_fn:
64 ldr r3, .LGOT
65 ldr r2, .LGOT+4
66.LPIC:
67 add r3, pc, r3
68 ldr r2, [r3, r2]
69 cmp r2, #0
70 bxeq lr
71 b PREINIT_FUNCTION
72 .p2align 2
73.LGOT:
74 .word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
75 .word PREINIT_FUNCTION(GOT)
76#endif
77
78 .section .init,"ax",%progbits
79 .p2align 2
80 .globl _init
81 .hidden _init
82 .type _init, %function
83_init:
84 push {r3, lr}
85#if PREINIT_FUNCTION_WEAK
86 bl call_weak_fn
87#else
88 bl PREINIT_FUNCTION
89#endif
90
91 .section .fini,"ax",%progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, %function
96_fini:
97 push {r3, lr}
lib/libc/glibc/sysdeps/arm/crtn.S deleted-57
...@@ -1,57 +0,0 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* Always build .init and .fini sections in ARM mode. */
37#define NO_THUMB
38#include <sysdep.h>
39
40/* crtn.S puts function epilogues in the .init and .fini sections
41 corresponding to the prologues in crti.S. */
42
43 .section .init,"ax",%progbits
44#ifdef __ARM_ARCH_4T__
45 pop {r3, lr}
46 bx lr
47#else
48 pop {r3, pc}
49#endif
50
51 .section .fini,"ax",%progbits
52#ifdef __ARM_ARCH_4T__
53 pop {r3, lr}
54 bx lr
55#else
56 pop {r3, pc}
57#endif
lib/libc/glibc/sysdeps/i386/crti.S deleted-86
...@@ -1,86 +0,0 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 pushl %ebx
65 /* Maintain 16-byte stack alignment for called functions. */
66 subl $8, %esp
67 LOAD_PIC_REG (bx)
68#if PREINIT_FUNCTION_WEAK
69 movl PREINIT_FUNCTION@GOT(%ebx), %eax
70 testl %eax, %eax
71 je .Lno_weak_fn
72 call *%eax
73.Lno_weak_fn:
74#else
75 call PREINIT_FUNCTION
76#endif
77
78 .section .fini,"ax",@progbits
79 .p2align 2
80 .globl _fini
81 .hidden _fini
82 .type _fini, @function
83_fini:
84 pushl %ebx
85 subl $8, %esp
86 LOAD_PIC_REG (bx)
lib/libc/glibc/sysdeps/i386/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addl $8, %esp
41 popl %ebx
42 ret
43
44 .section .fini,"ax",@progbits
45 addl $8, %esp
46 popl %ebx
47 ret
lib/libc/glibc/sysdeps/m68k/crti.S deleted-84
...@@ -1,84 +0,0 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 link.w %fp, #0
65 move.l %a5, -(%sp)
66 LOAD_GOT (%a5)
67#if PREINIT_FUNCTION_WEAK
68 tst.l PREINIT_FUNCTION@GOT(%a5)
69 jeq 1f
70 jbsr PREINIT_FUNCTION@PLTPC
711:
72#else
73 jbsr PREINIT_FUNCTION
74#endif
75
76 .section .fini,"ax",@progbits
77 .align 2
78 .globl _fini
79 .hidden _fini
80 .type _fini, @function
81_fini:
82 link.w %fp, #0
83 move.l %a5, -(%sp)
84 LOAD_GOT (%a5)
lib/libc/glibc/sysdeps/m68k/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 move.l -4(%fp), %a5
41 unlk %fp
42 rts
43
44 .section .fini,"ax",@progbits
45 move.l -4(%fp), %a5
46 unlk %fp
47 rts
lib/libc/glibc/sysdeps/mips/mips32/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 .set noreorder
72 .cpload $25
73 .set reorder
74 addiu $sp,$sp,-32
75 .cprestore 16
76 sw $31,28($sp)
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 .set noreorder
98 .cpload $25
99 .set reorder
100 addiu $sp,$sp,-32
101 .cprestore 16
102 sw $31,28($sp)
lib/libc/glibc/sysdeps/mips/mips32/crtn.S deleted-59
...@@ -1,59 +0,0 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 lw $31,28($sp)
43 .set noreorder
44 .set nomacro
45 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
46 jr $31
47 addiu $sp,$sp,32
48 .set macro
49 .set reorder
50
51 .section .fini,"ax",@progbits
52 lw $31,28($sp)
53 .set noreorder
54 .set nomacro
55 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
56 jr $31
57 addiu $sp,$sp,32
58 .set macro
59 .set reorder
lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 addiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 addu $28,$28,$25
75 sd $31,8($sp)
76 addiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 addiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 addu $28,$28,$25
101 sd $31,8($sp)
102 addiu $28,$28,%lo(%neg(%gp_rel(_fini)))
lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S deleted-61
...@@ -1,61 +0,0 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
47 jr $31
48 addiu $sp,$sp,16
49 .set macro
50 .set reorder
51
52 .section .fini,"ax",@progbits
53 ld $31,8($sp)
54 ld $28,0($sp)
55 .set noreorder
56 .set nomacro
57 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
58 jr $31
59 addiu $sp,$sp,16
60 .set macro
61 .set reorder
lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 daddiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 daddu $28,$28,$25
75 sd $31,8($sp)
76 daddiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 ld $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 ld $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 ld $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 daddiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 daddu $28,$28,$25
101 sd $31,8($sp)
102 daddiu $28,$28,%lo(%neg(%gp_rel(_fini)))
lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S deleted-61
...@@ -1,61 +0,0 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
47 jr $31
48 daddiu $sp,$sp,16
49 .set macro
50 .set reorder
51
52 .section .fini,"ax",@progbits
53 ld $31,8($sp)
54 ld $28,0($sp)
55 .set noreorder
56 .set nomacro
57 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
58 jr $31
59 daddiu $sp,$sp,16
60 .set macro
61 .set reorder
lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S deleted-91
...@@ -1,91 +0,0 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 stwu r1, -16(r1)
65 mflr r0
66 stw r0, 20(r1)
67 stw r30, 8(r1)
68 SETUP_GOT_ACCESS (r30, .Lgot_label_i)
69 addis r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@ha
70 addi r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@l
71#if PREINIT_FUNCTION_WEAK
72 lwz r0, PREINIT_FUNCTION@got(r30)
73 cmpwi cr7, r0, 0
74 beq+ cr7, 1f
75 bl PREINIT_FUNCTION@plt
761:
77#else
78 bl PREINIT_FUNCTION@local
79#endif
80
81 .section .fini,"ax",@progbits
82 .align 2
83 .globl _fini
84 .hidden _fini
85 .type _fini, @function
86_fini:
87 stwu r1, -16(r1)
88 mflr r0
89 stw r0, 20(r1)
90 stw r30, 8(r1)
91 SETUP_GOT_ACCESS (r30, .Lgot_label_f)
lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S deleted-53
...@@ -1,53 +0,0 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 lwz r0, 20(r1)
43 mtlr r0
44 lwz r30, 8(r1)
45 addi r1, r1, 16
46 blr
47
48 .section .fini,"ax",@progbits
49 lwz r0, 20(r1)
50 mtlr r0
51 lwz r30, 8(r1)
52 addi r1, r1, 16
53 blr
lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S deleted-90
...@@ -1,90 +0,0 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#if PREINIT_FUNCTION_WEAK
59 .section ".toc", "aw"
60.LC0:
61 .tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
62#endif
63 .section ".init", "ax", @progbits
64 ENTRY_2(_init)
65 .hidden _init
66 .align ALIGNARG (2)
67BODY_LABEL (_init):
68 LOCALENTRY(_init)
69 mflr 0
70 std 0, FRAME_LR_SAVE(r1)
71 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
72#if PREINIT_FUNCTION_WEAK
73 addis r9, r2, .LC0@toc@ha
74 ld r0, .LC0@toc@l(r9)
75 cmpdi cr7, r0, 0
76 beq+ cr7, 1f
77#endif
78 bl JUMPTARGET (PREINIT_FUNCTION)
79 nop
801:
81
82 .section ".fini", "ax", @progbits
83 ENTRY_2(_fini)
84 .hidden _fini
85 .align ALIGNARG (2)
86BODY_LABEL (_fini):
87 LOCALENTRY(_fini)
88 mflr 0
89 std 0, FRAME_LR_SAVE(r1)
90 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S deleted-51
...@@ -1,51 +0,0 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 addi r1, r1, FRAME_MIN_SIZE_PARM
43 ld r0, FRAME_LR_SAVE(r1)
44 mtlr r0
45 blr
46
47 .section .fini,"ax",@progbits
48 addi r1, r1, FRAME_MIN_SIZE_PARM
49 ld r0, FRAME_LR_SAVE(r1)
50 mtlr r0
51 blr
lib/libc/glibc/sysdeps/s390/s390-64/crti.S deleted-93
...@@ -1,93 +0,0 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 4
60 .globl _init
61 .hidden _init
62 .type _init,@function
63_init:
64 stmg %r6,%r15,48(%r15)
65 lgr %r1,%r15
66 aghi %r15,-160
67 stg %r1,0(%r15)
68 larl %r12,_GLOBAL_OFFSET_TABLE_
69#if PREINIT_FUNCTION_WEAK
70 /* zig patch: GOTENT -> GOT. revert with llvm 20. */
71 larl %r1,PREINIT_FUNCTION@GOT
72 lg %r1,0(%r1)
73 ltgr %r1,%r1
74 je 1f
75 basr %r14,%r1
76#else
77 brasl %r14,PREINIT_FUNCTION
78#endif
79 .align 4,0x07
801:
81
82 .section .fini,"ax",@progbits
83 .align 4
84 .globl _fini
85 .hidden _fini
86 .type _fini,@function
87_fini:
88 stmg %r6,%r15,48(%r15)
89 lg %r1,120(%r15)
90 aghi %r15,-160
91 stg %r1,0(%r15)
92 larl %r12,_GLOBAL_OFFSET_TABLE_
93 .align 4,0x07
lib/libc/glibc/sysdeps/s390/s390-64/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init
40 lg %r4,272(%r15)
41 lmg %r6,%r15,208(%r15)
42 br %r4
43
44 .section .fini
45 lg %r4,272(%r15)
46 lmg %r6,%r15,208(%r15)
47 br %r4
lib/libc/glibc/sysdeps/sparc/crti.S deleted-95
...@@ -1,95 +0,0 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#ifdef __arch64__
59#define STACKFRAME_SIZE 176
60#define GOT_LOAD ldx
61#else
62#define STACKFRAME_SIZE 96
63#define GOT_LOAD ld
64#endif
65
66 .section .init,"ax",@progbits
67 .p2align 2
68 .globl _init
69 .hidden _init
70 .type _init, @function
71_init:
72 save %sp, -STACKFRAME_SIZE, %sp
73#if PREINIT_FUNCTION_WEAK
74 SETUP_PIC_REG(l7)
75 sethi %gdop_hix22(PREINIT_FUNCTION), %g1
76 xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1
77 GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION)
78 cmp %g1, 0
79 be 1f
80 nop
81 call PREINIT_FUNCTION
82 nop
831:
84#else
85 call PREINIT_FUNCTION
86 nop
87#endif
88
89 .section .fini,"ax",@progbits
90 .p2align 2
91 .globl _fini
92 .hidden _fini
93 .type _fini, @function
94_fini:
95 save %sp, -STACKFRAME_SIZE, %sp
lib/libc/glibc/sysdeps/sparc/crtn.S deleted-45
...@@ -1,45 +0,0 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 jmp %i7 + 8
41 restore
42
43 .section .fini,"ax",@progbits
44 jmp %i7 + 8
45 restore
lib/libc/glibc/sysdeps/x86_64/crti.S deleted-84
...@@ -1,84 +0,0 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 _CET_ENDBR
65 /* Maintain 16-byte stack alignment for called functions. */
66 subq $8, %rsp
67#if PREINIT_FUNCTION_WEAK
68 movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax
69 testq %rax, %rax
70 je .Lno_weak_fn
71 call *%rax
72.Lno_weak_fn:
73#else
74 call PREINIT_FUNCTION
75#endif
76
77 .section .fini,"ax",@progbits
78 .p2align 2
79 .globl _fini
80 .hidden _fini
81 .type _fini, @function
82_fini:
83 _CET_ENDBR
84 subq $8, %rsp
lib/libc/glibc/sysdeps/x86_64/crtn.S deleted-45
...@@ -1,45 +0,0 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addq $8, %rsp
41 ret
42
43 .section .fini,"ax",@progbits
44 addq $8, %rsp
45 ret
lib/libc/musl/crt/aarch64/crti.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.global _init
3.type _init,%function
4_init:
5 stp x29,x30,[sp,-16]!
6 mov x29,sp
7
8.section .fini
9.global _fini
10.type _fini,%function
11_fini:
12 stp x29,x30,[sp,-16]!
13 mov x29,sp
lib/libc/musl/crt/aarch64/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 ldp x29,x30,[sp],#16
3 ret
4
5.section .fini
6 ldp x29,x30,[sp],#16
7 ret
lib/libc/musl/crt/arm/crti.s deleted-15
...@@ -1,15 +0,0 @@
1.syntax unified
2
3.section .init
4.global _init
5.type _init,%function
6.align 2
7_init:
8 push {r0,lr}
9
10.section .fini
11.global _fini
12.type _fini,%function
13.align 2
14_fini:
15 push {r0,lr}
lib/libc/musl/crt/arm/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.syntax unified
2
3.section .init
4 pop {r0,lr}
5 bx lr
6
7.section .fini
8 pop {r0,lr}
9 bx lr
lib/libc/musl/crt/crti.c deleted
lib/libc/musl/crt/crtn.c deleted
lib/libc/musl/crt/i386/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 sub $12,%esp
5
6.section .fini
7.global _fini
8_fini:
9 sub $12,%esp
lib/libc/musl/crt/i386/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 add $12,%esp
3 ret
4
5.section .fini
6 add $12,%esp
7 ret
lib/libc/musl/crt/microblaze/crti.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.global _init
3.align 2
4_init:
5 addi r1, r1, -32
6 swi r15, r1, 0
7
8.section .fini
9.global _fini
10.align 2
11_fini:
12 addi r1, r1, -32
13 swi r15, r1, 0
lib/libc/musl/crt/microblaze/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2 lwi r15, r1, 0
3 rtsd r15, 8
4 addi r1, r1, 32
5
6.section .fini
7 lwi r15, r1, 0
8 rtsd r15, 8
9 addi r1, r1, 32
lib/libc/musl/crt/mips/crti.s deleted-19
...@@ -1,19 +0,0 @@
1.set noreorder
2
3.section .init
4.global _init
5.type _init,@function
6.align 2
7_init:
8 subu $sp,$sp,32
9 sw $gp,24($sp)
10 sw $ra,28($sp)
11
12.section .fini
13.global _fini
14.type _fini,@function
15.align 2
16_fini:
17 subu $sp,$sp,32
18 sw $gp,24($sp)
19 sw $ra,28($sp)
lib/libc/musl/crt/mips/crtn.s deleted-15
...@@ -1,15 +0,0 @@
1.set noreorder
2
3.section .init
4 lw $gp,24($sp)
5 lw $ra,28($sp)
6 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
7 jr $ra
8 addu $sp,$sp,32
9
10.section .fini
11 lw $gp,24($sp)
12 lw $ra,28($sp)
13 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
14 jr $ra
15 addu $sp,$sp,32
lib/libc/musl/crt/mips64/crti.s deleted-17
...@@ -1,17 +0,0 @@
1.set noreorder
2
3.section .init
4.global _init
5.align 3
6_init:
7 dsubu $sp, $sp, 32
8 sd $gp, 16($sp)
9 sd $ra, 24($sp)
10
11.section .fini
12.global _fini
13.align 3
14_fini:
15 dsubu $sp, $sp, 32
16 sd $gp, 16($sp)
17 sd $ra, 24($sp)
lib/libc/musl/crt/mips64/crtn.s deleted-15
...@@ -1,15 +0,0 @@
1.set noreorder
2
3.section .init
4 ld $gp,16($sp)
5 ld $ra,24($sp)
6 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
7 jr $ra
8 daddu $sp,$sp,32
9
10.section .fini
11 ld $gp,16($sp)
12 ld $ra,24($sp)
13 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
14 jr $ra
15 daddu $sp,$sp,32
lib/libc/musl/crt/mipsn32/crti.s deleted-18
...@@ -1,18 +0,0 @@
1.set noreorder
2.section .init
3.global _init
4.type _init,@function
5.align 2
6_init:
7 subu $sp, $sp, 32
8 sd $gp, 16($sp)
9 sd $ra, 24($sp)
10
11.section .fini
12.global _fini
13.type _fini,@function
14.align 2
15_fini:
16 subu $sp, $sp, 32
17 sd $gp, 16($sp)
18 sd $ra, 24($sp)
lib/libc/musl/crt/mipsn32/crtn.s deleted-14
...@@ -1,14 +0,0 @@
1.set noreorder
2.section .init
3 ld $gp, 16($sp)
4 ld $ra, 24($sp)
5 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
6 jr $ra
7 addu $sp, $sp, 32
8
9.section .fini
10 ld $gp, 16($sp)
11 ld $ra, 24($sp)
12 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
13 jr $ra
14 addu $sp, $sp, 32
lib/libc/musl/crt/or1k/crti.s deleted-11
...@@ -1,11 +0,0 @@
1.section .init
2.global _init
3_init:
4 l.addi r1,r1,-4
5 l.sw 0(r1),r9
6
7.section .fini
8.global _fini
9_fini:
10 l.addi r1,r1,-4
11 l.sw 0(r1),r9
lib/libc/musl/crt/or1k/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2 l.lwz r9,0(r1)
3 l.jr r9
4 l.addi r1,r1,4
5
6.section .fini
7 l.lwz r9,0(r1)
8 l.jr r9
9 l.addi r1,r1,4
lib/libc/musl/crt/powerpc/crti.s deleted-15
...@@ -1,15 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 stwu 1,-32(1)
6 mflr 0
7 stw 0,36(1)
8
9.section .fini
10.align 2
11.global _fini
12_fini:
13 stwu 1,-32(1)
14 mflr 0
15 stw 0,36(1)
lib/libc/musl/crt/powerpc/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.align 2
3 lwz 0,36(1)
4 addi 1,1,32
5 mtlr 0
6 blr
7
8.section .fini
9.align 2
10 lwz 0,36(1)
11 addi 1,1,32
12 mtlr 0
13 blr
lib/libc/musl/crt/powerpc64/crti.s deleted-21
...@@ -1,21 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 addis 2, 12, .TOC.-_init@ha
6 addi 2, 2, .TOC.-_init@l
7 .localentry _init,.-_init
8 mflr 0
9 std 0, 16(1)
10 stdu 1,-32(1)
11
12.section .fini
13.align 2
14.global _fini
15_fini:
16 addis 2, 12, .TOC.-_fini@ha
17 addi 2, 2, .TOC.-_fini@l
18 .localentry _fini,.-_fini
19 mflr 0
20 std 0, 16(1)
21 stdu 1,-32(1)
lib/libc/musl/crt/powerpc64/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.align 2
3 addi 1, 1, 32
4 ld 0, 16(1)
5 mtlr 0
6 blr
7
8.section .fini
9.align 2
10 addi 1, 1, 32
11 ld 0, 16(1)
12 mtlr 0
13 blr
lib/libc/musl/crt/s390x/crti.s deleted-17
...@@ -1,17 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 stmg %r14, %r15, 112(%r15)
6 lgr %r0, %r15
7 aghi %r15, -160
8 stg %r0, 0(%r15)
9
10.section .fini
11.align 2
12.global _fini
13_fini:
14 stmg %r14, %r15, 112(%r15)
15 lgr %r0, %r15
16 aghi %r15, -160
17 stg %r0, 0(%r15)
lib/libc/musl/crt/s390x/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.align 2
3 lmg %r14, %r15, 272(%r15)
4 br %r14
5
6.section .fini
7.align 2
8 lmg %r14, %r15, 272(%r15)
9 br %r14
lib/libc/musl/crt/sh/crti.s deleted-21
...@@ -1,21 +0,0 @@
1.section .init
2.global _init
3.type _init, @function
4_init:
5 add #-4, r15
6 mov.l r12, @-r15
7 mov.l r14, @-r15
8 sts.l pr, @-r15
9 mov r15, r14
10 nop
11
12.section .fini
13.global _fini
14.type _fini, @function
15_fini:
16 add #-4, r15
17 mov.l r12, @-r15
18 mov.l r14, @-r15
19 sts.l pr, @-r15
20 mov r15, r14
21 nop
lib/libc/musl/crt/sh/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2 lds.l @r15+, pr
3 mov.l @r15+, r14
4 mov.l @r15+, r12
5 rts
6 add #4, r15
7
8.section .fini
9 lds.l @r15+, pr
10 mov.l @r15+, r14
11 mov.l @r15+, r12
12 rts
13 add #4, r15
lib/libc/musl/crt/x32/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 push %rax
5
6.section .fini
7.global _fini
8_fini:
9 push %rax
lib/libc/musl/crt/x32/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 pop %rax
3 ret
4
5.section .fini
6 pop %rax
7 ret
lib/libc/musl/crt/x86_64/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 push %rax
5
6.section .fini
7.global _fini
8_fini:
9 push %rax
lib/libc/musl/crt/x86_64/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 pop %rax
3 ret
4
5.section .fini
6 pop %rax
7 ret
src/Compilation.zig+213-227
...@@ -122,6 +122,10 @@ link_task_queue_postponed: std.ArrayListUnmanaged(link.Task) = .empty,...@@ -122,6 +122,10 @@ link_task_queue_postponed: std.ArrayListUnmanaged(link.Task) = .empty,
122/// the linker task thread.122/// the linker task thread.
123remaining_prelink_tasks: u32,123remaining_prelink_tasks: u32,
124124
125/// Set of work that can be represented by only flags to determine whether the
126/// work is queued or not.
127queued_jobs: QueuedJobs,
128
125work_queues: [129work_queues: [
126 len: {130 len: {
127 var len: usize = 0;131 var len: usize = 0;
...@@ -193,10 +197,6 @@ stack_report: bool,...@@ -193,10 +197,6 @@ stack_report: bool,
193debug_compiler_runtime_libs: bool,197debug_compiler_runtime_libs: bool,
194debug_compile_errors: bool,198debug_compile_errors: bool,
195incremental: bool,199incremental: bool,
196job_queued_compiler_rt_lib: bool = false,
197job_queued_compiler_rt_obj: bool = false,
198job_queued_fuzzer_lib: bool = false,
199job_queued_update_builtin_zig: bool,
200alloc_failure_occurred: bool = false,200alloc_failure_occurred: bool = false,
201last_update_was_cache_hit: bool = false,201last_update_was_cache_hit: bool = false,
202202
...@@ -234,13 +234,13 @@ tsan_lib: ?CrtFile = null,...@@ -234,13 +234,13 @@ tsan_lib: ?CrtFile = null,
234/// and resolved before calling linker.flush().234/// and resolved before calling linker.flush().
235libc_static_lib: ?CrtFile = null,235libc_static_lib: ?CrtFile = null,
236/// Populated when we build the libcompiler_rt static library. A Job to build this is indicated236/// Populated when we build the libcompiler_rt static library. A Job to build this is indicated
237/// by setting `job_queued_compiler_rt_lib` and resolved before calling linker.flush().237/// by setting `queued_jobs.compiler_rt_lib` and resolved before calling linker.flush().
238compiler_rt_lib: ?CrtFile = null,238compiler_rt_lib: ?CrtFile = null,
239/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated239/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated
240/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush().240/// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush().
241compiler_rt_obj: ?CrtFile = null,241compiler_rt_obj: ?CrtFile = null,
242/// Populated when we build the libfuzzer static library. A Job to build this242/// Populated when we build the libfuzzer static library. A Job to build this
243/// is indicated by setting `job_queued_fuzzer_lib` and resolved before243/// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before
244/// calling linker.flush().244/// calling linker.flush().
245fuzzer_lib: ?CrtFile = null,245fuzzer_lib: ?CrtFile = null,
246246
...@@ -284,6 +284,27 @@ file_system_inputs: ?*std.ArrayListUnmanaged(u8),...@@ -284,6 +284,27 @@ file_system_inputs: ?*std.ArrayListUnmanaged(u8),
284/// This digest will be known after update() is called.284/// This digest will be known after update() is called.
285digest: ?[Cache.bin_digest_len]u8 = null,285digest: ?[Cache.bin_digest_len]u8 = null,
286286
287const QueuedJobs = struct {
288 compiler_rt_lib: bool = false,
289 compiler_rt_obj: bool = false,
290 fuzzer_lib: bool = false,
291 update_builtin_zig: bool,
292 musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = @splat(false),
293 glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = @splat(false),
294 /// one of WASI libc static objects
295 wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = @splat(false),
296 /// one of the mingw-w64 static objects
297 mingw_crt_file: [@typeInfo(mingw.CrtFile).@"enum".fields.len]bool = @splat(false),
298 /// all of the glibc shared objects
299 glibc_shared_objects: bool = false,
300 /// libunwind.a, usually needed when linking libc
301 libunwind: bool = false,
302 libcxx: bool = false,
303 libcxxabi: bool = false,
304 libtsan: bool = false,
305 zig_libc: bool = false,
306};
307
287pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size;308pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size;
288pub const SemaError = Zcu.SemaError;309pub const SemaError = Zcu.SemaError;
289310
...@@ -377,26 +398,6 @@ const Job = union(enum) {...@@ -377,26 +398,6 @@ const Job = union(enum) {
377 /// Fully resolve the given `struct` or `union` type.398 /// Fully resolve the given `struct` or `union` type.
378 resolve_type_fully: InternPool.Index,399 resolve_type_fully: InternPool.Index,
379400
380 /// one of the glibc static objects
381 glibc_crt_file: glibc.CrtFile,
382 /// all of the glibc shared objects
383 glibc_shared_objects,
384 /// one of the musl static objects
385 musl_crt_file: musl.CrtFile,
386 /// one of the mingw-w64 static objects
387 mingw_crt_file: mingw.CrtFile,
388
389 /// libunwind.a, usually needed when linking libc
390 libunwind: void,
391 libcxx: void,
392 libcxxabi: void,
393 libtsan: void,
394 /// needed when not linking libc and using LLVM for code generation because it generates
395 /// calls to, for example, memcpy and memset.
396 zig_libc: void,
397 /// one of WASI libc static objects
398 wasi_libc_crt_file: wasi_libc.CrtFile,
399
400 /// The value is the index into `windows_libs`.401 /// The value is the index into `windows_libs`.
401 windows_import_lib: usize,402 windows_import_lib: usize,
402403
...@@ -800,8 +801,6 @@ pub const MiscTask = enum {...@@ -800,8 +801,6 @@ pub const MiscTask = enum {
800 docs_copy,801 docs_copy,
801 docs_wasm,802 docs_wasm,
802803
803 @"musl crti.o",
804 @"musl crtn.o",
805 @"musl crt1.o",804 @"musl crt1.o",
806 @"musl rcrt1.o",805 @"musl rcrt1.o",
807 @"musl Scrt1.o",806 @"musl Scrt1.o",
...@@ -816,8 +815,6 @@ pub const MiscTask = enum {...@@ -816,8 +815,6 @@ pub const MiscTask = enum {
816 @"libwasi-emulated-mman.a",815 @"libwasi-emulated-mman.a",
817 @"libwasi-emulated-signal.a",816 @"libwasi-emulated-signal.a",
818817
819 @"glibc crti.o",
820 @"glibc crtn.o",
821 @"glibc Scrt1.o",818 @"glibc Scrt1.o",
822 @"glibc libc_nonshared.a",819 @"glibc libc_nonshared.a",
823 @"glibc shared object",820 @"glibc shared object",
...@@ -1512,7 +1509,9 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1512,7 +1509,9 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1512 .framework_dirs = options.framework_dirs,1509 .framework_dirs = options.framework_dirs,
1513 .llvm_opt_bisect_limit = options.llvm_opt_bisect_limit,1510 .llvm_opt_bisect_limit = options.llvm_opt_bisect_limit,
1514 .skip_linker_dependencies = options.skip_linker_dependencies,1511 .skip_linker_dependencies = options.skip_linker_dependencies,
1515 .job_queued_update_builtin_zig = have_zcu,1512 .queued_jobs = .{
1513 .update_builtin_zig = have_zcu,
1514 },
1516 .function_sections = options.function_sections,1515 .function_sections = options.function_sections,
1517 .data_sections = options.data_sections,1516 .data_sections = options.data_sections,
1518 .native_system_include_paths = options.native_system_include_paths,1517 .native_system_include_paths = options.native_system_include_paths,
...@@ -1804,64 +1803,44 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1804,64 +1803,44 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1804 } else if (target.isMusl() and !target.isWasm()) {1803 } else if (target.isMusl() and !target.isWasm()) {
1805 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1804 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18061805
1807 if (musl.needsCrtiCrtn(target)) {
1808 try comp.queueJobs(&[_]Job{
1809 .{ .musl_crt_file = .crti_o },
1810 .{ .musl_crt_file = .crtn_o },
1811 });
1812 comp.remaining_prelink_tasks += 2;
1813 }
1814 if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {1806 if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {
1815 try comp.queueJobs(&.{.{ .musl_crt_file = f }});1807 comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true;
1816 comp.remaining_prelink_tasks += 1;1808 comp.remaining_prelink_tasks += 1;
1817 }1809 }
1818 try comp.queueJobs(&.{.{ .musl_crt_file = switch (comp.config.link_mode) {1810 switch (comp.config.link_mode) {
1819 .static => .libc_a,1811 .static => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_a)] = true,
1820 .dynamic => .libc_so,1812 .dynamic => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_so)] = true,
1821 } }});1813 }
1822 comp.remaining_prelink_tasks += 1;1814 comp.remaining_prelink_tasks += 1;
1823 } else if (target.isGnuLibC()) {1815 } else if (target.isGnuLibC()) {
1824 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1816 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18251817
1826 if (glibc.needsCrtiCrtn(target)) {
1827 try comp.queueJobs(&[_]Job{
1828 .{ .glibc_crt_file = .crti_o },
1829 .{ .glibc_crt_file = .crtn_o },
1830 });
1831 comp.remaining_prelink_tasks += 2;
1832 }
1833 if (glibc.needsCrt0(comp.config.output_mode)) |f| {1818 if (glibc.needsCrt0(comp.config.output_mode)) |f| {
1834 try comp.queueJobs(&.{.{ .glibc_crt_file = f }});1819 comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true;
1835 comp.remaining_prelink_tasks += 1;1820 comp.remaining_prelink_tasks += 1;
1836 }1821 }
1837 try comp.queueJobs(&[_]Job{1822 comp.queued_jobs.glibc_shared_objects = true;
1838 .{ .glibc_shared_objects = {} },
1839 .{ .glibc_crt_file = .libc_nonshared_a },
1840 });
1841 comp.remaining_prelink_tasks += 1;
1842 comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target);1823 comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target);
1824
1825 comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true;
1826 comp.remaining_prelink_tasks += 1;
1843 } else if (target.isWasm() and target.os.tag == .wasi) {1827 } else if (target.isWasm() and target.os.tag == .wasi) {
1844 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1828 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18451829
1846 for (comp.wasi_emulated_libs) |crt_file| {1830 for (comp.wasi_emulated_libs) |crt_file| {
1847 try comp.queueJob(.{1831 comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(crt_file)] = true;
1848 .wasi_libc_crt_file = crt_file,
1849 });
1850 comp.remaining_prelink_tasks += 1;
1851 }1832 }
1852 try comp.queueJobs(&[_]Job{1833 comp.remaining_prelink_tasks += @intCast(comp.wasi_emulated_libs.len);
1853 .{ .wasi_libc_crt_file = wasi_libc.execModelCrtFile(comp.config.wasi_exec_model) },1834
1854 .{ .wasi_libc_crt_file = .libc_a },1835 comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.execModelCrtFile(comp.config.wasi_exec_model))] = true;
1855 });1836 comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.CrtFile.libc_a)] = true;
1856 comp.remaining_prelink_tasks += 2;1837 comp.remaining_prelink_tasks += 2;
1857 } else if (target.isMinGW()) {1838 } else if (target.isMinGW()) {
1858 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1839 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18591840
1860 const crt_job: Job = .{ .mingw_crt_file = if (is_dyn_lib) .dllcrt2_o else .crt2_o };1841 const main_crt_file: mingw.CrtFile = if (is_dyn_lib) .dllcrt2_o else .crt2_o;
1861 try comp.queueJobs(&.{1842 comp.queued_jobs.mingw_crt_file[@intFromEnum(main_crt_file)] = true;
1862 .{ .mingw_crt_file = .mingw32_lib },1843 comp.queued_jobs.mingw_crt_file[@intFromEnum(mingw.CrtFile.mingw32_lib)] = true;
1863 crt_job,
1864 });
1865 comp.remaining_prelink_tasks += 2;1844 comp.remaining_prelink_tasks += 2;
18661845
1867 // When linking mingw-w64 there are some import libs we always need.1846 // When linking mingw-w64 there are some import libs we always need.
...@@ -1873,7 +1852,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1873,7 +1852,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1873 else => return error.LibCUnavailable,1852 else => return error.LibCUnavailable,
1874 }1853 }
1875 } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) {1854 } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) {
1876 try comp.queueJob(.{ .zig_libc = {} });1855 comp.queued_jobs.zig_libc = true;
1877 comp.remaining_prelink_tasks += 1;1856 comp.remaining_prelink_tasks += 1;
1878 } else {1857 } else {
1879 return error.LibCUnavailable;1858 return error.LibCUnavailable;
...@@ -1886,18 +1865,22 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1886,18 +1865,22 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1886 for (0..count) |i| {1865 for (0..count) |i| {
1887 try comp.queueJob(.{ .windows_import_lib = i });1866 try comp.queueJob(.{ .windows_import_lib = i });
1888 }1867 }
1868 // when integrating coff linker with prelink, the above
1869 // queueJob will need to change into something else since those
1870 // jobs are dispatched *after* the link_task_wait_group.wait()
1871 // that happens when separateCodegenThreadOk() is false.
1889 }1872 }
1890 if (comp.wantBuildLibUnwindFromSource()) {1873 if (comp.wantBuildLibUnwindFromSource()) {
1891 try comp.queueJob(.{ .libunwind = {} });1874 comp.queued_jobs.libunwind = true;
1892 comp.remaining_prelink_tasks += 1;1875 comp.remaining_prelink_tasks += 1;
1893 }1876 }
1894 if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.link_libcpp) {1877 if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.link_libcpp) {
1895 try comp.queueJob(.libcxx);1878 comp.queued_jobs.libcxx = true;
1896 try comp.queueJob(.libcxxabi);1879 comp.queued_jobs.libcxxabi = true;
1897 comp.remaining_prelink_tasks += 2;1880 comp.remaining_prelink_tasks += 2;
1898 }1881 }
1899 if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.any_sanitize_thread) {1882 if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.any_sanitize_thread) {
1900 try comp.queueJob(.libtsan);1883 comp.queued_jobs.libtsan = true;
1901 comp.remaining_prelink_tasks += 1;1884 comp.remaining_prelink_tasks += 1;
1902 }1885 }
19031886
...@@ -1916,20 +1899,20 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1916,20 +1899,20 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1916 if (comp.include_compiler_rt and capable_of_building_compiler_rt) {1899 if (comp.include_compiler_rt and capable_of_building_compiler_rt) {
1917 if (is_exe_or_dyn_lib) {1900 if (is_exe_or_dyn_lib) {
1918 log.debug("queuing a job to build compiler_rt_lib", .{});1901 log.debug("queuing a job to build compiler_rt_lib", .{});
1919 comp.job_queued_compiler_rt_lib = true;1902 comp.queued_jobs.compiler_rt_lib = true;
1920 comp.remaining_prelink_tasks += 1;1903 comp.remaining_prelink_tasks += 1;
1921 } else if (output_mode != .Obj) {1904 } else if (output_mode != .Obj) {
1922 log.debug("queuing a job to build compiler_rt_obj", .{});1905 log.debug("queuing a job to build compiler_rt_obj", .{});
1923 // In this case we are making a static library, so we ask1906 // In this case we are making a static library, so we ask
1924 // for a compiler-rt object to put in it.1907 // for a compiler-rt object to put in it.
1925 comp.job_queued_compiler_rt_obj = true;1908 comp.queued_jobs.compiler_rt_obj = true;
1926 comp.remaining_prelink_tasks += 1;1909 comp.remaining_prelink_tasks += 1;
1927 }1910 }
1928 }1911 }
19291912
1930 if (is_exe_or_dyn_lib and comp.config.any_fuzz and capable_of_building_compiler_rt) {1913 if (is_exe_or_dyn_lib and comp.config.any_fuzz and capable_of_building_compiler_rt) {
1931 log.debug("queuing a job to build libfuzzer", .{});1914 log.debug("queuing a job to build libfuzzer", .{});
1932 comp.job_queued_fuzzer_lib = true;1915 comp.queued_jobs.fuzzer_lib = true;
1933 comp.remaining_prelink_tasks += 1;1916 comp.remaining_prelink_tasks += 1;
1934 }1917 }
1935 }1918 }
...@@ -3712,21 +3695,70 @@ fn performAllTheWorkInner(...@@ -3712,21 +3695,70 @@ fn performAllTheWorkInner(
3712 work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node });3695 work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node });
3713 }3696 }
37143697
3715 if (comp.job_queued_compiler_rt_lib) {3698 if (testAndClear(&comp.queued_jobs.compiler_rt_lib)) {
3716 comp.job_queued_compiler_rt_lib = false;
3717 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node });3699 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node });
3718 }3700 }
37193701
3720 if (comp.job_queued_compiler_rt_obj) {3702 if (testAndClear(&comp.queued_jobs.compiler_rt_obj)) {
3721 comp.job_queued_compiler_rt_obj = false;
3722 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node });3703 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node });
3723 }3704 }
37243705
3725 if (comp.job_queued_fuzzer_lib) {3706 if (testAndClear(&comp.queued_jobs.fuzzer_lib)) {
3726 comp.job_queued_fuzzer_lib = false;
3727 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node });3707 comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node });
3728 }3708 }
37293709
3710 if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) {
3711 comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node });
3712 }
3713
3714 if (testAndClear(&comp.queued_jobs.libunwind)) {
3715 comp.link_task_wait_group.spawnManager(buildLibUnwind, .{ comp, main_progress_node });
3716 }
3717
3718 if (testAndClear(&comp.queued_jobs.libcxx)) {
3719 comp.link_task_wait_group.spawnManager(buildLibCxx, .{ comp, main_progress_node });
3720 }
3721
3722 if (testAndClear(&comp.queued_jobs.libcxxabi)) {
3723 comp.link_task_wait_group.spawnManager(buildLibCxxAbi, .{ comp, main_progress_node });
3724 }
3725
3726 if (testAndClear(&comp.queued_jobs.libtsan)) {
3727 comp.link_task_wait_group.spawnManager(buildLibTsan, .{ comp, main_progress_node });
3728 }
3729
3730 if (testAndClear(&comp.queued_jobs.zig_libc)) {
3731 comp.link_task_wait_group.spawnManager(buildZigLibc, .{ comp, main_progress_node });
3732 }
3733
3734 for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| {
3735 if (testAndClear(&comp.queued_jobs.musl_crt_file[i])) {
3736 const tag: musl.CrtFile = @enumFromInt(i);
3737 comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node });
3738 }
3739 }
3740
3741 for (0..@typeInfo(glibc.CrtFile).@"enum".fields.len) |i| {
3742 if (testAndClear(&comp.queued_jobs.glibc_crt_file[i])) {
3743 const tag: glibc.CrtFile = @enumFromInt(i);
3744 comp.link_task_wait_group.spawnManager(buildGlibcCrtFile, .{ comp, tag, main_progress_node });
3745 }
3746 }
3747
3748 for (0..@typeInfo(wasi_libc.CrtFile).@"enum".fields.len) |i| {
3749 if (testAndClear(&comp.queued_jobs.wasi_libc_crt_file[i])) {
3750 const tag: wasi_libc.CrtFile = @enumFromInt(i);
3751 comp.link_task_wait_group.spawnManager(buildWasiLibcCrtFile, .{ comp, tag, main_progress_node });
3752 }
3753 }
3754
3755 for (0..@typeInfo(mingw.CrtFile).@"enum".fields.len) |i| {
3756 if (testAndClear(&comp.queued_jobs.mingw_crt_file[i])) {
3757 const tag: mingw.CrtFile = @enumFromInt(i);
3758 comp.link_task_wait_group.spawnManager(buildMingwCrtFile, .{ comp, tag, main_progress_node });
3759 }
3760 }
3761
3730 {3762 {
3731 const astgen_frame = tracy.namedFrame("astgen");3763 const astgen_frame = tracy.namedFrame("astgen");
3732 defer astgen_frame.end();3764 defer astgen_frame.end();
...@@ -3741,8 +3773,8 @@ fn performAllTheWorkInner(...@@ -3741,8 +3773,8 @@ fn performAllTheWorkInner(
3741 // 1. to avoid race condition of zig processes truncating each other's builtin.zig files3773 // 1. to avoid race condition of zig processes truncating each other's builtin.zig files
3742 // 2. optimization; in the hot path it only incurs a stat() syscall, which happens3774 // 2. optimization; in the hot path it only incurs a stat() syscall, which happens
3743 // in the `astgen_wait_group`.3775 // in the `astgen_wait_group`.
3744 if (comp.job_queued_update_builtin_zig) b: {3776 if (comp.queued_jobs.update_builtin_zig) b: {
3745 comp.job_queued_update_builtin_zig = false;3777 comp.queued_jobs.update_builtin_zig = false;
3746 if (comp.zcu == null) break :b;3778 if (comp.zcu == null) break :b;
3747 // TODO put all the modules in a flat array to make them easy to iterate.3779 // TODO put all the modules in a flat array to make them easy to iterate.
3748 var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .empty;3780 var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .empty;
...@@ -3821,11 +3853,12 @@ fn performAllTheWorkInner(...@@ -3821,11 +3853,12 @@ fn performAllTheWorkInner(
3821 comp.link_task_wait_group.wait();3853 comp.link_task_wait_group.wait();
3822 comp.link_task_wait_group.reset();3854 comp.link_task_wait_group.reset();
3823 std.log.scoped(.link).debug("finished waiting for link_task_wait_group", .{});3855 std.log.scoped(.link).debug("finished waiting for link_task_wait_group", .{});
3856 assert(comp.remaining_prelink_tasks == 0);
3824 }3857 }
38253858
3826 work: while (true) {3859 work: while (true) {
3827 for (&comp.work_queues) |*work_queue| if (work_queue.readItem()) |job| {3860 for (&comp.work_queues) |*work_queue| if (work_queue.readItem()) |job| {
3828 try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job, main_progress_node);3861 try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job);
3829 continue :work;3862 continue :work;
3830 };3863 };
3831 if (comp.zcu) |zcu| {3864 if (comp.zcu) |zcu| {
...@@ -3860,7 +3893,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void {...@@ -3860,7 +3893,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void {
3860 for (jobs) |job| try comp.queueJob(job);3893 for (jobs) |job| try comp.queueJob(job);
3861}3894}
38623895
3863fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progress.Node) JobError!void {3896fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void {
3864 switch (job) {3897 switch (job) {
3865 .codegen_nav => |nav_index| {3898 .codegen_nav => |nav_index| {
3866 const zcu = comp.zcu.?;3899 const zcu = comp.zcu.?;
...@@ -3956,56 +3989,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre...@@ -3956,56 +3989,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
3956 error.AnalysisFail => return,3989 error.AnalysisFail => return,
3957 };3990 };
3958 },3991 },
3959 .glibc_crt_file => |crt_file| {
3960 const named_frame = tracy.namedFrame("glibc_crt_file");
3961 defer named_frame.end();
3962
3963 glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| {
3964 // TODO Surface more error details.
3965 comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{
3966 @errorName(err),
3967 });
3968 };
3969 },
3970 .glibc_shared_objects => {
3971 const named_frame = tracy.namedFrame("glibc_shared_objects");
3972 defer named_frame.end();
3973
3974 glibc.buildSharedObjects(comp, prog_node) catch |err| {
3975 // TODO Surface more error details.
3976 comp.lockAndSetMiscFailure(
3977 .glibc_shared_objects,
3978 "unable to build glibc shared objects: {s}",
3979 .{@errorName(err)},
3980 );
3981 };
3982 },
3983 .musl_crt_file => |crt_file| {
3984 const named_frame = tracy.namedFrame("musl_crt_file");
3985 defer named_frame.end();
3986
3987 musl.buildCrtFile(comp, crt_file, prog_node) catch |err| {
3988 // TODO Surface more error details.
3989 comp.lockAndSetMiscFailure(
3990 .musl_crt_file,
3991 "unable to build musl CRT file: {s}",
3992 .{@errorName(err)},
3993 );
3994 };
3995 },
3996 .mingw_crt_file => |crt_file| {
3997 const named_frame = tracy.namedFrame("mingw_crt_file");
3998 defer named_frame.end();
3999
4000 mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| {
4001 // TODO Surface more error details.
4002 comp.lockAndSetMiscFailure(
4003 .mingw_crt_file,
4004 "unable to build mingw-w64 CRT file {s}: {s}",
4005 .{ @tagName(crt_file), @errorName(err) },
4006 );
4007 };
4008 },
4009 .windows_import_lib => |index| {3992 .windows_import_lib => |index| {
4010 const named_frame = tracy.namedFrame("windows_import_lib");3993 const named_frame = tracy.namedFrame("windows_import_lib");
4011 defer named_frame.end();3994 defer named_frame.end();
...@@ -4020,95 +4003,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre...@@ -4020,95 +4003,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre
4020 );4003 );
4021 };4004 };
4022 },4005 },
4023 .libunwind => {
4024 const named_frame = tracy.namedFrame("libunwind");
4025 defer named_frame.end();
4026
4027 libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) {
4028 error.OutOfMemory => return error.OutOfMemory,
4029 error.SubCompilationFailed => return, // error reported already
4030 else => comp.lockAndSetMiscFailure(
4031 .libunwind,
4032 "unable to build libunwind: {s}",
4033 .{@errorName(err)},
4034 ),
4035 };
4036 },
4037 .libcxx => {
4038 const named_frame = tracy.namedFrame("libcxx");
4039 defer named_frame.end();
4040
4041 libcxx.buildLibCXX(comp, prog_node) catch |err| switch (err) {
4042 error.OutOfMemory => return error.OutOfMemory,
4043 error.SubCompilationFailed => return, // error reported already
4044 else => comp.lockAndSetMiscFailure(
4045 .libcxx,
4046 "unable to build libcxx: {s}",
4047 .{@errorName(err)},
4048 ),
4049 };
4050 },
4051 .libcxxabi => {
4052 const named_frame = tracy.namedFrame("libcxxabi");
4053 defer named_frame.end();
4054
4055 libcxx.buildLibCXXABI(comp, prog_node) catch |err| switch (err) {
4056 error.OutOfMemory => return error.OutOfMemory,
4057 error.SubCompilationFailed => return, // error reported already
4058 else => comp.lockAndSetMiscFailure(
4059 .libcxxabi,
4060 "unable to build libcxxabi: {s}",
4061 .{@errorName(err)},
4062 ),
4063 };
4064 },
4065 .libtsan => {
4066 const named_frame = tracy.namedFrame("libtsan");
4067 defer named_frame.end();
4068
4069 libtsan.buildTsan(comp, prog_node) catch |err| switch (err) {
4070 error.OutOfMemory => return error.OutOfMemory,
4071 error.SubCompilationFailed => return, // error reported already
4072 else => comp.lockAndSetMiscFailure(
4073 .libtsan,
4074 "unable to build TSAN library: {s}",
4075 .{@errorName(err)},
4076 ),
4077 };
4078 },
4079 .wasi_libc_crt_file => |crt_file| {
4080 const named_frame = tracy.namedFrame("wasi_libc_crt_file");
4081 defer named_frame.end();
4082
4083 wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| {
4084 // TODO Surface more error details.
4085 comp.lockAndSetMiscFailure(
4086 .wasi_libc_crt_file,
4087 "unable to build WASI libc CRT file: {s}",
4088 .{@errorName(err)},
4089 );
4090 };
4091 },
4092 .zig_libc => {
4093 const named_frame = tracy.namedFrame("zig_libc");
4094 defer named_frame.end();
4095
4096 comp.buildOutputFromZig(
4097 "c.zig",
4098 .Lib,
4099 &comp.libc_static_lib,
4100 .zig_libc,
4101 prog_node,
4102 ) catch |err| switch (err) {
4103 error.OutOfMemory => return error.OutOfMemory,
4104 error.SubCompilationFailed => return, // error reported already
4105 else => comp.lockAndSetMiscFailure(
4106 .zig_libc,
4107 "unable to build zig's multitarget libc: {s}",
4108 .{@errorName(err)},
4109 ),
4110 };
4111 },
4112 }4006 }
4113}4007}
41144008
...@@ -4761,6 +4655,92 @@ fn buildRt(...@@ -4761,6 +4655,92 @@ fn buildRt(
4761 };4655 };
4762}4656}
47634657
4658fn buildMuslCrtFile(comp: *Compilation, crt_file: musl.CrtFile, prog_node: std.Progress.Node) void {
4659 musl.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) {
4660 error.SubCompilationFailed => return, // error reported already
4661 else => comp.lockAndSetMiscFailure(.musl_crt_file, "unable to build musl {s}: {s}", .{
4662 @tagName(crt_file), @errorName(err),
4663 }),
4664 };
4665}
4666
4667fn buildGlibcCrtFile(comp: *Compilation, crt_file: glibc.CrtFile, prog_node: std.Progress.Node) void {
4668 glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) {
4669 error.SubCompilationFailed => return, // error reported already
4670 else => comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc {s}: {s}", .{
4671 @tagName(crt_file), @errorName(err),
4672 }),
4673 };
4674}
4675
4676fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void {
4677 glibc.buildSharedObjects(comp, prog_node) catch |err| switch (err) {
4678 error.SubCompilationFailed => return, // error reported already
4679 else => comp.lockAndSetMiscFailure(.glibc_shared_objects, "unable to build glibc shared objects: {s}", .{
4680 @errorName(err),
4681 }),
4682 };
4683}
4684
4685fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std.Progress.Node) void {
4686 mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) {
4687 error.SubCompilationFailed => return, // error reported already
4688 else => comp.lockAndSetMiscFailure(.mingw_crt_file, "unable to build mingw-w64 {s}: {s}", .{
4689 @tagName(crt_file), @errorName(err),
4690 }),
4691 };
4692}
4693
4694fn buildWasiLibcCrtFile(comp: *Compilation, crt_file: wasi_libc.CrtFile, prog_node: std.Progress.Node) void {
4695 wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) {
4696 error.SubCompilationFailed => return, // error reported already
4697 else => comp.lockAndSetMiscFailure(.wasi_libc_crt_file, "unable to build WASI libc {s}: {s}", .{
4698 @tagName(crt_file), @errorName(err),
4699 }),
4700 };
4701}
4702
4703fn buildLibUnwind(comp: *Compilation, prog_node: std.Progress.Node) void {
4704 libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) {
4705 error.SubCompilationFailed => return, // error reported already
4706 else => comp.lockAndSetMiscFailure(.libunwind, "unable to build libunwind: {s}", .{@errorName(err)}),
4707 };
4708}
4709
4710fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) void {
4711 libcxx.buildLibCxx(comp, prog_node) catch |err| switch (err) {
4712 error.SubCompilationFailed => return, // error reported already
4713 else => comp.lockAndSetMiscFailure(.libcxx, "unable to build libcxx: {s}", .{@errorName(err)}),
4714 };
4715}
4716
4717fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) void {
4718 libcxx.buildLibCxxAbi(comp, prog_node) catch |err| switch (err) {
4719 error.SubCompilationFailed => return, // error reported already
4720 else => comp.lockAndSetMiscFailure(.libcxxabi, "unable to build libcxxabi: {s}", .{@errorName(err)}),
4721 };
4722}
4723
4724fn buildLibTsan(comp: *Compilation, prog_node: std.Progress.Node) void {
4725 libtsan.buildTsan(comp, prog_node) catch |err| switch (err) {
4726 error.SubCompilationFailed => return, // error reported already
4727 else => comp.lockAndSetMiscFailure(.libtsan, "unable to build TSAN library: {s}", .{@errorName(err)}),
4728 };
4729}
4730
4731fn buildZigLibc(comp: *Compilation, prog_node: std.Progress.Node) void {
4732 comp.buildOutputFromZig(
4733 "c.zig",
4734 .Lib,
4735 &comp.libc_static_lib,
4736 .zig_libc,
4737 prog_node,
4738 ) catch |err| switch (err) {
4739 error.SubCompilationFailed => return, // error reported already
4740 else => comp.lockAndSetMiscFailure(.zig_libc, "unable to build zig's multitarget libc: {s}", .{@errorName(err)}),
4741 };
4742}
4743
4764fn reportRetryableCObjectError(4744fn reportRetryableCObjectError(
4765 comp: *Compilation,4745 comp: *Compilation,
4766 c_object: *CObject,4746 c_object: *CObject,
...@@ -6805,3 +6785,9 @@ pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {...@@ -6805,3 +6785,9 @@ pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
6805pub fn compilerRtStrip(comp: Compilation) bool {6785pub fn compilerRtStrip(comp: Compilation) bool {
6806 return comp.root_mod.strip;6786 return comp.root_mod.strip;
6807}6787}
6788
6789fn testAndClear(b: *bool) bool {
6790 const result = b.*;
6791 b.* = false;
6792 return result;
6793}
src/glibc.zig+11-97
...@@ -156,29 +156,14 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI...@@ -156,29 +156,14 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI
156 return abi;156 return abi;
157}157}
158158
159fn useElfInitFini(target: std.Target) bool {
160 // Legacy architectures use _init/_fini.
161 return switch (target.cpu.arch) {
162 .arm, .armeb => true,
163 .aarch64, .aarch64_be => true,
164 .m68k => true,
165 .mips, .mipsel, .mips64, .mips64el => true,
166 .powerpc, .powerpcle, .powerpc64, .powerpc64le => true,
167 .s390x => true,
168 .sparc, .sparc64 => true,
169 .x86, .x86_64 => true,
170 else => false,
171 };
172}
173
174pub const CrtFile = enum {159pub const CrtFile = enum {
175 crti_o,
176 crtn_o,
177 scrt1_o,160 scrt1_o,
178 libc_nonshared_a,161 libc_nonshared_a,
179};162};
180163
181pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void {164/// TODO replace anyerror with explicit error set, recording user-friendly errors with
165/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
166pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
182 if (!build_options.have_llvm) {167 if (!build_options.have_llvm) {
183 return error.ZigCompilerNotBuiltWithLLVMExtensions;168 return error.ZigCompilerNotBuiltWithLLVMExtensions;
184 }169 }
...@@ -199,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -199,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
199 // waste computation and create false negatives.184 // waste computation and create false negatives.
200185
201 switch (crt_file) {186 switch (crt_file) {
202 .crti_o => {
203 var args = std.ArrayList([]const u8).init(arena);
204 try add_include_dirs(comp, arena, &args);
205 try args.appendSlice(&[_][]const u8{
206 "-D_LIBC_REENTRANT",
207 "-include",
208 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
209 "-DMODULE_NAME=libc",
210 "-Wno-nonportable-include-path",
211 "-include",
212 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
213 "-DTOP_NAMESPACE=glibc",
214 "-DASSEMBLER",
215 "-Wa,--noexecstack",
216 });
217 var files = [_]Compilation.CSourceFile{
218 .{
219 .src_path = try start_asm_path(comp, arena, "crti.S"),
220 .cache_exempt_flags = args.items,
221 .owner = comp.root_mod,
222 },
223 };
224 return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files, .{});
225 },
226 .crtn_o => {
227 var args = std.ArrayList([]const u8).init(arena);
228 try add_include_dirs(comp, arena, &args);
229 try args.appendSlice(&[_][]const u8{
230 "-D_LIBC_REENTRANT",
231 "-DMODULE_NAME=libc",
232 "-include",
233 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
234 "-DTOP_NAMESPACE=glibc",
235 "-DASSEMBLER",
236 "-Wa,--noexecstack",
237 });
238 var files = [_]Compilation.CSourceFile{
239 .{
240 .src_path = try start_asm_path(comp, arena, "crtn.S"),
241 .cache_exempt_flags = args.items,
242 .owner = undefined,
243 },
244 };
245 return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files, .{});
246 },
247 .scrt1_o => {187 .scrt1_o => {
248 const start_o: Compilation.CSourceFile = blk: {188 const start_o: Compilation.CSourceFile = blk: {
249 var args = std.ArrayList([]const u8).init(arena);189 var args = std.ArrayList([]const u8).init(arena);
...@@ -381,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -381,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
381 });321 });
382 try add_include_dirs(comp, arena, &args);322 try add_include_dirs(comp, arena, &args);
383323
384 if (!useElfInitFini(target)) {324 try args.append("-DNO_INITFINI");
385 try args.append("-DNO_INITFINI");
386 }
387325
388 if (target.cpu.arch == .x86) {326 if (target.cpu.arch == .x86) {
389 // This prevents i386/sysdep.h from trying to do some327 // This prevents i386/sysdep.h from trying to do some
...@@ -430,32 +368,15 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![...@@ -430,32 +368,15 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
430 try result.appendSlice(comp.zig_lib_directory.path.?);368 try result.appendSlice(comp.zig_lib_directory.path.?);
431 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);369 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
432 if (is_sparc) {370 if (is_sparc) {
433 if (mem.eql(u8, basename, "crti.S") or mem.eql(u8, basename, "crtn.S")) {371 if (is_64) {
434 try result.appendSlice("sparc");372 try result.appendSlice("sparc" ++ s ++ "sparc64");
435 } else {373 } else {
436 if (is_64) {374 try result.appendSlice("sparc" ++ s ++ "sparc32");
437 try result.appendSlice("sparc" ++ s ++ "sparc64");
438 } else {
439 try result.appendSlice("sparc" ++ s ++ "sparc32");
440 }
441 }375 }
442 } else if (arch.isArm()) {376 } else if (arch.isArm()) {
443 try result.appendSlice("arm");377 try result.appendSlice("arm");
444 } else if (arch.isMIPS()) {378 } else if (arch.isMIPS()) {
445 if (!mem.eql(u8, basename, "crti.S") and !mem.eql(u8, basename, "crtn.S")) {379 try result.appendSlice("mips");
446 try result.appendSlice("mips");
447 } else {
448 if (is_64) {
449 const abi_dir = if (comp.getTarget().abi == .gnuabin32)
450 "n32"
451 else
452 "n64";
453 try result.appendSlice("mips" ++ s ++ "mips64" ++ s);
454 try result.appendSlice(abi_dir);
455 } else {
456 try result.appendSlice("mips" ++ s ++ "mips32");
457 }
458 }
459 } else if (arch == .x86_64) {380 } else if (arch == .x86_64) {
460 try result.appendSlice("x86_64");381 try result.appendSlice("x86_64");
461 } else if (arch == .x86) {382 } else if (arch == .x86) {
...@@ -735,7 +656,9 @@ fn wordDirective(target: std.Target) []const u8 {...@@ -735,7 +656,9 @@ fn wordDirective(target: std.Target) []const u8 {
735 return if (target.ptrBitWidth() == 64) ".quad" else ".long";656 return if (target.ptrBitWidth() == 64) ".quad" else ".long";
736}657}
737658
738pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !void {659/// TODO replace anyerror with explicit error set, recording user-friendly errors with
660/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
661pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void {
739 const tracy = trace(@src());662 const tracy = trace(@src());
740 defer tracy.end();663 defer tracy.end();
741664
...@@ -1362,15 +1285,6 @@ fn buildSharedLib(...@@ -1362,15 +1285,6 @@ fn buildSharedLib(
1362 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);1285 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
1363}1286}
13641287
1365// Return true if glibc has crti/crtn sources for that architecture.
1366pub fn needsCrtiCrtn(target: std.Target) bool {
1367 return switch (target.cpu.arch) {
1368 .riscv32, .riscv64 => false,
1369 .loongarch64 => false,
1370 else => true,
1371 };
1372}
1373
1374pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {1288pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
1375 return switch (output_mode) {1289 return switch (output_mode) {
1376 .Obj, .Lib => null,1290 .Obj, .Lib => null,
src/libcxx.zig+2-2
...@@ -114,7 +114,7 @@ pub const BuildError = error{...@@ -114,7 +114,7 @@ pub const BuildError = error{
114 ZigCompilerNotBuiltWithLLVMExtensions,114 ZigCompilerNotBuiltWithLLVMExtensions,
115};115};
116116
117pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {117pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
118 if (!build_options.have_llvm) {118 if (!build_options.have_llvm) {
119 return error.ZigCompilerNotBuiltWithLLVMExtensions;119 return error.ZigCompilerNotBuiltWithLLVMExtensions;
120 }120 }
...@@ -357,7 +357,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -357,7 +357,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
357 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);357 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
358}358}
359359
360pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {360pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
361 if (!build_options.have_llvm) {361 if (!build_options.have_llvm) {
362 return error.ZigCompilerNotBuiltWithLLVMExtensions;362 return error.ZigCompilerNotBuiltWithLLVMExtensions;
363 }363 }
src/mingw.zig+3-1
...@@ -17,7 +17,9 @@ pub const CrtFile = enum {...@@ -17,7 +17,9 @@ pub const CrtFile = enum {
17 mingw32_lib,17 mingw32_lib,
18};18};
1919
20pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void {20/// TODO replace anyerror with explicit error set, recording user-friendly errors with
21/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
22pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
21 if (!build_options.have_llvm) {23 if (!build_options.have_llvm) {
22 return error.ZigCompilerNotBuiltWithLLVMExtensions;24 return error.ZigCompilerNotBuiltWithLLVMExtensions;
23 }25 }
src/musl.zig+3-52
...@@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig");...@@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig");
9const build_options = @import("build_options");9const build_options = @import("build_options");
1010
11pub const CrtFile = enum {11pub const CrtFile = enum {
12 crti_o,
13 crtn_o,
14 crt1_o,12 crt1_o,
15 rcrt1_o,13 rcrt1_o,
16 scrt1_o,14 scrt1_o,
...@@ -18,7 +16,9 @@ pub const CrtFile = enum {...@@ -18,7 +16,9 @@ pub const CrtFile = enum {
18 libc_so,16 libc_so,
19};17};
2018
21pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) !void {19/// TODO replace anyerror with explicit error set, recording user-friendly errors with
20/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
21pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
22 if (!build_options.have_llvm) {22 if (!build_options.have_llvm) {
23 return error.ZigCompilerNotBuiltWithLLVMExtensions;23 return error.ZigCompilerNotBuiltWithLLVMExtensions;
24 }24 }
...@@ -28,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -28,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
28 const arena = arena_allocator.allocator();28 const arena = arena_allocator.allocator();
2929
30 switch (in_crt_file) {30 switch (in_crt_file) {
31 .crti_o => {
32 var args = std.ArrayList([]const u8).init(arena);
33 try addCcArgs(comp, arena, &args, false);
34 var files = [_]Compilation.CSourceFile{
35 .{
36 .src_path = try start_asm_path(comp, arena, "crti.s"),
37 .extra_flags = args.items,
38 .owner = undefined,
39 },
40 };
41 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{
42 .function_sections = true,
43 .data_sections = true,
44 .omit_frame_pointer = true,
45 .no_builtin = true,
46 });
47 },
48 .crtn_o => {
49 var args = std.ArrayList([]const u8).init(arena);
50 try addCcArgs(comp, arena, &args, false);
51 var files = [_]Compilation.CSourceFile{
52 .{
53 .src_path = try start_asm_path(comp, arena, "crtn.s"),
54 .extra_flags = args.items,
55 .owner = undefined,
56 },
57 };
58 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{
59 .function_sections = true,
60 .data_sections = true,
61 .omit_frame_pointer = true,
62 .no_builtin = true,
63 });
64 },
65 .crt1_o => {31 .crt1_o => {
66 var args = std.ArrayList([]const u8).init(arena);32 var args = std.ArrayList([]const u8).init(arena);
67 try addCcArgs(comp, arena, &args, false);33 try addCcArgs(comp, arena, &args, false);
...@@ -327,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -327,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
327 }293 }
328}294}
329295
330/// Return true if musl has arch-specific crti/crtn sources.
331/// See lib/libc/musl/crt/ARCH/crt?.s .
332pub fn needsCrtiCrtn(target: std.Target) bool {
333 return switch (target.cpu.arch) {
334 .loongarch64,
335 .m68k,
336 .riscv32,
337 .riscv64,
338 .wasm32,
339 .wasm64,
340 => false,
341 else => true,
342 };
343}
344
345pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {296pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
346 return switch (output_mode) {297 return switch (output_mode) {
347 .Obj, .Lib => null,298 .Obj, .Lib => null,
src/wasi_libc.zig+3-1
...@@ -57,7 +57,9 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co...@@ -57,7 +57,9 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co
57 };57 };
58}58}
5959
60pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void {60/// TODO replace anyerror with explicit error set, recording user-friendly errors with
61/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
62pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
61 if (!build_options.have_llvm) {63 if (!build_options.have_llvm) {
62 return error.ZigCompilerNotBuiltWithLLVMExtensions;64 return error.ZigCompilerNotBuiltWithLLVMExtensions;
63 }65 }
test/link/elf.zig-4
...@@ -1,7 +1,3 @@...@@ -1,7 +1,3 @@
1//! Here we test our ELF linker for correctness and functionality.
2//! Currently, we support linking x86_64 Linux, but in the future we
3//! will progressively relax those to exercise more combinations.
4
5pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {1pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
6 _ = build_opts;2 _ = build_opts;
7 const elf_step = b.step("test-elf", "Run ELF tests");3 const elf_step = b.step("test-elf", "Run ELF tests");