xref: /linux/scripts/Makefile.thinlto (revision 637315cb400eed1dbe721954fea437a61a2d65b2)
1*9f2aee8fSRong XuPHONY := __default
2*9f2aee8fSRong Xu__default:
3*9f2aee8fSRong Xu
4*9f2aee8fSRong Xuinclude include/config/auto.conf
5*9f2aee8fSRong Xuinclude $(srctree)/scripts/Kbuild.include
6*9f2aee8fSRong Xuinclude $(srctree)/scripts/Makefile.lib
7*9f2aee8fSRong Xu
8*9f2aee8fSRong Xunative-objs := $(patsubst %.o,%.thinlto-native.o,$(call read-file, vmlinux.thinlto-index))
9*9f2aee8fSRong Xu
10*9f2aee8fSRong Xu__default: $(native-objs)
11*9f2aee8fSRong Xu
12*9f2aee8fSRong Xu# Generate .thinlto-native.o (obj) from .o (bitcode) and .thinlto.bc (summary) files
13*9f2aee8fSRong Xu# ---------------------------------------------------------------------------
14*9f2aee8fSRong Xuquiet_cmd_cc_o_bc = CC $(quiet_modtag)  $@
15*9f2aee8fSRong Xu      be_flags = $(shell sed -n '/saved_c_flags_/s/.*:= //p' \
16*9f2aee8fSRong Xu                $(dir $(<)).$(notdir $(<)).cmd)
17*9f2aee8fSRong Xu      cmd_cc_o_bc = \
18*9f2aee8fSRong Xu      $(CC) $(be_flags) -x ir -fno-lto -Wno-unused-command-line-argument \
19*9f2aee8fSRong Xu      -fthinlto-index=$(word 2, $^) -c -o $@ $<
20*9f2aee8fSRong Xu
21*9f2aee8fSRong Xutargets += $(native-objs)
22*9f2aee8fSRong Xu$(native-objs): %.thinlto-native.o: %.o %.o.thinlto.bc   FORCE
23*9f2aee8fSRong Xu	$(call if_changed,cc_o_bc)
24*9f2aee8fSRong Xu
25*9f2aee8fSRong Xu# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
26*9f2aee8fSRong Xu# ---------------------------------------------------------------------------
27*9f2aee8fSRong Xu
28*9f2aee8fSRong XuPHONY += FORCE
29*9f2aee8fSRong XuFORCE:
30*9f2aee8fSRong Xu
31*9f2aee8fSRong Xu# Read all saved command lines and dependencies for the $(targets) we
32*9f2aee8fSRong Xu# may be building above, using $(if_changed{,_dep}). As an
33*9f2aee8fSRong Xu# optimization, we don't need to read them if the target does not
34*9f2aee8fSRong Xu# exist, we will rebuild anyway in that case.
35*9f2aee8fSRong Xu
36*9f2aee8fSRong Xuexisting-targets := $(wildcard $(sort $(targets)))
37*9f2aee8fSRong Xu
38*9f2aee8fSRong Xu-include $(foreach f, $(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
39*9f2aee8fSRong Xu
40*9f2aee8fSRong Xu.PHONY: $(PHONY)
41