1 # Top level -*- makefile -*- fragment for LTO
2 # Copyright (C) 2009-2024 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)
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/>.
22 # The name of the LTO compiler.
23 LTO_EXE = lto1$(exeext)
24 LTO_DUMP_EXE = lto-dump$(exeext)
25 LTO_DUMP_INSTALL_NAME := $(shell echo lto-dump|sed '$(program_transform_name)')
26 # The LTO-specific object files inclued in $(LTO_EXE).
27 LTO_OBJS = lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o lto/lto-partition.o lto/lto-symtab.o lto/lto-common.o
28 lto_OBJS = $(LTO_OBJS)
29 LTO_DUMP_OBJS = lto/lto-lang.o lto/lto-object.o attribs.o lto/lto-partition.o lto/lto-symtab.o lto/lto-dump.o lto/lto-common.o
30 lto_dump_OBJS = $(LTO_DUMP_OBJS)
32 # this is only useful in a LTO bootstrap, but this does not work right
33 # now. Should reenable after this is fixed, but only when LTO bootstrap
36 #ifeq ($(if $(wildcard ../stage_current),$(shell cat \
37 # ../stage_current)),stageautofeedback)
38 #$(LTO_OBJS): CFLAGS += -fauto-profile=lto1.fda
39 #$(LTO_OBJS): lto1.fda
44 lto: $(LTO_EXE) $(LTO_DUMP_EXE)
45 lto1.serial = $(LTO_EXE)
46 lto2.serial = $(LTO_DUMP_EXE)
50 # These hooks are used by the main GCC Makefile. Consult that
51 # Makefile for documentation.
56 lto.install-common: installdirs
57 $(INSTALL_PROGRAM) $(LTO_DUMP_EXE) \
58 $(DESTDIR)$(bindir)/$(LTO_DUMP_INSTALL_NAME)$(exeext)
77 rm -f $(LTO_OBJS) $(LTO_EXE) lto1*.fda $(LTO_DUMP_OBJS) $(LTO_DUMP_EXE) lto-dump.fda
91 # Use strict warnings for this front end.
92 lto-warn = $(STRICT_WARN)
94 $(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS) $(lto1.prev)
95 @$(call LINK_PROGRESS,$(INDEX.lto1),start)
96 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
97 $(LTO_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS)
98 @$(call LINK_PROGRESS,$(INDEX.lto1),end)
100 $(LTO_DUMP_EXE): $(LTO_DUMP_OBJS) $(BACKEND) $(LIBDEPS) $(lto2.prev)
101 @$(call LINK_PROGRESS,$(INDEX.lto2),start)
102 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
103 $(LTO_DUMP_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS)
104 @$(call LINK_PROGRESS,$(INDEX.lto2),end)
106 lto/lto-dump.o: $(LTO_OBJS)
108 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"
109 components_in_prev_target = "libstdc++-v3 libsanitizer libvtv libgcc libbacktrace libphobos zlib libgomp libatomic"
111 lto1.fda: create_fdas_for_lto1
112 $(PROFILE_MERGER) $(shell ls -ha lto1_*.fda) --output_file lto1.fda -gcov_version 2
114 create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext) ../prev-gcc/$(PERF_DATA)
115 for component_in_prev in "$(components_in_prev)"; do \
116 perf_path=../prev-$$component_in_prev/$(PERF_DATA); \
119 if [ -f $$perf_path ]; then \
120 profile_name=lto1_$$component_in_prev.fda; \
121 $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
125 for component_in_prev_target in "$(components_in_prev_target)"; do \
126 perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \
129 if [ -f $$perf_path ]; then \
130 profile_name=lto1_$$component_in_prev_target.fda; \
131 $(CREATE_GCOV) -binary ../prev-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \
137 # LTO testing is done as part of C/C++/Fortran etc. testing.
140 # No LTO-specific selftests