c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]
[official-gcc.git] / gcc / cp / Make-lang.in
blob25143c820b07705a10d2a400d4c9a56581bc701e
1 # Top level -*- makefile -*- fragment for GNU C++.
2 #   Copyright (C) 1994-2025 Free Software Foundation, Inc.
4 #This file is part of GCC.
6 #GCC is free software; you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation; either version 3, or (at your option)
9 #any later version.
11 #GCC is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING3.  If not see
18 # <http://www.gnu.org/licenses/>.
20 # This file provides the language dependent support in the main Makefile.
21 # Each language makefile fragment must provide the following targets:
23 # foo.all.cross, foo.start.encap, foo.rest.encap,
24 # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
25 # foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
26 # foo.mostlyclean, foo.clean, foo.distclean,
27 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
29 # where `foo' is the name of the language.
31 # It should also provide rules for:
33 # - making any compiler driver (eg: g++)
34 # - the compiler proper (eg: cc1plus)
35 # - define the names for selecting the language in LANGUAGES.
37 # Actual names to use when installing a native compiler.
38 CXX_INSTALL_NAME := $(shell echo c++|sed '$(program_transform_name)')
39 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
40 CXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo c++|sed '$(program_transform_name)')
41 GXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo g++|sed '$(program_transform_name)')
42 CP_PLUGIN_HEADERS := cp-tree.h cxx-pretty-print.h name-lookup.h type-utils.h operators.def cp-trait.def contracts.h
44 #\f
45 # Define the names for selecting c++ in LANGUAGES.
46 # Note that it would be nice to move the dependency on g++
47 # into the C++ rule, but that needs a little bit of work
48 # to do the right thing within all.cross.
49 c++: cc1plus$(exeext)
50 c++.serial = cc1plus$(exeext)
52 # Tell GNU make to ignore these if they exist.
53 .PHONY: c++
55 CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES)
57 CFLAGS-cp/module.o += -DHOST_MACHINE=\"$(host)\" \
58         -DTARGET_MACHINE=\"$(target)\" $(ZLIBINC)
60 # In non-release builds, use a date-related module version.
61 ifneq ($(DEVPHASE_c),)
62 # Some date's don't grok 'r', if so, simply use today's date,
63 # but use date from previous stage if bootstrapping to avoid breaking
64 # bootstraps across midnight.
65 s-cp-module-version: $(srcdir)/cp/module.cc
66         MODULE_VERSION=`if date -r $(srcdir)/cp/module.cc '+%y%m%d%H%MU' \
67                           2>/dev/null; then :; \
68                         elif test ../prev-gcc/s-cp-module-version -nt \
69                                $(srcdir)/cp/module.cc; then \
70                           cat ../prev-gcc/s-cp-module-version; \
71                         else \
72                           date '+%y%m%d0000U' 2>/dev/null; \
73                         fi`; \
74         echo $${MODULE_VERSION} > s-cp-module-version
75 cp/module.o: s-cp-module-version
76 CFLAGS-cp/module.o += -DMODULE_VERSION='$(shell cat s-cp-module-version)'
77 endif
79 # Create the compiler driver for g++.
80 GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
81 xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
82         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
83           $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
84           $(EXTRA_GCC_LIBS) $(LIBS)
86 # Create a version of the g++ driver which calls the cross-compiler.
87 g++-cross$(exeext): xg++$(exeext)
88         -rm -f g++-cross$(exeext)
89         cp xg++$(exeext) g++-cross$(exeext)
91 # The compiler itself.
92 # Shared with C front end:
93 CXX_C_OBJS = attribs.o \
94         $(C_COMMON_OBJS) $(CXX_TARGET_OBJS)
96 # Language-specific object files for C++ and Objective C++.
97 CXX_AND_OBJCXX_OBJS = \
98         cp/call.o cp/class.o cp/constexpr.o cp/constraint.o \
99         cp/coroutines.o cp/cp-gimplify.o \
100         cp/cp-objcp-common.o cp/cp-ubsan.o \
101         cp/cvt.o cp/contracts.o cp/cxx-pretty-print.o \
102         cp/decl.o cp/decl2.o cp/dump.o \
103         cp/error.o cp/except.o cp/expr.o \
104         cp/friend.o cp/init.o \
105         cp/lambda.o cp/lex.o cp/logic.o \
106         cp/mangle.o cp/mapper-client.o cp/mapper-resolver.o \
107         cp/method.o cp/module.o \
108         cp/name-lookup.o cp/optimize.o \
109         cp/parser.o cp/pt.o cp/ptree.o \
110         cp/rtti.o \
111         cp/search.o cp/semantics.o \
112         cp/tree.o cp/typeck.o cp/typeck2.o \
113         cp/vtable-class-hierarchy.o $(CXX_C_OBJS)
115 ifeq ($(if $(wildcard ../stage_current),$(shell cat \
116   ../stage_current)),stageautofeedback)
117 $(CXX_AND_OBJCXX_OBJS): CFLAGS += -fauto-profile=cc1plus.fda
118 $(CXX_AND_OBJCXX_OBJS): cc1plus.fda
119 endif
121 # Language-specific object files for C++.
122 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
124 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
126 # Use strict warnings for this front end.
127 cp-warn = $(STRICT_WARN)
129 # compute checksum over all object files and the options
130 # re-use the checksum from the prev-final stage so it passes
131 # the bootstrap comparison and allows comparing of the cc1 binary
132 cc1plus-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
133         $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) 
134         if [ -f ../stage_final ] \
135            && cmp -s ../stage_current ../stage_final; then \
136            cp ../prev-gcc/cc1plus-checksum.cc cc1plus-checksum.cc; \
137         else \
138           build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) \
139                      checksum-options > cc1plus-checksum.cc.tmp &&         \
140           $(srcdir)/../move-if-change cc1plus-checksum.cc.tmp cc1plus-checksum.cc; \
141         fi
143 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(LIBDEPS) $(c++.prev)
144         @$(call LINK_PROGRESS,$(INDEX.c++),start)
145         +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
146               $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) \
147                 $(LIBS) $(BACKENDLIBS)
148         @$(call LINK_PROGRESS,$(INDEX.c++),end)
150 ifeq ($(ENABLE_MAINTAINER_RULES), true)
151 # Special build rule.  This is a maintainer rule, that is only
152 # available when GCC is configured with --enable-maintainer-mode.  In
153 # other cases, it is not available to avoid triggering rebuilds if a
154 # user has the source checked out with unusual timestamps.
155 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
156 else
157 # We keep the rule so that you can still force a rebuild, even if you
158 # didn't configure GCC with --enable-maintainer-mode, by manually
159 # deleting the $(srcdir)/cp/cfns.h file.
160 $(srcdir)/cp/cfns.h:
161 endif
162         gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
163                 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
165 # We always need the dependency on the .gperf file because it itself is generated.
166 ifeq ($(ENABLE_MAINTAINER_RULES), true)
167 $(srcdir)/cp/std-name-hint.h: $(srcdir)/cp/std-name-hint.gperf
168 else
169 $(srcdir)/cp/std-name-hint.h: | $(srcdir)/cp/std-name-hint.gperf
170 endif
171         gperf -o -C -E -k '1,2,7,11,$$' -D -N find -L C++ \
172                 $(srcdir)/cp/std-name-hint.gperf --output-file $(srcdir)/cp/std-name-hint.h
174 # The std-name-hint.gperf file itself is generated from a general
175 # C++ API description.
176 ifeq ($(ENABLE_MAINTAINER_RULES), true)
177 $(srcdir)/cp/std-name-hint.gperf: $(srcdir)/cp/gen-cxxapi-file.py $(srcdir)/cp/cxxapi-data.csv
178 else
179 $(srcdir)/cp/std-name-hint.gperf:
180 endif
181         python3 $(srcdir)/cp/gen-cxxapi-file.py hints $(srcdir)/cp/cxxapi-data.csv > $@
182 ifneq ($(ENABLE_MAINTAINER_RULES), true)
183 .SECONDARY: $(srcdir)/cp/std-name-hint.gperf
184 endif
186 # This is the file that depends on the generated header file.
187 cp/name-lookup.o: $(srcdir)/cp/std-name-hint.h
189 components_in_prev = "bfd opcodes binutils fixincludes gas gcc gmp mpfr mpc isl gold intl ld libbacktrace libcpp libcody libdecnumber libiberty libiberty-linker-plugin libiconv zlib lto-plugin libctf libsframe"
190 components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace libphobos zlib libgomp libatomic"
192 cc1plus.fda: create_fdas_for_cc1plus
193         $(PROFILE_MERGER) $(shell ls -ha cc1plus_*.fda) --output_file cc1plus.fda -gcov_version 2
195 create_fdas_for_cc1plus: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
196         for component_in_prev in "$(components_in_prev)"; do \
197           perf_path=../prev-$$component_in_prev/$(PERF_DATA); \
198           echo "Perf path:"; \
199           echo $$perf_path; \
200           if [ -f $$perf_path ]; then \
201             profile_name=cc1plus_$$component_in_prev.fda; \
202             $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
203           fi; \
204         done;
206         for component_in_prev_target in "$(components_in_prev_target)"; do \
207           perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \
208           echo "Perf path:"; \
209           echo $$perf_path; \
210           if [ -f $$perf_path ]; then \
211             profile_name=cc1plus_$$component_in_prev_target.fda; \
212             $(CREATE_GCOV) -binary ../prev-gcc/cc1plus$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
213           fi; \
214         done;
216         $(STAMP) $@
218 # Build hooks:
220 c++.all.cross: g++-cross$(exeext)
221 c++.start.encap: xg++$(exeext)
222 c++.rest.encap:
223 c++.info:
224 c++.install-info:
225 c++.dvi:
226 c++.install-dvi:
227 c++.pdf:
228 c++.install-pdf:
229 c++.install-html:
230 c++.html:
231 c++.srcinfo:
232 c++.srcextra:
234 c++.tags: force
235         cd $(srcdir)/cp; $(ETAGS) -o TAGS.sub *.cc *.h \
236           ../../libcody/*.cc ../../c++tools/*.cc \
237           --language=none --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
238         $(ETAGS) --include TAGS.sub --include ../TAGS.sub
240 c++.man: doc/g++.1
242 c++.srcman: doc/g++.1
243         -cp -p $^ $(srcdir)/doc
245 # C++ selftests
247 # If C++ is enabled, require the selftests to be run for it
248 # at each stage of the build:
249 selftest-c++: s-selftest-c++
251 CPP_SELFTEST_DEPS = cc1plus$(exeext) $(SELFTEST_DEPS)
252 CPP_SELFTEST_FLAGS = -xc++ $(SELFTEST_FLAGS)
254 # Run the C++ selftests
255 s-selftest-c++: $(CPP_SELFTEST_DEPS)
256         $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS)
257         $(STAMP) $@
259 # Convenience method for running C++ selftests under gdb:
260 .PHONY: selftest-c++-gdb
261 selftest-c++-gdb: $(CPP_SELFTEST_DEPS)
262         $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS) \
263           -wrapper gdb,--args
265 # Convenience method for running C++ selftests under valgrind:
266 .PHONY: selftest-c++-valgrind
267 selftest-c++-valgrind: $(CPP_SELFTEST_DEPS)
268         $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS) \
269           -wrapper valgrind,--leak-check=full
271 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
272 # check targets.  However, our DejaGNU framework requires 'check-g++' as its
273 # entry point.  We feed the former to the latter here.
274 check-c++ : check-g++
276 # Run the testsuite in C++17 mode.
277 check-c++1z: check-c++17
278 check-c++17:
279         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=17 check-g++
281 # Run the testsuite in all standard conformance levels.
282 check-c++-all:
283         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,17,20,23,impcx" check-g++
285 # Run the testsuite with garbage collection at every opportunity.
286 check-g++-strict-gc:
287         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0,--param,hash-table-verification-limit=10000" \
288           TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
289 check-c++-subtargets : check-g++-subtargets
290 # List of targets that can use the generic check- rule and its // variant.
291 lang_checks += check-g++
292 lang_checks_parallelized += check-g++
293 # For description see the check_$lang_parallelize comment in gcc/Makefile.in.
294 check_g++_parallelize = 10000
296 # Install hooks:
297 # cc1plus is installed elsewhere as part of $(COMPILERS).
299 # Install the driver program as $(target)-g++ and $(target)-c++, and
300 # also as g++ and c++ if native.
301 c++.install-common: installdirs
302         -if test "$(enable_as_accelerator)" != "yes" ; then \
303           rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
304           $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
305           chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
306           rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
307           ( cd $(DESTDIR)$(bindir) && \
308             $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
309           if [ -f cc1plus$(exeext) ] ; then \
310             if [ ! -f g++-cross$(exeext) ] ; then \
311               rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
312               ( cd $(DESTDIR)$(bindir) && \
313                 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
314               rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
315               ( cd $(DESTDIR)$(bindir) && \
316                 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
317             fi ; \
318           fi; \
319         fi
321 # We can't use links because not everyone supports them.  So just copy the
322 # manpage.
323 doc/g++.1: doc/gcc.1
324         cp $< doc/g++.1
326 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
328 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
329         -rm -f $@
330         -$(INSTALL_DATA) $< $@
331         -chmod a-x $@
333 c++.install-plugin: installdirs
334 # We keep the directory structure for files in config and .def files. All
335 # other files are flattened to a single directory.
336         headers="$(CP_PLUGIN_HEADERS)"; \
337         for file in $$headers; do \
338           path=$(srcdir)/cp/$$file; \
339           dest=$(plugin_includedir)/cp/$$file; \
340           echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
341           dir=`dirname $$dest`; \
342           $(mkinstalldirs) $(DESTDIR)$$dir; \
343           $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
344         done
345 # Install import library.
346 ifeq ($(plugin_implib),yes)
347         $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
348         $(INSTALL_DATA) cc1plus$(exeext).a $(DESTDIR)$(plugin_resourcesdir)/cc1plus$(exeext).a
349 endif
351 c++.uninstall:
352         -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
353         -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
354         -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
356 # Clean hooks:
357 # A lot of the ancillary files are deleted by the main makefile.
358 # We just have to delete files specific to us.
360 c++.mostlyclean:
361         -rm -f doc/g++.1
362         -rm -f cp/*$(objext)
363         -rm -f cp/*$(coverageexts)
364         -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus*.fda
365 c++.clean:
366 c++.distclean:
367         -rm -f cp/config.status cp/Makefile
368 c++.maintainer-clean:
370 # Stage hooks:
371 # The main makefile has already created stage?/cp.
373 c++.stage1: stage1-start
374         -mv cp/*$(objext) stage1/cp
375 c++.stage2: stage2-start
376         -mv cp/*$(objext) stage2/cp
377 c++.stage3: stage3-start
378         -mv cp/*$(objext) stage3/cp
379 c++.stage4: stage4-start
380         -mv cp/*$(objext) stage4/cp
381 c++.stageprofile: stageprofile-start
382         -mv cp/*$(objext) stageprofile/cp
383 c++.stagefeedback: stagefeedback-start
384         -mv cp/*$(objext) stagefeedback/cp
385 c++.autostageprofile: stageprofile-start
386         -mv cp/*$(objext) autostageprofile/cp
387 c++.autostagefeedback: stagefeedback-start
388         -mv cp/*$(objext) autostagefeedback/cp