From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by dpdk.org (Postfix) with ESMTP id E2E7CDE0 for ; Mon, 13 Jan 2014 23:44:25 +0100 (CET) Received: by mail-lb0-f170.google.com with SMTP id u14so1889966lbd.15 for ; Mon, 13 Jan 2014 14:45:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=R3Mu8nKHAyY0hbV3w/jXLgytECfqup4UpQHZz7E5zOk=; b=GmX3uOUGwTWqH97jRVCnslfVUPDBxgNMRRZAlamI9iOCzTP0Ysm9VAq4buRUXlv5db 8Z5Xjc5Ren2H2WuU4JcjKn4n1habXew8O3kBdgeFAWMGCAkpo6Mmr4Fq2tzCFuYUpSmr 5awbCntNGzEuNoFvEO/dCgEhx3KGQkwE+w/KMMa61EZOdIOWHIHaLo5Gf9IblpfX8sqw p0Cfp1Gyz8tLBhz7qvLDwYvV2LuN7FCINV4Pmi4w2/V5zKMEyXuPfJHlGCGQw6ZafNqI 5VnjY1Rib4+EhF2U/o2SrEsgXnIUTu1G9gDQYFqtKZT7TF8SYDOrybEk3emQQeh3UfUy bREQ== X-Gm-Message-State: ALoCoQn94mzKAYoyxKi+iBJ/c7TMZWpn7MUFR1aIARV4RdAUrbb8pJ5DBJapU79J0iaNE0BuAWVM MIME-Version: 1.0 X-Received: by 10.153.9.97 with SMTP id dr1mr5495689lad.43.1389653138891; Mon, 13 Jan 2014 14:45:38 -0800 (PST) Received: by 10.112.137.34 with HTTP; Mon, 13 Jan 2014 14:45:38 -0800 (PST) Date: Mon, 13 Jan 2014 14:45:38 -0800 Message-ID: From: Dan Kan To: "dev@dpdk.org" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] Changes to makefiles to allow building apps using g++ X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jan 2014 22:44:26 -0000 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")