]>
Commit | Line | Data |
---|---|---|
d7f09764 | 1 | # Top level -*- makefile -*- fragment for LTO |
83ffe9cd | 2 | # Copyright (C) 2009-2023 Free Software Foundation, Inc. |
d7f09764 DN |
3 | |
4 | #This file is part of GCC. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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/>. | |
19 | ||
20 | # Variables | |
21 | ||
22 | # The name of the LTO compiler. | |
23 | LTO_EXE = lto1$(exeext) | |
66d62d9f | 24 | LTO_DUMP_EXE = lto-dump$(exeext) |
38613b9b | 25 | LTO_DUMP_INSTALL_NAME := $(shell echo lto-dump|sed '$(program_transform_name)') |
d7f09764 | 26 | # The LTO-specific object files inclued in $(LTO_EXE). |
a79420f9 | 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 |
7c6fedd2 | 28 | lto_OBJS = $(LTO_OBJS) |
66d62d9f HK |
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) | |
d7f09764 | 31 | |
277d7ee0 AK |
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 | |
34 | # is enabled. | |
35 | ||
e9ac1f86 JJ |
36 | #ifeq ($(if $(wildcard ../stage_current),$(shell cat \ |
37 | # ../stage_current)),stageautofeedback) | |
277d7ee0 AK |
38 | #$(LTO_OBJS): CFLAGS += -fauto-profile=lto1.fda |
39 | #$(LTO_OBJS): lto1.fda | |
40 | #endif | |
41 | ||
d7f09764 DN |
42 | # Rules |
43 | ||
d326ebc9 | 44 | lto: $(LTO_EXE) $(LTO_DUMP_EXE) |
a774a6a2 JJ |
45 | lto1.serial = $(LTO_EXE) |
46 | lto2.serial = $(LTO_DUMP_EXE) | |
d326ebc9 | 47 | |
a774a6a2 | 48 | .PHONY: lto |
d326ebc9 | 49 | |
d7f09764 DN |
50 | # These hooks are used by the main GCC Makefile. Consult that |
51 | # Makefile for documentation. | |
d326ebc9 JJ |
52 | lto.all.cross: |
53 | lto.start.encap: | |
d7f09764 DN |
54 | lto.rest.encap: |
55 | lto.tags: | |
66d62d9f HK |
56 | lto.install-common: installdirs |
57 | $(INSTALL_PROGRAM) $(LTO_DUMP_EXE) \ | |
6e42c90c | 58 | $(DESTDIR)$(bindir)/$(LTO_DUMP_INSTALL_NAME)$(exeext) |
66d62d9f | 59 | |
d7f09764 DN |
60 | lto.install-man: |
61 | lto.install-info: | |
62 | lto.dvi: | |
c3e80a16 | 63 | lto.install-dvi: |
d7f09764 DN |
64 | lto.pdf: |
65 | lto.install-pdf: | |
66 | lto.html: | |
55bcd32b | 67 | lto.install-html: |
d7f09764 DN |
68 | lto.uninstall: |
69 | lto.info: | |
70 | lto.man: | |
71 | lto.srcextra: | |
72 | lto.srcman: | |
73 | lto.srcinfo: | |
74 | lto.install-plugin: | |
75 | ||
76 | lto.mostlyclean: | |
0c77a090 | 77 | rm -f $(LTO_OBJS) $(LTO_EXE) lto1*.fda $(LTO_DUMP_OBJS) $(LTO_DUMP_EXE) lto-dump.fda |
d7f09764 DN |
78 | |
79 | lto.clean: | |
80 | lto.distclean: | |
81 | lto.maintainer-clean: | |
82 | lto.stage1: | |
83 | lto.stage2: | |
84 | lto.stage3: | |
85 | lto.stage4: | |
86 | lto.stageprofile: | |
87 | lto.stagefeedback: | |
88 | ||
89 | # LTO rules. | |
90 | ||
91 | # Use strict warnings for this front end. | |
92 | lto-warn = $(STRICT_WARN) | |
93 | ||
a774a6a2 | 94 | $(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS) $(lto1.prev) |
d326ebc9 | 95 | @$(call LINK_PROGRESS,$(INDEX.lto1),start) |
427b248d | 96 | +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ |
6b3456d1 | 97 | $(LTO_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS) |
d326ebc9 | 98 | @$(call LINK_PROGRESS,$(INDEX.lto1),end) |
d7f09764 | 99 | |
a774a6a2 | 100 | $(LTO_DUMP_EXE): $(LTO_DUMP_OBJS) $(BACKEND) $(LIBDEPS) $(lto2.prev) |
d326ebc9 | 101 | @$(call LINK_PROGRESS,$(INDEX.lto2),start) |
66d62d9f HK |
102 | +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ |
103 | $(LTO_DUMP_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS) | |
d326ebc9 | 104 | @$(call LINK_PROGRESS,$(INDEX.lto2),end) |
66d62d9f | 105 | |
fe1d1a8b | 106 | lto/lto-dump.o: $(LTO_OBJS) |
66d62d9f | 107 | |
0c77a090 ER |
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" | |
110 | ||
111 | .PHONY: create_fdas_for_lto1 | |
112 | ||
113 | lto1.fda: create_fdas_for_lto1 | |
114 | $(PROFILE_MERGER) $(shell ls -ha lto1_*.fda) --output_file lto1.fda -gcov_version 2 | |
115 | ||
116 | create_fdas_for_lto1: ../stage1-gcc/lto1$(exeext) ../prev-gcc/$(PERF_DATA) | |
117 | for component_in_prev in "$(components_in_prev)"; do \ | |
118 | perf_path=../prev-$$component_in_prev/$(PERF_DATA); \ | |
119 | echo "Perf path:"; \ | |
120 | echo $$perf_path; \ | |
121 | if [ -f $$perf_path ]; then \ | |
122 | profile_name=lto1_$$component_in_prev.fda; \ | |
123 | $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \ | |
124 | fi; \ | |
125 | done; | |
126 | ||
127 | for component_in_prev_target in "$(components_in_prev_target)"; do \ | |
128 | perf_path=../prev-$(TARGET_SUBDIR)/$$component_in_prev_target/$(PERF_DATA); \ | |
129 | echo "Perf path:"; \ | |
130 | echo $$perf_path; \ | |
131 | if [ -f $$perf_path ]; then \ | |
132 | profile_name=lto1_$$component_in_prev_target.fda; \ | |
133 | $(CREATE_GCOV) -binary ../stage1-gcc/lto1$(exeext) -gcov $$profile_name -profile $$perf_path -gcov_version 2; \ | |
134 | fi; \ | |
135 | done; | |
277d7ee0 | 136 | |
1915c739 JJ |
137 | # LTO testing is done as part of C/C++/Fortran etc. testing. |
138 | check-lto: | |
033eb567 DM |
139 | |
140 | # No LTO-specific selftests | |
141 | selftest-lto: |