Skip to content

Commit f61bdc3

Browse files
WangNan0acmel
authored andcommitted
tools build: Support compiling C++ source file
Add new rule to compile .cpp file to .o use g++. C++ support is required for built-in clang and LLVM support. Linker side support will be introduced by following commits. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Alexei Starovoitov <ast@fb.com> Cc: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1474874832-134786-2-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 2ad8327 commit f61bdc3

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎tools/build/Build.include‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
9090
# - per object C flags
9191
# - BUILD_STR macro to allow '-D"$(variable)"' constructs
9292
c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
93+
cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
9394

9495
###
9596
## HOSTCC C flags

‎tools/build/Makefile.build‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ quiet_cmd_cc_o_c = CC $@
6161
quiet_cmd_host_cc_o_c = HOSTCC $@
6262
cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $<
6363

64+
quiet_cmd_cxx_o_c = CXX $@
65+
cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $<
66+
6467
quiet_cmd_cpp_i_c = CPP $@
6568
cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
6669

@@ -88,6 +91,10 @@ $(OUTPUT)%.o: %.c FORCE
8891
$(call rule_mkdir)
8992
$(call if_changed_dep,$(host)cc_o_c)
9093

94+
$(OUTPUT)%.o: %.cpp FORCE
95+
$(call rule_mkdir)
96+
$(call if_changed_dep,cxx_o_c)
97+
9198
$(OUTPUT)%.o: %.S FORCE
9299
$(call rule_mkdir)
93100
$(call if_changed_dep,$(host)cc_o_c)

0 commit comments

Comments
 (0)