summaryrefslogtreecommitdiff
path: root/patches/mrustc-maple.patch
blob: 97d60189196cc150bcde5fb27a5a647d5ee1c7df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
diff -ruN mrustc-0.11.2.orig/src/ast/ast.cpp mrustc-0.11.2/src/ast/ast.cpp
--- mrustc-0.11.2.orig/src/ast/ast.cpp	2025-05-05 19:48:49.015447489 -0400
+++ mrustc-0.11.2/src/ast/ast.cpp	2025-05-06 21:59:55.063318921 -0400
@@ -243,9 +243,9 @@
 
 Function::Function(Span sp, ::std::string abi, Flags flags, GenericParams params, TypeRef ret_type, Arglist args, bool is_variadic):
     m_span(sp),
-    m_params( move(params) ),
-    m_rettype( move(ret_type) ),
-    m_args( move(args) ),
+    m_params( std::move(params) ),
+    m_rettype( std::move(ret_type) ),
+    m_args( std::move(args) ),
     m_is_variadic(is_variadic),
     m_abi( mv$(abi) ),
     m_flags(flags)
diff -ruN mrustc-0.11.2.orig/src/ast/ast.hpp mrustc-0.11.2/src/ast/ast.hpp
--- mrustc-0.11.2.orig/src/ast/ast.hpp	2025-05-05 19:48:49.015447489 -0400
+++ mrustc-0.11.2/src/ast/ast.hpp	2025-05-06 22:00:48.786212819 -0400
@@ -101,8 +101,8 @@
 
     //TypeAlias() {}
     TypeAlias(GenericParams params, TypeRef type):
-        m_params( move(params) ),
-        m_type( move(type) )
+        m_params( std::move(params) ),
+        m_type( std::move(type) )
     {}
     static TypeAlias new_associated_type(GenericParams params, GenericParams type_bounds, TypeRef default_type) {
         TypeAlias rv { std::move(params), std::move(default_type) };
@@ -164,8 +164,8 @@
 
     Static(Class s_class, TypeRef type, Expr value):
         m_class(s_class),
-        m_type( move(type) ),
-        m_value( move(value) )
+        m_type( std::move(type) ),
+        m_value( std::move(value) )
     {}
 
     const Class& s_class() const { return m_class; }
@@ -421,8 +421,8 @@
     
     Enum() {}
     Enum( GenericParams params, ::std::vector<EnumVariant> variants ):
-        m_params( move(params) ),
-        m_variants( move(variants) )
+        m_params( std::move(params) ),
+        m_variants( std::move(variants) )
     {}
 
     const GenericParams& params() const { return m_params; }
@@ -483,11 +483,11 @@
     {
     }
     Struct( GenericParams params, ::std::vector<StructItem> fields ):
-        m_params( move(params) ),
+        m_params( std::move(params) ),
         m_data( StructData::make_Struct({mv$(fields)}) )
     {}
     Struct( GenericParams params, ::std::vector<TupleItem> fields ):
-        m_params( move(params) ),
+        m_params( std::move(params) ),
         m_data( StructData::make_Tuple({mv$(fields)}) )
     {}
 
@@ -511,7 +511,7 @@
     } m_markings;
 
     Union( GenericParams params, ::std::vector<StructItem> fields ):
-        m_params( move(params) ),
+        m_params( std::move(params) ),
         m_variants( mv$(fields) )
     {}
 
diff -ruN mrustc-0.11.2.orig/src/ast/expr.hpp mrustc-0.11.2/src/ast/expr.hpp
--- mrustc-0.11.2.orig/src/ast/expr.hpp	2025-05-05 19:48:49.015447489 -0400
+++ mrustc-0.11.2/src/ast/expr.hpp	2025-05-06 22:01:28.556431607 -0400
@@ -76,8 +76,8 @@
         m_block_type(type),
         m_yields_final_value(yields_final_value),
         m_label(""),
-        m_local_mod( move(local_mod) ),
-        m_nodes( move(nodes) )
+        m_local_mod( std::move(local_mod) ),
+        m_nodes( std::move(nodes) )
     {
     }
 
@@ -106,9 +106,9 @@
     bool    m_is_braced;
 
     ExprNode_Macro(AST::Path name, RcString ident, ::TokenTree&& tokens, bool is_braced=false):
