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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
# Make-lang.in -- Top level -*- makefile -*- fragment for GCC Rust frontend.
# Copyright (C) 2009-2024 Free Software Foundation, Inc.
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This file provides the language dependent support in the main Makefile.
#RUST_EXES = rust
# Use strict warnings for this front end.
rust-warn = $(STRICT_WARN)
# ..., with the exception of '-Wunused-parameter'; waiting for
# <https://github.com/Rust-GCC/gccrs/issues/1626> "bootstrap build failure".
rust-warn += -Wno-unused-parameter
# Installation name. Useful for cross compilers and used during install.
GCCRS_INSTALL_NAME := $(shell echo gccrs|sed '$(program_transform_name)')
GCCRS_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccrs|sed '$(program_transform_name)')
# Define the names for selecting rust in LANGUAGES.
rust: crab1$(exeext)
rust.serial = crab1$(exeext)
# Tell GNU make to ignore files by these names if they exist.
.PHONY: rust
# removed GRS_CFLAGS from here
CFLAGS-rust/rustspec.o += $(DRIVER_DEFINES)
# Create the compiler driver gccrs.
# A compiler driver is the program that interprets command argument and can be called from the command
# line - e.g. gcc or g++, and not cc1, which is the actual compiler
# Create driver objects
GCCRS_D_OBJS = \
$(GCC_OBJS) \
rust/rustspec.o \
$(END)
gccrs$(exeext): $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
$(EXTRA_GCC_LIBS) $(LIBS)
# List of host object files used by the rust language - files for translation from the parse tree
# to GENERIC
# The compiler proper, not driver
GRS_OBJS = \
rust/rust-lang.o \
rust/rust-attribs.o \
rust/rust-object-export.o \
rust/rust-linemap.o \
rust/rust-diagnostics.o \
rust/rust-gcc.o \
rust/rust-token.o \
rust/rust-lex.o \
rust/rust-cfg-parser.o \
rust/rust-parse.o \
rust/rust-ast.o \
rust/rust-ast-formatting.o \
rust/rust-path.o \
rust/rust-pattern.o \
rust/rust-ast-fragment.o \
rust/rust-ast-dump.o \
rust/rust-ast-collector.o \
rust/rust-ast-visitor.o \
rust/rust-hir-dump.o \
rust/rust-session-manager.o \
rust/rust-compile.o \
rust/rust-mangle.o \
rust/rust-mangle-v0.o \
rust/rust-mangle-legacy.o \
rust/rust-compile-resolve-path.o \
rust/rust-macro-expand.o \
rust/rust-cfg-strip.o \
rust/rust-expand-visitor.o \
rust/rust-ast-builder.o \
rust/rust-derive.o \
rust/rust-derive-clone.o \
rust/rust-derive-copy.o \
rust/rust-proc-macro.o \
rust/rust-macro-invoc-lexer.o \
rust/rust-proc-macro-invoc-lexer.o \
rust/rust-macro-substitute-ctx.o \
rust/rust-macro-builtins.o \
rust/rust-hir.o \
rust/rust-hir-map.o \
rust/rust-attributes.o \
rust/rust-keyword-values.o \
rust/rust-abi.o \
rust/rust-token-converter.o \
rust/rust-macro.o \
rust/rust-ast-lower.o \
rust/rust-ast-lower-base.o \
rust/rust-ast-lower-pattern.o \
rust/rust-ast-lower-item.o \
rust/rust-ast-lower-implitem.o \
rust/rust-ast-lower-expr.o \
rust/rust-ast-lower-type.o \
rust/rust-ast-lower-stmt.o \
rust/rust-rib.o \
rust/rust-name-resolution-context.o \
rust/rust-default-resolver.o \
rust/rust-toplevel-name-resolver-2.0.o \
rust/rust-early-name-resolver-2.0.o \
rust/rust-late-name-resolver-2.0.o \
rust/rust-early-name-resolver.o \
rust/rust-name-resolver.o \
rust/rust-ast-resolve.o \
rust/rust-ast-resolve-base.o \
rust/rust-ast-resolve-item.o \
rust/rust-ast-resolve-pattern.o \
rust/rust-ast-resolve-expr.o \
rust/rust-ast-resolve-type.o \
rust/rust-ast-resolve-path.o \
rust/rust-ast-resolve-stmt.o \
rust/rust-ast-resolve-struct-expr-field.o \
rust/rust-hir-type-check.o \
rust/rust-privacy-check.o \
rust/rust-privacy-ctx.o \
rust/rust-reachability.o \
rust/rust-visibility-resolver.o \
rust/rust-pub-restricted-visitor.o \
rust/rust-privacy-reporter.o \
rust/rust-tyty.o \
rust/rust-tyty-util.o \
rust/rust-tyty-call.o \
rust/rust-tyty-subst.o \
rust/rust-typecheck-context.o \
rust/rust-tyty-bounds.o \
rust/rust-hir-trait-resolve.o \
rust/rust-hir-trait-reference.o \
rust/rust-hir-type-check-item.o \
rust/rust-hir-type-check-type.o \
rust/rust-hir-type-check-struct.o \
rust/rust-hir-type-check-pattern.o \
rust/rust-hir-type-check-expr.o \
rust/rust-hir-type-check-stmt.o \
rust/rust-hir-type-check-enumitem.o \
rust/rust-hir-type-check-implitem.o \
rust/rust-borrow-checker.o \
rust/rust-bir-builder-expr-stmt.o \
rust/rust-bir-dump.o \
rust/rust-hir-dot-operator.o \
rust/rust-hir-path-probe.o \
rust/rust-type-util.o \
rust/rust-coercion.o \
rust/rust-casts.o \
rust/rust-unify.o \
rust/rust-hir-type-check-base.o \
rust/rust-autoderef.o \
rust/rust-substitution-mapper.o \
rust/rust-const-checker.o \
rust/rust-lint-marklive.o \
rust/rust-lint-unused-var.o \
rust/rust-readonly-check.o \
rust/rust-hir-type-check-path.o \
rust/rust-unsafe-checker.o \
rust/rust-compile-intrinsic.o \
rust/rust-compile-pattern.o \
rust/rust-compile-fnparam.o \
rust/rust-compile-proc-macro.o \
rust/rust-base62.o \
rust/rust-compile-item.o \
rust/rust-compile-implitem.o \
rust/rust-compile-stmt.o \
rust/rust-compile-expr.o \
rust/rust-compile-type.o \
rust/rust-compile-block.o \
rust/rust-compile-struct-field-expr.o \
rust/rust-constexpr.o \
rust/rust-compile-base.o \
rust/rust-tree.o \
rust/rust-compile-context.o \
rust/rust-export-metadata.o \
rust/rust-imports.o \
rust/rust-import-archive.o \
rust/rust-extern-crate.o \
rust/rust-builtins.o \
rust/rust-feature.o \
rust/rust-feature-gate.o \
rust/rust-ast-validation.o \
rust/rust-dir-owner.o \
rust/rust-unicode.o \
rust/rust-punycode.o \
$(END)
# removed object files from here
# All language-specific object files for Rust.
RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
LIBPROC_MACRO_INTERNAL = ../libgrust/libproc_macro_internal/libproc_macro_internal.a
RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL)
# The compiler itself is called crab1
crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) $(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(LIBPROC_MACRO_INTERNAL) $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)
# Build hooks.
lang_checks += check-rust
lang_checks_parallelized += check-rust
check_rust_parallelize = 10
# Copies its dependencies into the source directory. This generally should be used for generated files
# such as Bison output files which are not version-controlled, but should be included in any release
# tarballs. This target will be executed during a bootstrap if ‘--enable-generated-files-in-srcdir’
# was specified as a configure option.
rust.srcextra:
rust.all.cross: gccrs$(exeext)
# idk what this does but someone used it
rust.start.encap: gccrs$(exeext)
rust.rest.encap:
# Build generated man pages for the front end from Texinfo manuals (see Man Page Generation), in the
# build directory. This target is only called if the necessary tools are available, but should ignore
# errors so as not to stop the build if errors occur; man pages are optional and the tools involved
# may be installed in a broken way.
rust.man:
# Copies its dependencies into the source directory. These targets will be executed during a bootstrap
# if ‘--enable-generated-files-in-srcdir’ was specified as a configure option.
rust.srcman:
# Clean hooks.
rust.mostlyclean:
# cd $(srcdir)/rust; rm -f *.o y.tab.h y.tab.c lex.yy.c
rust.clean: rust.mostlyclean
# Builds an etags TAGS file in the language subdirectory in the source tree.
# TODO: add more directories if I add more
rust.tags: force
cd $(srcdir)/rust; \
etags -o TAGS.sub *.y *.l *.cc *.h ast/*.h ast/*.cc lex/*.h lex/*.cc parse/*.h parse/*.cc; \
etags --include TAGS.sub --include ../TAGS.sub
# Build documentation hooks.
# Build info documentation for the front end, in the build directory. This target is only called by
# ‘make bootstrap’ if a suitable version of makeinfo is available, so does not need to check for this,
# and should fail if an error occurs.
rust.info:
rust.srcinfo:
# Build DVI documentation for the front end, in the build directory. This should be done using
# $(TEXI2DVI), with appropriate -I arguments pointing to directories of included files.
rust.dvi:
# Build PDF documentation for the front end, in the build directory. This should be done using
# $(TEXI2PDF), with appropriate -I arguments pointing to directories of included files.
rust.pdf:
doc/rust.info:
doc/rust.dvi:
doc/rust.pdf:
# Build HTML documentation for the front end, in the build directory.
rust.html:
# Install hooks.
# Install everything that is part of the front end, apart from the compiler executables listed in
# compilers in config-lang.in.
rust.install-common: installdirs
# -rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
# -rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext)
# $(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
# if test -f $(DESTDIR)$(bindir)$(GCCRS_TARGET_INSTALL_NAME)$(exeext); then \
# :; \
# else \
# cd $(DESTDIR)$(bindir) && \
# $(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
# fi
-rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
$(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
( cd $(DESTDIR)$(bindir) && \
$(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext) ); \
# Install headers needed for plugins.
rust.install-plugin:
# Uninstall files installed by installing the compiler. This is currently documented not to be
# supported, so the hook need not do anything.
rust.uninstall:
# -rm -rf $(DESTDIR)/$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
-rm -f gccrs$(exeext) grs1$(exeext)
-rm -f $(RUST_ALL_OBJS)
# ^those two are a maybe
# Enable selftests for the rust frontend
selftest-rust: s-selftest-rust
RUST_SELFTEST_FLAGS = -xrust -frust-incomplete-and-experimental-compiler-do-not-use $(SELFTEST_FLAGS)
RUST_SELFTEST_DEPS = crab1$(exeext) $(SELFTEST_DEPS)
# Run the rust selftests
s-selftest-rust: $(RUST_SELFTEST_DEPS)
$(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS)
$(STAMP) $@
# Convenience methods for running rust selftests under gdb:
.PHONY: selftest-rust-gdb
selftest-rust-gdb: $(RUST_SELFTEST_DEPS)
$(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
-wrapper gdb,--args
# Convenience methods for running rust selftests under valgrind:
.PHONY: selftest-rust-valgrind
selftest-rust-valgrind: $(RUST_SELFTEST_DEPS)
$(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
-wrapper valgrind,--leak-check=full
# Install info documentation for the front end, if it is present in the source directory. This target
# should have dependencies on info files that should be installed.
rust.install-info:
rust.install-dvi:
rust.install-html:
rust.install-pdf:
# Install man pages for the front end. This target should ignore errors.
rust.install-man:
# Stage hooks:
# The toplevel makefile has already created stage?/rust at this point.
# Used for handling bootstrap
rust.stage1: stage1-start
-mv rust/*$(objext) stage1/rust
rust.stage2: stage2-start
-mv rust/*$(objext) stage2/rust
rust.stage3: stage3-start
-mv rust/*$(objext) stage3/rust
rust.stage4: stage4-start
-mv rust/*$(objext) stage4/rust
rust.stageprofile: stageprofile-start
-mv rust/*$(objext) stageprofile/rust
rust.stagefeedback: stagefeedback-start
-mv rust/*$(objext) stagefeedback/rust
CFLAGS-rust/rust-lang.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
-DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\"
# cross-folder includes - add new folders later
RUST_INCLUDES = -I $(srcdir)/rust \
-I $(srcdir)/rust/lex \
-I $(srcdir)/rust/parse \
-I $(srcdir)/rust/ast \
-I $(srcdir)/rust/analysis \
-I $(srcdir)/rust/backend \
-I $(srcdir)/rust/expand \
-I $(srcdir)/rust/hir/tree \
-I $(srcdir)/rust/hir \
-I $(srcdir)/rust/resolve \
-I $(srcdir)/rust/util \
-I $(srcdir)/rust/typecheck \
-I $(srcdir)/rust/checks/lints \
-I $(srcdir)/rust/checks/errors \
-I $(srcdir)/rust/checks/errors/privacy \
-I $(srcdir)/rust/checks/errors/borrowck \
-I $(srcdir)/rust/util \
-I $(srcdir)/rust/metadata \
-I $(srcdir)/../libgrust
# add files that require cross-folder includes - currently rust-lang.o, rust-lex.o
CFLAGS-rust/rust-lang.o += $(RUST_INCLUDES)
CFLAGS-rust/rust-lex.o += $(RUST_INCLUDES)
CFLAGS-rust/rust-parse.o += $(RUST_INCLUDES)
CFLAGS-rust/rust-session-manager.o += $(RUST_INCLUDES)
RUST_CXXFLAGS = $(CXXFLAGS)
# build all rust/lex files in rust folder, add cross-folder includes
rust/%.o: rust/lex/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build all rust/parse files in rust folder, add cross-folder includes
rust/%.o: rust/parse/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/ast files in rust folder
rust/%.o: rust/ast/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/backend files in rust folder
rust/%.o: rust/backend/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/expand files in rust folder
rust/%.o: rust/expand/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/util files in rust folder
rust/%.o: rust/util/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/hir files in rust folder
rust/%.o: rust/hir/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/hir/tree files in rust folder
rust/%.o: rust/hir/tree/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/resolve files in rust folder
rust/%.o: rust/resolve/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/typecheck files in rust folder
rust/%.o: rust/typecheck/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/checks/lints files in rust folder
rust/%.o: rust/checks/lints/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/checks/errors files in rust folder
rust/%.o: rust/checks/errors/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build privacy pass files in rust folder
rust/%.o: rust/checks/errors/privacy/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build borrow checking pass files in rust folder
rust/%.o: rust/checks/errors/borrowck/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
# build rust/metadata files in rust folder
rust/%.o: rust/metadata/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
|