gccrs: rename rust-hir-full-tests.cc
[official-gcc.git] / gcc / rust / Make-lang.in
blob3ed0c09e0e7ae4f127694c13b82b1f5fc4151bbb
1 # Make-lang.in -- Top level -*- makefile -*- fragment for GCC Rust frontend.
3 # Copyright (C) 2009-2023 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
12 # GCC is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3.  If not see
19 # <http://www.gnu.org/licenses/>.
21 # This file provides the language dependent support in the main Makefile.
23 #RUST_EXES = rust
25 # Use strict warnings for this front end.
26 rust-warn = $(STRICT_WARN)
27 # ..., with the exception of '-Wunused-parameter'; waiting for
28 # <https://github.com/Rust-GCC/gccrs/issues/1626> "bootstrap build failure".
29 rust-warn += -Wno-unused-parameter
31 # Installation name. Useful for cross compilers and used during install.
32 GCCRS_INSTALL_NAME := $(shell echo gccrs|sed '$(program_transform_name)')
33 GCCRS_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccrs|sed '$(program_transform_name)')
35 # Define the names for selecting rust in LANGUAGES.
36 rust: rust1$(exeext)
38 rust.serial = rust1$(exeext)
40 # Tell GNU make to ignore files by these names if they exist.
41 .PHONY: rust
43 # removed GRS_CFLAGS from here
45 CFLAGS-rust/rustspec.o += $(DRIVER_DEFINES)
47 # Create the compiler driver gccrs.
48 # A compiler driver is the program that interprets command argument and can be called from the command
49 # line - e.g. gcc or g++, and not cc1, which is the actual compiler
51 # Create driver objects
52 GCCRS_D_OBJS = \
53    $(GCC_OBJS) \
54    rust/rustspec.o \
55    $(END)
57 gccrs$(exeext): $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
58         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
59           $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
60           $(EXTRA_GCC_LIBS) $(LIBS)
62 # List of host object files used by the rust language - files for translation from the parse tree
63 # to GENERIC
64 # The compiler proper, not driver
65 GRS_OBJS = \
66     rust/rust-lang.o \
67     rust/rust-object-export.o \
68     rust/rust-linemap.o \
69     rust/rust-gcc-diagnostics.o \
70     rust/rust-diagnostics.o \
71     rust/rust-gcc.o \
72     rust/rust-token.o \
73     rust/rust-lex.o \
74     rust/rust-cfg-parser.o \
75     rust/rust-parse.o \
76     rust/rust-ast.o \
77     rust/rust-ast-fragment.o \
78     rust/rust-ast-dump.o \
79     rust/rust-hir-dump.o \
80     rust/rust-session-manager.o \
81     rust/rust-compile.o \
82     rust/rust-mangle.o \
83     rust/rust-compile-resolve-path.o \
84     rust/rust-macro-expand.o \
85     rust/rust-attribute-visitor.o \
86     rust/rust-macro-invoc-lexer.o \
87     rust/rust-macro-substitute-ctx.o \
88     rust/rust-macro-builtins.o \
89     rust/rust-hir.o \
90     rust/rust-hir-map.o \
91     rust/rust-attributes.o \
92     rust/rust-abi.o \
93         rust/rust-macro.o \
94     rust/rust-ast-lower.o \
95     rust/rust-ast-lower-base.o \
96     rust/rust-ast-lower-pattern.o \
97     rust/rust-ast-lower-item.o \
98     rust/rust-ast-lower-expr.o \
99     rust/rust-ast-lower-type.o \
100     rust/rust-early-name-resolver.o \
101     rust/rust-name-resolver.o \
102     rust/rust-ast-resolve.o \
103     rust/rust-ast-resolve-base.o \
104     rust/rust-ast-resolve-item.o \
105     rust/rust-ast-resolve-pattern.o \
106     rust/rust-ast-resolve-expr.o \
107     rust/rust-ast-resolve-type.o \
108     rust/rust-ast-resolve-path.o \
109     rust/rust-ast-resolve-stmt.o \
110     rust/rust-ast-resolve-struct-expr-field.o \
111     rust/rust-hir-type-check.o \
112     rust/rust-privacy-check.o \
113     rust/rust-privacy-ctx.o \
114     rust/rust-reachability.o \
115     rust/rust-visibility-resolver.o \
116     rust/rust-pub-restricted-visitor.o \
117     rust/rust-privacy-reporter.o \
118     rust/rust-tyty.o \
119     rust/rust-tyty-util.o \
120     rust/rust-tyty-call.o \
121     rust/rust-tyty-subst.o \
122     rust/rust-typecheck-context.o \
123     rust/rust-tyty-bounds.o \
124     rust/rust-hir-type-check-util.o \
125     rust/rust-hir-trait-resolve.o \
126     rust/rust-hir-trait-reference.o \
127     rust/rust-hir-type-check-item.o \
128     rust/rust-hir-type-check-type.o \
129     rust/rust-hir-type-check-struct.o \
130     rust/rust-hir-type-check-pattern.o \
131     rust/rust-hir-type-check-expr.o \
132     rust/rust-hir-type-check-stmt.o \
133     rust/rust-hir-type-check-enumitem.o \
134     rust/rust-hir-type-check-implitem.o \
135     rust/rust-hir-dot-operator.o \
136     rust/rust-hir-path-probe.o \
137     rust/rust-type-util.o \
138     rust/rust-coercion.o \
139     rust/rust-casts.o \
140     rust/rust-unify.o \
141     rust/rust-hir-type-check-base.o \
142     rust/rust-autoderef.o \
143     rust/rust-substitution-mapper.o \
144     rust/rust-const-checker.o \
145     rust/rust-lint-marklive.o \
146     rust/rust-lint-unused-var.o \
147     rust/rust-hir-type-check-path.o \
148     rust/rust-unsafe-checker.o \
149     rust/rust-compile-intrinsic.o \
150     rust/rust-compile-pattern.o \
151     rust/rust-compile-fnparam.o \
152     rust/rust-base62.o \
153     rust/rust-optional-test.o \
154     rust/rust-compile-item.o \
155     rust/rust-compile-implitem.o \
156     rust/rust-compile-stmt.o \
157     rust/rust-compile-expr.o \
158     rust/rust-compile-type.o \
159     rust/rust-compile-block.o \
160     rust/rust-compile-struct-field-expr.o \
161     rust/rust-constexpr.o \
162     rust/rust-compile-base.o \
163     rust/rust-tree.o \
164     rust/rust-compile-context.o \
165     rust/rust-export-metadata.o \
166     rust/rust-imports.o \
167     rust/rust-import-archive.o \
168     rust/rust-extern-crate.o \
169     rust/rust-builtins.o \
170     rust/rust-feature.o \
171     rust/rust-feature-gate.o \
172     $(END)
173 # removed object files from here
175 # All language-specific object files for Rust.
176 RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
178 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
180 # The compiler itself is called rust1 (formerly grs1)
181 rust1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(rust.prev)
182         @$(call LINK_PROGRESS,$(INDEX.rust),start)
183         +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
184               $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
185         @$(call LINK_PROGRESS,$(INDEX.rust),end)
187 # Build hooks.
189 lang_checks += check-rust
190 lang_checks_parallelized += check-rust
191 check_rust_parallelize = 10
193 # Copies its dependencies into the source directory. This generally should be used for generated files
194 # such as Bison output files which are not version-controlled, but should be included in any release
195 # tarballs. This target will be executed during a bootstrap if ‘--enable-generated-files-in-srcdir’
196 # was specified as a configure option.
197 rust.srcextra:
199 rust.all.cross: gccrs$(exeext)
201 # idk what this does but someone used it
202 rust.start.encap: gccrs$(exeext)
203 rust.rest.encap:
205 # Build generated man pages for the front end from Texinfo manuals (see Man Page Generation), in the
206 # build directory. This target is only called if the necessary tools are available, but should ignore
207 # errors so as not to stop the build if errors occur; man pages are optional and the tools involved
208 # may be installed in a broken way.
209 rust.man:
211 # Copies its dependencies into the source directory. These targets will be executed during a bootstrap
212 # if ‘--enable-generated-files-in-srcdir’ was specified as a configure option.
213 rust.srcman:
215 # Clean hooks.
217 rust.mostlyclean:
218 #       cd $(srcdir)/rust; rm -f *.o y.tab.h y.tab.c lex.yy.c
220 rust.clean: rust.mostlyclean
222 # Builds an etags TAGS file in the language subdirectory in the source tree.
223 # TODO: add more directories if I add more
224 rust.tags: force
225         cd $(srcdir)/rust; \
226         etags -o TAGS.sub *.y *.l *.cc *.h ast/*.h ast/*.cc lex/*.h lex/*.cc parse/*.h parse/*.cc; \
227         etags --include TAGS.sub --include ../TAGS.sub
229 # Build documentation hooks.
231 # Build info documentation for the front end, in the build directory. This target is only called by
232 # ‘make bootstrap’ if a suitable version of makeinfo is available, so does not need to check for this,
233 # and should fail if an error occurs.
234 rust.info:
236 rust.srcinfo:
238 # Build DVI documentation for the front end, in the build directory. This should be done using
239 # $(TEXI2DVI), with appropriate -I arguments pointing to directories of included files.
240 rust.dvi:
242 # Build PDF documentation for the front end, in the build directory. This should be done using
243 # $(TEXI2PDF), with appropriate -I arguments pointing to directories of included files.
244 rust.pdf:
246 doc/rust.info:
247 doc/rust.dvi:
248 doc/rust.pdf:
250 # Build HTML documentation for the front end, in the build directory.
251 rust.html:
253 # Install hooks.
255 # Install everything that is part of the front end, apart from the compiler executables listed in
256 # compilers in config-lang.in.
257 rust.install-common: installdirs
258 #       -rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
259 #       -rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext)
260 #       $(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
261 #       if test -f $(DESTDIR)$(bindir)$(GCCRS_TARGET_INSTALL_NAME)$(exeext); then \
262 #         :; \
263 #       else \
264 #         cd $(DESTDIR)$(bindir) && \
265 #          $(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
266 #       fi
267         -rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
268         $(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
269         rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
270         ( cd $(DESTDIR)$(bindir) && \
271       $(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext) ); \
273 # Install headers needed for plugins.
274 rust.install-plugin:
276 # Uninstall files installed by installing the compiler. This is currently documented not to be
277 # supported, so the hook need not do anything.
278 rust.uninstall:
279 #       -rm -rf $(DESTDIR)/$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
280         -rm -f gccrs$(exeext) grs1$(exeext)
281         -rm -f $(RUST_ALL_OBJS)
282 # ^those two are a maybe
284 # Enable selftests for the rust frontend
285 selftest-rust: s-selftest-rust
287 RUST_SELFTEST_FLAGS = -xrust -frust-incomplete-and-experimental-compiler-do-not-use $(SELFTEST_FLAGS)
288 RUST_SELFTEST_DEPS = rust1$(exeext) $(SELFTEST_DEPS)
290 # Run the rust selftests
291 s-selftest-rust: $(RUST_SELFTEST_DEPS)
292         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS)
293         $(STAMP) $@
295 # Convenience methods for running rust selftests under gdb:
296 .PHONY: selftest-rust-gdb
297 selftest-rust-gdb: $(RUST_SELFTEST_DEPS)
298         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
299           -wrapper gdb,--args
301 # Convenience methods for running rust selftests under valgrind:
302 .PHONY: selftest-rust-valgrind
303 selftest-rust-valgrind: $(RUST_SELFTEST_DEPS)
304         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
305           -wrapper valgrind,--leak-check=full
307 # Install info documentation for the front end, if it is present in the source directory. This target
308 # should have dependencies on info files that should be installed.
309 rust.install-info:
311 rust.install-pdf:
313 # Install man pages for the front end. This target should ignore errors.
314 rust.install-man:
316 # Stage hooks:
317 # The toplevel makefile has already created stage?/rust at this point.
318 # Used for handling bootstrap
320 rust.stage1: stage1-start
321         -mv rust/*$(objext) stage1/rust
322 rust.stage2: stage2-start
323         -mv rust/*$(objext) stage2/rust
324 rust.stage3: stage3-start
325         -mv rust/*$(objext) stage3/rust
326 rust.stage4: stage4-start
327         -mv rust/*$(objext) stage4/rust
328 rust.stageprofile: stageprofile-start
329         -mv rust/*$(objext) stageprofile/rust
330 rust.stagefeedback: stagefeedback-start
331         -mv rust/*$(objext) stagefeedback/rust
333 CFLAGS-rust/rust-lang.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
334         -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\"
336 # cross-folder includes - add new folders later
337 RUST_INCLUDES = -I $(srcdir)/rust \
338         -I $(srcdir)/rust/lex \
339         -I $(srcdir)/rust/parse \
340         -I $(srcdir)/rust/ast \
341         -I $(srcdir)/rust/analysis \
342         -I $(srcdir)/rust/backend \
343         -I $(srcdir)/rust/expand \
344         -I $(srcdir)/rust/hir/tree \
345         -I $(srcdir)/rust/hir \
346         -I $(srcdir)/rust/resolve \
347         -I $(srcdir)/rust/util \
348         -I $(srcdir)/rust/typecheck \
349         -I $(srcdir)/rust/checks/lints \
350         -I $(srcdir)/rust/checks/errors \
351         -I $(srcdir)/rust/checks/errors/privacy \
352         -I $(srcdir)/rust/util \
353         -I $(srcdir)/rust/metadata
355 # add files that require cross-folder includes - currently rust-lang.o, rust-lex.o
356 CFLAGS-rust/rust-lang.o += $(RUST_INCLUDES)
357 CFLAGS-rust/rust-lex.o += $(RUST_INCLUDES)
358 CFLAGS-rust/rust-parse.o += $(RUST_INCLUDES)
359 CFLAGS-rust/rust-session-manager.o += $(RUST_INCLUDES)
361 RUST_CXXFLAGS = $(CXXFLAGS)
363 # build all rust/lex files in rust folder, add cross-folder includes
364 rust/%.o: rust/lex/%.cc
365         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
366         $(POSTCOMPILE)
368 # build all rust/parse files in rust folder, add cross-folder includes
369 rust/%.o: rust/parse/%.cc
370         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
371         $(POSTCOMPILE)
373 # build rust/ast files in rust folder
374 rust/%.o: rust/ast/%.cc
375         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
376         $(POSTCOMPILE)
378 # build rust/backend files in rust folder
379 rust/%.o: rust/backend/%.cc
380         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
381         $(POSTCOMPILE)
383 # build rust/expand files in rust folder
384 rust/%.o: rust/expand/%.cc
385         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
386         $(POSTCOMPILE)
388 # build rust/util files in rust folder
389 rust/%.o: rust/util/%.cc
390         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
391         $(POSTCOMPILE)
393 # build rust/hir files in rust folder
394 rust/%.o: rust/hir/%.cc
395         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
396         $(POSTCOMPILE)
398 # build rust/hir/tree files in rust folder
399 rust/%.o: rust/hir/tree/%.cc
400         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
401         $(POSTCOMPILE)
403 # build rust/resolve files in rust folder
404 rust/%.o: rust/resolve/%.cc
405         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
406         $(POSTCOMPILE)
408 # build rust/typecheck files in rust folder
409 rust/%.o: rust/typecheck/%.cc
410         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
411         $(POSTCOMPILE)
413 # build rust/checks/lints files in rust folder
414 rust/%.o: rust/checks/lints/%.cc
415         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
416         $(POSTCOMPILE)
418 # build rust/checks/errors files in rust folder
419 rust/%.o: rust/checks/errors/%.cc
420         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
421         $(POSTCOMPILE)
423 # build privacy pass files in rust folder
424 rust/%.o: rust/checks/errors/privacy/%.cc
425         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
426         $(POSTCOMPILE)
428 # build rust/metadata files in rust folder
429 rust/%.o: rust/metadata/%.cc
430         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
431         $(POSTCOMPILE)