-        m_path( move(name) ),
+        m_path( std::move(name) ),
         m_ident(ident),
-        m_tokens( move(tokens) )
+        m_tokens( std::move(tokens) )
         , m_is_braced(is_braced)
     {}
 
@@ -132,11 +132,11 @@
     ::std::vector<::std::string>    m_flags;
 
     ExprNode_Asm(::std::string text, ::std::vector<ValRef> output, ::std::vector<ValRef> input, ::std::vector<::std::string> clobbers, ::std::vector<::std::string> flags):
-        m_text( move(text) ),
-        m_output( move(output) ),
-        m_input( move(input) ),
-        m_clobbers( move(clobbers) ),
-        m_flags( move(flags) )
+        m_text( std::move(text) ),
+        m_output( std::move(output) ),
+        m_input( std::move(input) ),
+        m_clobbers( std::move(clobbers) ),
+        m_flags( std::move(flags) )
     {
     }
 
@@ -169,8 +169,8 @@
 
     ExprNode_Asm2(AsmCommon::Options options, std::vector<AsmCommon::Line> lines, std::vector<Param> params)
         : m_options(options)
-        , m_lines( move(lines) )
-        , m_params( move(params) )
+        , m_lines( std::move(lines) )
+        , m_params( std::move(params) )
     {
     }
 
@@ -194,8 +194,8 @@
 
     ExprNode_Flow(Type type, Ident target, ExprNodeP value):
         m_type(type),
-        m_target( move(target) ),
-        m_value( move(value) )
+        m_target( std::move(target) ),
+        m_value( std::move(value) )
     {
     }
 
@@ -212,10 +212,10 @@
     ::std::pair<unsigned,unsigned>  m_letelse_slots;
 
     ExprNode_LetBinding(Pattern pat, TypeRef type, ExprNodeP value, ExprNodeP else_arm={})
-        : m_pat( move(pat) )
-        , m_type( move(type) )
-        , m_value( move(value) )
-        , m_else( move(else_arm) )
+        : m_pat( std::move(pat) )
+        , m_type( std::move(type) )
+        , m_value( std::move(value) )
+        , m_else( std::move(else_arm) )
     {
     }
 
@@ -237,8 +237,8 @@
     ExprNode_Assign(): m_op(NONE) {}
     ExprNode_Assign(Operation op, ExprNodeP slot, ExprNodeP value):
         m_op(op),
-        m_slot( move(slot) ),
-        m_value( move(value) )
+        m_slot( std::move(slot) ),
+        m_value( std::move(value) )
     {
     }
 
@@ -251,8 +251,8 @@
     ::std::vector<ExprNodeP> m_args;
 
     ExprNode_CallPath(Path&& path, ::std::vector<ExprNodeP>&& args):
-        m_path( move(path) ),
-        m_args( move(args) )
+        m_path( std::move(path) ),
+        m_args( std::move(args) )
     {
     }
 
@@ -266,9 +266,9 @@
     ::std::vector<ExprNodeP> m_args;
 
     ExprNode_CallMethod(ExprNodeP obj, PathNode method, ::std::vector<ExprNodeP> args):
-        m_val( move(obj) ),
-        m_method( move(method) ),
-        m_args( move(args) )
+        m_val( std::move(obj) ),
+        m_method( std::move(method) ),
+        m_args( std::move(args) )
     {
     }
 
@@ -282,8 +282,8 @@
     ::std::vector<ExprNodeP> m_args;
 
     ExprNode_CallObject(ExprNodeP val, ::std::vector< ExprNodeP >&& args):
-        m_val( move(val) ),
-        m_args( move(args) )
+        m_val( std::move(val) ),
+        m_args( std::move(args) )
     {
     }
     NODE_METHODS();
@@ -531,9 +531,9 @@
     t_values    m_values;
 
     ExprNode_StructLiteral(Path path, ExprNodeP base_value, t_values&& values ):
-        m_path( move(path) ),
-        m_base_value( move(base_value) ),
-        m_values( move(values) )
+        m_path( std::move(path) ),
+        m_base_value( std::move(base_value) ),
+        m_values( std::move(values) )
     {}
 
     NODE_METHODS();
@@ -548,8 +548,8 @@
     t_values    m_values;
 
     ExprNode_StructLiteralPattern(Path path, t_values&& values)
