Commit 0c3b7e42616f1f6084cfeb0d443cbff0b2c424a9
Committed by
Arnaldo Carvalho de Melo
1 parent
18ef15c675
Exists in
smarc_imx_lf-5.15.y
and in
27 other branches
tools build: Add support for host programs format
In some cases, like for fixdep and shortly for jevents, we need to build a tool to run on the host that will be used in building a tool, such as perf, that is being cross compiled, so do like the kernel and provide HOSTCC, HOSTLD and HOSTAR to do that. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Requested-by: Andi Kleen <andi@firstfloor.org> Requested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/20160927141846.GA6589@krava Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 3 changed files with 26 additions and 4 deletions Side-by-side Diff
tools/build/Build.include
... | ... | @@ -90,4 +90,9 @@ |
90 | 90 | # - per object C flags |
91 | 91 | # - BUILD_STR macro to allow '-D"$(variable)"' constructs |
92 | 92 | c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) |
93 | + | |
94 | +### | |
95 | +## HOSTCC C flags | |
96 | + | |
97 | +host_c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj)) |
tools/build/Makefile
tools/build/Makefile.build
... | ... | @@ -58,6 +58,9 @@ |
58 | 58 | quiet_cmd_cc_o_c = CC $@ |
59 | 59 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
60 | 60 | |
61 | +quiet_cmd_host_cc_o_c = HOSTCC $@ | |
62 | + cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< | |
63 | + | |
61 | 64 | quiet_cmd_cpp_i_c = CPP $@ |
62 | 65 | cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< |
63 | 66 | |
64 | 67 | |
65 | 68 | |
66 | 69 | |
... | ... | @@ -70,16 +73,24 @@ |
70 | 73 | # If there's nothing to link, create empty $@ object. |
71 | 74 | quiet_cmd_ld_multi = LD $@ |
72 | 75 | cmd_ld_multi = $(if $(strip $(obj-y)),\ |
73 | - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) | |
76 | + $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) | |
74 | 77 | |
78 | +quiet_cmd_host_ld_multi = HOSTLD $@ | |
79 | + cmd_host_ld_multi = $(if $(strip $(obj-y)),\ | |
80 | + $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) | |
81 | + | |
82 | +ifneq ($(filter $(obj),$(hostprogs)),) | |
83 | + host = host_ | |
84 | +endif | |
85 | + | |
75 | 86 | # Build rules |
76 | 87 | $(OUTPUT)%.o: %.c FORCE |
77 | 88 | $(call rule_mkdir) |
78 | - $(call if_changed_dep,cc_o_c) | |
89 | + $(call if_changed_dep,$(host)cc_o_c) | |
79 | 90 | |
80 | 91 | $(OUTPUT)%.o: %.S FORCE |
81 | 92 | $(call rule_mkdir) |
82 | - $(call if_changed_dep,cc_o_c) | |
93 | + $(call if_changed_dep,$(host)cc_o_c) | |
83 | 94 | |
84 | 95 | $(OUTPUT)%.i: %.c FORCE |
85 | 96 | $(call rule_mkdir) |
... | ... | @@ -119,7 +130,7 @@ |
119 | 130 | |
120 | 131 | $(in-target): $(obj-y) FORCE |
121 | 132 | $(call rule_mkdir) |
122 | - $(call if_changed,ld_multi) | |
133 | + $(call if_changed,$(host)ld_multi) | |
123 | 134 | |
124 | 135 | __build: $(in-target) |
125 | 136 | @: |