DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Changes to makefiles to allow building apps using g++
@ 2014-01-13 22:45 Dan Kan
  2014-01-14 11:29 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Kan @ 2014-01-13 22:45 UTC (permalink / raw)
  To: dev

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")

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] Changes to makefiles to allow building apps using g++
  2014-01-13 22:45 [dpdk-dev] Changes to makefiles to allow building apps using g++ Dan Kan
@ 2014-01-14 11:29 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-01-14 11:29 UTC (permalink / raw)
  To: Dan Kan; +Cc: dev

Hello Dan,

13/01/2014 23:45, Dan Kan:
> 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.

If you need it, it's an excellent reason to integrate it.
Moreover we can guess that you're not alone to have this need.

> 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.

I think that it should be documented.
What about a file doc/build-app.rst ?
You could start documenting how it is different for C++.

> +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

Could you factorize the common flags, please ?

Thank you
-- 
Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-14 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-13 22:45 [dpdk-dev] Changes to makefiles to allow building apps using g++ Dan Kan
2014-01-14 11:29 ` Thomas Monjalon

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).