-        : m_path( move(path) )
-        , m_values( move(values) )
+        : m_path( std::move(path) )
+        , m_values( std::move(values) )
     {}
 
     NODE_METHODS();
@@ -646,8 +646,8 @@
     TypeRef m_type;
 
     ExprNode_Cast(ExprNodeP value, TypeRef&& dst_type):
-        m_value( move(value) ),
-        m_type( move(dst_type) )
+        m_value( std::move(value) ),
+        m_type( std::move(dst_type) )
     {
     }
     NODE_METHODS();
@@ -661,8 +661,8 @@
     TypeRef m_type;
 
     ExprNode_TypeAnnotation(ExprNodeP value, TypeRef&& dst_type):
-        m_value( move(value) ),
-        m_type( move(dst_type) )
+        m_value( std::move(value) ),
+        m_type( std::move(dst_type) )
     {
     }
     NODE_METHODS();
diff -ruN mrustc-0.11.2.orig/src/ast/lifetime_ref.hpp mrustc-0.11.2/src/ast/lifetime_ref.hpp
--- mrustc-0.11.2.orig/src/ast/lifetime_ref.hpp	2025-05-05 20:46:46.568398964 -0400
+++ mrustc-0.11.2/src/ast/lifetime_ref.hpp	2025-05-05 19:59:44.934652489 -0400
@@ -6,6 +6,7 @@
  * - AST Lifetime reference
  */
 #pragma once
+#include <cstdint>
 #include "../common.hpp"
 #include "ident.hpp"
 
diff -ruN mrustc-0.11.2.orig/src/debug.cpp mrustc-0.11.2/src/debug.cpp
--- mrustc-0.11.2.orig/src/debug.cpp	2025-05-05 20:46:46.568562659 -0400
+++ mrustc-0.11.2/src/debug.cpp	2025-05-05 19:57:59.149549205 -0400
@@ -5,6 +5,7 @@
  * debug.cpp
  * - Debug printing (with indenting)
  */
+#include <cstdint>
 #include <debug_inner.hpp>
 #include <debug.hpp>
 #include <set>
diff -ruN mrustc-0.11.2.orig/src/hir/expr.hpp mrustc-0.11.2/src/hir/expr.hpp
--- mrustc-0.11.2.orig/src/hir/expr.hpp	2025-05-05 19:48:49.017523096 -0400
+++ mrustc-0.11.2/src/hir/expr.hpp	2025-05-06 22:02:51.568333466 -0400
@@ -156,8 +156,8 @@
     ExprNode_Asm2(Span sp, AsmCommon::Options options, std::vector<AsmCommon::Line> lines, std::vector<Param> params)
         : ExprNode(mv$(sp))
         , m_options(options)
-        , m_lines( move(lines) )
-        , m_params( move(params) )
+        , m_lines( std::move(lines) )
+        , m_params( std::move(params) )
     {
     }
 
diff -ruN mrustc-0.11.2.orig/src/hir/generic_ref.hpp mrustc-0.11.2/src/hir/generic_ref.hpp
--- mrustc-0.11.2.orig/src/hir/generic_ref.hpp	2025-05-05 20:46:46.568679102 -0400
+++ mrustc-0.11.2/src/hir/generic_ref.hpp	2025-05-05 19:59:36.463727568 -0400
@@ -6,6 +6,7 @@
  * - Reference to a generic
  */
 #pragma once
+#include <cstdint>
 #include <rc_string.hpp>
 
 /// Binding index for a Generic that indicates "Self"
diff -ruN mrustc-0.11.2.orig/src/hir/type_ref.hpp mrustc-0.11.2/src/hir/type_ref.hpp
--- mrustc-0.11.2.orig/src/hir/type_ref.hpp	2025-05-05 20:46:46.568770980 -0400
+++ mrustc-0.11.2/src/hir/type_ref.hpp	2025-05-05 19:59:57.743537961 -0400
@@ -7,6 +7,7 @@
 */
 #pragma once
 
+#include <cstdint>
 #include <rc_string.hpp>
 #include <span.hpp>
 
