Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / rust / Make-lang.in
blob6449f47564d87f2823cb1fe132ed8df2c3237223
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-diagnostics.o \
70     rust/rust-gcc.o \
71     rust/rust-token.o \
72     rust/rust-lex.o \
73     rust/rust-cfg-parser.o \
74     rust/rust-parse.o \
75     rust/rust-ast.o \
76     rust/rust-ast-fragment.o \
77     rust/rust-ast-dump.o \
78     rust/rust-hir-dump.o \
79     rust/rust-session-manager.o \
80     rust/rust-compile.o \
81     rust/rust-mangle.o \
82     rust/rust-compile-resolve-path.o \
83     rust/rust-macro-expand.o \
84     rust/rust-attribute-visitor.o \
85     rust/rust-macro-invoc-lexer.o \
86     rust/rust-macro-substitute-ctx.o \
87     rust/rust-macro-builtins.o \
88     rust/rust-hir.o \
89     rust/rust-hir-map.o \
90     rust/rust-attributes.o \
91     rust/rust-abi.o \
92         rust/rust-macro.o \
93     rust/rust-ast-lower.o \
94     rust/rust-ast-lower-base.o \
95     rust/rust-ast-lower-pattern.o \
96     rust/rust-ast-lower-item.o \
97     rust/rust-ast-lower-expr.o \
98     rust/rust-ast-lower-type.o \
99     rust/rust-early-name-resolver.o \
100     rust/rust-name-resolver.o \
101     rust/rust-ast-resolve.o \
102     rust/rust-ast-resolve-base.o \
103     rust/rust-ast-resolve-item.o \
104     rust/rust-ast-resolve-pattern.o \
105     rust/rust-ast-resolve-expr.o \
106     rust/rust-ast-resolve-type.o \
107     rust/rust-ast-resolve-path.o \
108     rust/rust-ast-resolve-stmt.o \
109     rust/rust-ast-resolve-struct-expr-field.o \
110     rust/rust-hir-type-check.o \
111     rust/rust-privacy-check.o \
112     rust/rust-privacy-ctx.o \
113     rust/rust-reachability.o \
114     rust/rust-visibility-resolver.o \
115     rust/rust-pub-restricted-visitor.o \
116     rust/rust-privacy-reporter.o \
117     rust/rust-tyty.o \
118     rust/rust-tyty-util.o \
119     rust/rust-tyty-call.o \
120     rust/rust-tyty-subst.o \
121     rust/rust-typecheck-context.o \
122     rust/rust-tyty-bounds.o \
123     rust/rust-hir-type-check-util.o \
124     rust/rust-hir-trait-resolve.o \
125     rust/rust-hir-trait-reference.o \
126     rust/rust-hir-type-check-item.o \
127     rust/rust-hir-type-check-type.o \
128     rust/rust-hir-type-check-struct.o \
129     rust/rust-hir-type-check-pattern.o \
130     rust/rust-hir-type-check-expr.o \
131     rust/rust-hir-type-check-stmt.o \
132     rust/rust-hir-type-check-enumitem.o \
133     rust/rust-hir-type-check-implitem.o \
134     rust/rust-hir-dot-operator.o \
135     rust/rust-hir-path-probe.o \
136     rust/rust-type-util.o \
137     rust/rust-coercion.o \
138     rust/rust-casts.o \
139     rust/rust-unify.o \
140     rust/rust-hir-type-check-base.o \
141     rust/rust-autoderef.o \
142     rust/rust-substitution-mapper.o \
143     rust/rust-const-checker.o \
144     rust/rust-lint-marklive.o \
145     rust/rust-lint-unused-var.o \
146     rust/rust-hir-type-check-path.o \
147     rust/rust-unsafe-checker.o \
148     rust/rust-compile-intrinsic.o \
149     rust/rust-compile-pattern.o \
150     rust/rust-compile-fnparam.o \
151     rust/rust-base62.o \
152     rust/rust-optional-test.o \
153     rust/rust-compile-item.o \
154     rust/rust-compile-implitem.o \
155     rust/rust-compile-stmt.o \
156     rust/rust-compile-expr.o \
157     rust/rust-compile-type.o \
158     rust/rust-compile-block.o \
159     rust/rust-compile-struct-field-expr.o \
160     rust/rust-constexpr.o \
161     rust/rust-compile-base.o \
162     rust/rust-tree.o \
163     rust/rust-compile-context.o \
164     rust/rust-export-metadata.o \
165     rust/rust-imports.o \
166     rust/rust-import-archive.o \
167     rust/rust-extern-crate.o \
168     rust/rust-builtins.o \
169     rust/rust-feature.o \
170     rust/rust-feature-gate.o \
171     $(END)
172 # removed object files from here
174 # All language-specific object files for Rust.
175 RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
177 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
179 # The compiler itself is called rust1 (formerly grs1)
180 rust1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(rust.prev)
181         @$(call LINK_PROGRESS,$(INDEX.rust),start)
182         +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
183               $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
184         @$(call LINK_PROGRESS,$(INDEX.rust),end)
186 # Build hooks.
188 lang_checks += check-rust
189 lang_checks_parallelized += check-rust
190 check_rust_parallelize = 10
192 # Copies its dependencies into the source directory. This generally should be used for generated files
193 # such as Bison output files which are not version-controlled, but should be included in any release
194 # tarballs. This target will be executed during a bootstrap if ‘--enable-generated-files-in-srcdir’
195 # was specified as a configure option.
196 rust.srcextra:
198 rust.all.cross: gccrs$(exeext)
200 # idk what this does but someone used it
201 rust.start.encap: gccrs$(exeext)
202 rust.rest.encap:
204 # Build generated man pages for the front end from Texinfo manuals (see Man Page Generation), in the
205 # build directory. This target is only called if the necessary tools are available, but should ignore
206 # errors so as not to stop the build if errors occur; man pages are optional and the tools involved
207 # may be installed in a broken way.
208 rust.man:
210 # Copies its dependencies into the source directory. These targets will be executed during a bootstrap
211 # if ‘--enable-generated-files-in-srcdir’ was specified as a configure option.
212 rust.srcman:
214 # Clean hooks.
216 rust.mostlyclean:
217 #       cd $(srcdir)/rust; rm -f *.o y.tab.h y.tab.c lex.yy.c
219 rust.clean: rust.mostlyclean
221 # Builds an etags TAGS file in the language subdirectory in the source tree.
222 # TODO: add more directories if I add more
223 rust.tags: force
224         cd $(srcdir)/rust; \
225         etags -o TAGS.sub *.y *.l *.cc *.h ast/*.h ast/*.cc lex/*.h lex/*.cc parse/*.h parse/*.cc; \
226         etags --include TAGS.sub --include ../TAGS.sub
228 # Build documentation hooks.
230 # Build info documentation for the front end, in the build directory. This target is only called by
231 # ‘make bootstrap’ if a suitable version of makeinfo is available, so does not need to check for this,
232 # and should fail if an error occurs.
233 rust.info:
235 rust.srcinfo:
237 # Build DVI documentation for the front end, in the build directory. This should be done using
238 # $(TEXI2DVI), with appropriate -I arguments pointing to directories of included files.
239 rust.dvi:
241 # Build PDF documentation for the front end, in the build directory. This should be done using
242 # $(TEXI2PDF), with appropriate -I arguments pointing to directories of included files.
243 rust.pdf:
245 doc/rust.info:
246 doc/rust.dvi:
247 doc/rust.pdf:
249 # Build HTML documentation for the front end, in the build directory.
250 rust.html:
252 # Install hooks.
254 # Install everything that is part of the front end, apart from the compiler executables listed in
255 # compilers in config-lang.in.
256 rust.install-common: installdirs
257 #       -rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
258 #       -rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext)
259 #       $(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
260 #       if test -f $(DESTDIR)$(bindir)$(GCCRS_TARGET_INSTALL_NAME)$(exeext); then \
261 #         :; \
262 #       else \
263 #         cd $(DESTDIR)$(bindir) && \
264 #          $(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
265 #       fi
266         -rm -f $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
267         $(INSTALL_PROGRAM) gccrs$(exeext) $(DESTDIR)$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
268         rm -f $(DESTDIR)$(bindir)/$(GCCRS_TARGET_INSTALL_NAME)$(exeext); \
269         ( cd $(DESTDIR)$(bindir) && \
270       $(LN) $(GCCRS_INSTALL_NAME)$(exeext) $(GCCRS_TARGET_INSTALL_NAME)$(exeext) ); \
272 # Install headers needed for plugins.
273 rust.install-plugin:
275 # Uninstall files installed by installing the compiler. This is currently documented not to be
276 # supported, so the hook need not do anything.
277 rust.uninstall:
278 #       -rm -rf $(DESTDIR)/$(bindir)/$(GCCRS_INSTALL_NAME)$(exeext)
279         -rm -f gccrs$(exeext) grs1$(exeext)
280         -rm -f $(RUST_ALL_OBJS)
281 # ^those two are a maybe
283 # Enable selftests for the rust frontend
284 selftest-rust: s-selftest-rust
286 RUST_SELFTEST_FLAGS = -xrust -frust-incomplete-and-experimental-compiler-do-not-use $(SELFTEST_FLAGS)
287 RUST_SELFTEST_DEPS = rust1$(exeext) $(SELFTEST_DEPS)
289 # Run the rust selftests
290 s-selftest-rust: $(RUST_SELFTEST_DEPS)
291         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS)
292         $(STAMP) $@
294 # Convenience methods for running rust selftests under gdb:
295 .PHONY: selftest-rust-gdb
296 selftest-rust-gdb: $(RUST_SELFTEST_DEPS)
297         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
298           -wrapper gdb,--args
300 # Convenience methods for running rust selftests under valgrind:
301 .PHONY: selftest-rust-valgrind
302 selftest-rust-valgrind: $(RUST_SELFTEST_DEPS)
303         $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \
304           -wrapper valgrind,--leak-check=full
306 # Install info documentation for the front end, if it is present in the source directory. This target
307 # should have dependencies on info files that should be installed.
308 rust.install-info:
310 rust.install-pdf:
312 # Install man pages for the front end. This target should ignore errors.
313 rust.install-man:
315 # Stage hooks:
316 # The toplevel makefile has already created stage?/rust at this point.
317 # Used for handling bootstrap
319 rust.stage1: stage1-start
320         -mv rust/*$(objext) stage1/rust
321 rust.stage2: stage2-start
322         -mv rust/*$(objext) stage2/rust
323 rust.stage3: stage3-start
324         -mv rust/*$(objext) stage3/rust
325 rust.stage4: stage4-start
326         -mv rust/*$(objext) stage4/rust
327 rust.stageprofile: stageprofile-start
328         -mv rust/*$(objext) stageprofile/rust
329 rust.stagefeedback: stagefeedback-start
330         -mv rust/*$(objext) stagefeedback/rust
332 CFLAGS-rust/rust-lang.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
333         -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\"
335 # cross-folder includes - add new folders later
336 RUST_INCLUDES = -I $(srcdir)/rust \
337         -I $(srcdir)/rust/lex \
338         -I $(srcdir)/rust/parse \
339         -I $(srcdir)/rust/ast \
340         -I $(srcdir)/rust/analysis \
341         -I $(srcdir)/rust/backend \
342         -I $(srcdir)/rust/expand \
343         -I $(srcdir)/rust/hir/tree \
344         -I $(srcdir)/rust/hir \
345         -I $(srcdir)/rust/resolve \
346         -I $(srcdir)/rust/util \
347         -I $(srcdir)/rust/typecheck \
348         -I $(srcdir)/rust/checks/lints \
349         -I $(srcdir)/rust/checks/errors \
350         -I $(srcdir)/rust/checks/errors/privacy \
351         -I $(srcdir)/rust/util \
352         -I $(srcdir)/rust/metadata
354 # add files that require cross-folder includes - currently rust-lang.o, rust-lex.o
355 CFLAGS-rust/rust-lang.o += $(RUST_INCLUDES)
356 CFLAGS-rust/rust-lex.o += $(RUST_INCLUDES)
357 CFLAGS-rust/rust-parse.o += $(RUST_INCLUDES)
358 CFLAGS-rust/rust-session-manager.o += $(RUST_INCLUDES)
360 RUST_CXXFLAGS = $(CXXFLAGS)
362 # build all rust/lex files in rust folder, add cross-folder includes
363 rust/%.o: rust/lex/%.cc
364         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
365         $(POSTCOMPILE)
367 # build all rust/parse files in rust folder, add cross-folder includes
368 rust/%.o: rust/parse/%.cc
369         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
370         $(POSTCOMPILE)
372 # build rust/ast files in rust folder
373 rust/%.o: rust/ast/%.cc
374         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
375         $(POSTCOMPILE)
377 # build rust/backend files in rust folder
378 rust/%.o: rust/backend/%.cc
379         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
380         $(POSTCOMPILE)
382 # build rust/expand files in rust folder
383 rust/%.o: rust/expand/%.cc
384         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
385         $(POSTCOMPILE)
387 # build rust/util files in rust folder
388 rust/%.o: rust/util/%.cc
389         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
390         $(POSTCOMPILE)
392 # build rust/hir files in rust folder
393 rust/%.o: rust/hir/%.cc
394         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
395         $(POSTCOMPILE)
397 # build rust/hir/tree files in rust folder
398 rust/%.o: rust/hir/tree/%.cc
399         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
400         $(POSTCOMPILE)
402 # build rust/resolve files in rust folder
403 rust/%.o: rust/resolve/%.cc
404         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
405         $(POSTCOMPILE)
407 # build rust/typecheck files in rust folder
408 rust/%.o: rust/typecheck/%.cc
409         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
410         $(POSTCOMPILE)
412 # build rust/checks/lints files in rust folder
413 rust/%.o: rust/checks/lints/%.cc
414         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
415         $(POSTCOMPILE)
417 # build rust/checks/errors files in rust folder
418 rust/%.o: rust/checks/errors/%.cc
419         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
420         $(POSTCOMPILE)
422 # build privacy pass files in rust folder
423 rust/%.o: rust/checks/errors/privacy/%.cc
424         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
425         $(POSTCOMPILE)
427 # build rust/metadata files in rust folder
428 rust/%.o: rust/metadata/%.cc
429         $(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
430         $(POSTCOMPILE)