From: Dan Kan <dan@nyansa.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] Changes to makefiles to allow building apps using g++
Date: Mon, 13 Jan 2014 14:45:38 -0800 [thread overview]
Message-ID: <CA+RRbcr0u3NhCDw5Kv5okk=Wbv4CGxKWC+5dnbto6S2Ke1k+3Q@mail.gmail.com> (raw)
I made changes to makefiles to at least allow app development to be in done
C++. I'm wondering if the community is interested in getting these changes
as a patch. The dpdk library must still be compiled using gcc. However, the
applications can be compiled using g++ by setting CC=g++, e.g. "make
CC=g++". With g++, non-trivial designated initializers will no longer be
allowed among others. As a result, most sample apps cannot be compiled
using g++ without modifications; hello world app works with g++. You will
also need to specify your c++ file extension if it's not named cpp, e.g.
make CC=g++ CXX-suffix=cc. The behavior for gcc or icc compilation remains
unmodified. Anyway, let me know if it's worthwhile to submit a patch.
Thanks.
Here is the preview of the patch.
+++ mk/internal/rte.compile-pre.mk 2014-01-13 14:14:34.278816220 -0800
@@ -33,11 +33,14 @@
# Common to rte.lib.mk, rte.app.mk, rte.obj.mk
#
+CXX-suffix = cpp
+
SRCS-all := $(SRCS-y) $(SRCS-n) $(SRCS-)
# convert source to obj file
src2obj = $(strip $(patsubst %.c,%.o,\
- $(patsubst %.S,%_s.o,$(1))))
+ $(patsubst %.$(CXX-suffix),%.o,\
+ $(patsubst %.S,%_s.o,$(1)))))
# add a dot in front of the file name
dotfile = $(strip $(foreach f,$(1),\
@@ -46,12 +49,14 @@
# convert source/obj files into dot-dep filename (does not
# include .S files)
src2dep = $(strip $(call dotfile,$(patsubst %.c,%.o.d, \
- $(patsubst %.S,,$(1)))))
+ $(patsubst %.$(CXX-suffix),%.o.d, \
+ $(patsubst %.S,,$(1))))))
obj2dep = $(strip $(call dotfile,$(patsubst %.o,%.o.d,$(1))))
# convert source/obj files into dot-cmd filename
src2cmd = $(strip $(call dotfile,$(patsubst %.c,%.o.cmd, \
- $(patsubst %.S,%_s.o.cmd,$(1)))))
+ $(patsubst %.$(CXX-suffix),%.o.cmd, \
+ $(patsubst %.S,%_s.o.cmd,$(1))))))
obj2cmd = $(strip $(call dotfile,$(patsubst %.o,%.o.cmd,$(1))))
OBJS-y := $(call src2obj,$(SRCS-y))
@@ -137,6 +142,22 @@
$(depfile_newer)),\
$(C_TO_O_DO))
+%.o: %.$(CXX-suffix) $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE
+ @[ -d $(dir $@) ] || mkdir -p $(dir $@)
+ $(if $(D),\
+ @echo -n "$< -> $@ " ; \
+ echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
+ echo -n "cmdline_changed=$(call boolean,$(call
cmdline_changed,$(C_TO_O))) " ; \
+ echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
+ echo "depfile_newer=$(call boolean,$(depfile_newer))")
+ $(if $(or \
+ $(file_missing),\
+ $(call cmdline_changed,$(C_TO_O)),\
+ $(depfile_missing),\
+ $(depfile_newer)),\
+ $(C_TO_O_DO))
+
+
# command to assemble a .S file to generate an object
ifeq ($(USE_HOST),1)
S_TO_O = $(CPP) $(HOST_CPPFLAGS) $($(@)_CPPFLAGS) $(HOST_EXTRA_CPPFLAGS)
$< $(@).tmp && \
diff -ur ../temp/dpdk-1.5.1r2/mk/toolchain/gcc/rte.vars.mk mk/toolchain/gcc/
rte.vars.mk
--- ../temp/dpdk-1.5.1r2/mk/toolchain/gcc/rte.vars.mk 2014-01-02
07:03:19.000000000 -0800
+++ mk/toolchain/gcc/rte.vars.mk 2014-01-13 14:07:33.148292590 -0800
@@ -68,9 +68,16 @@
endif
endif
+ifeq ($(CC), $(CROSS)g++)
+TOOLCHAIN_CFLAGS += -D__STDC_LIMIT_MACROS
+WERROR_FLAGS := -W -Wall -Werror
+WERROR_FLAGS += -Wmissing-declarations -Wpointer-arith
+WERROR_FLAGS += -Wcast-align -Wcast-qual
+else
WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition
-Wpointer-arith
WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
+endif
WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
ifeq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
next reply other threads:[~2014-01-13 22:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 22:45 Dan Kan [this message]
2014-01-14 11:29 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+RRbcr0u3NhCDw5Kv5okk=Wbv4CGxKWC+5dnbto6S2Ke1k+3Q@mail.gmail.com' \
--to=dan@nyansa.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).