diff -ruN mrustc-0.11.2.orig/src/macro_rules/macro_rules.hpp mrustc-0.11.2/src/macro_rules/macro_rules.hpp
--- mrustc-0.11.2.orig/src/macro_rules/macro_rules.hpp	2025-05-05 19:48:49.012008507 -0400
+++ mrustc-0.11.2/src/macro_rules/macro_rules.hpp	2025-05-06 22:02:05.491732403 -0400
@@ -102,7 +102,7 @@
         name( op ),
         name_index(index),
         tok( mv$(sep) ),
-        subpats( move(ents) ),
+        subpats( std::move(ents) ),
         type(PAT_LOOP)
     {
     }
diff -ruN mrustc-0.11.2.orig/src/trans/codegen_c.cpp mrustc-0.11.2/src/trans/codegen_c.cpp
--- mrustc-0.11.2.orig/src/trans/codegen_c.cpp	2025-05-05 19:48:49.014366958 -0400
+++ mrustc-0.11.2/src/trans/codegen_c.cpp	2025-05-06 22:09:34.173707709 -0400
@@ -1287,10 +1287,11 @@
                     break;
                 }
                 // HACK: Work around [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117423] by disabling an optimisation stage
-                if( opt.opt_level > 0 )
+                // Disabled for Maple Linux. See build-chroot.sh for details. ~ahill
+                /* if( opt.opt_level > 0 )
                 {
                     args.push_back("-fno-tree-sra");
-                }
+                } */
                 if( opt.emit_debug_info )
                 {
                     args.push_back("-g");
@@ -4785,7 +4786,8 @@
                 switch (v.first[0])
                 {
                 case '=':   m_of << "=";    break;
-                case '+':   m_of << "+";    break;
+                // Patched for Maple Linux. See build-chroot.sh for details. ~ahill
+                case '+':   m_of << "=";    break;
                 default:    MIR_TODO(mir_res, "Handle asm! output leader '" << v.first[0] << "'");
                 }
                 m_of << H::convert_reg(v.first.c_str() + 1);
@@ -5428,12 +5430,14 @@
                     if(i != 0)  m_of << ",";
                     m_of << " ";
                     m_of << "\"";
-                    if( !p.output && !p.input ) {
+                    // Patched for Maple Linux. See build-chroot.sh for details. ~ahill
+                    m_of << "=";
+                    /*if( !p.output && !p.input ) {
                         m_of << "+";
                     }
                     else {
                         m_of << (p.input ? "+" : "=");
-                    }
+                    }*/
                     TU_MATCH_HDRA((p.spec), {)
                     TU_ARMA(Class, c)
                         // https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
diff -ruN mrustc-0.11.2.orig/src/trans/target.cpp mrustc-0.11.2/src/trans/target.cpp
--- mrustc-0.11.2.orig/src/trans/target.cpp	2025-05-05 19:48:49.014366958 -0400
+++ mrustc-0.11.2/src/trans/target.cpp	2025-05-06 22:07:39.775297252 -0400
@@ -405,7 +405,8 @@
     TargetSpec init_from_spec_name(const ::std::string& target_name)
     {
         // Options for all the fully-GNU environments
-        #define BACKEND_C_OPTS_GNU  {"-ffunction-sections", "-pthread"}, {"-Wl,--start-group"}, {"-Wl,--end-group", "-Wl,--gc-sections", "-l", "atomic"}
+        // Patched for Maple Linux. See build-chroot.sh for details. ~ahill
+        #define BACKEND_C_OPTS_GNU  {"-ffunction-sections", "-pthread"}, {"-Wl,--start-group"}, {"-Wl,--end-group", "-Wl,--gc-sections"}
         // If there's a '/' or a '\' in the filename, open it as a path, otherwise assume it's a triple.
         if( target_name.find('/') != ::std::string::npos || target_name.find('\\') != ::std::string::npos )
         {
diff -ruN mrustc-0.11.2.orig/src/trans/codegen_c.cpp mrustc-0.11.2/src/trans/codegen_c.cpp
--- mrustc-0.11.2.orig/src/trans/codegen_c.cpp	2024-12-29 22:28:18.000000000 -0500
+++ mrustc-0.11.2/src/trans/codegen_c.cpp	2025-05-07 12:57:51.573401275 -0400
@@ -1295,6 +1295,7 @@
                 {
                     args.push_back("-g");
                 }
+                args.push_back("-fno-delete-null-pointer-checks");
                 // TODO: Why?
                 args.push_back("-fPIC");
                 args.push_back("-o");