* [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux
@ 2014-07-07 23:36 Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 1/6] pmd_bond: add missing variable initialization Bruce Richardson
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
This patch set enables clang compilation on FreeBSD and Linux. It includes
patches to fix a number of compilation errors thrown up by clang, and then
adds in the appropriate toolchain makefiles and compile-time configurations.
This set has been tested with clang v3.3 on FreeBSD 10 and clang v3.4 on
Fedora linux 20. The example apps folder has not been tested at this time, this
patch set only focuses on the core libraries and apps.
Bruce Richardson (6):
pmd_bond: add missing variable initialization
Makefiles: add clang to compiler if/else block
mk: Ensure correct detection of SSE4.2 on FreeBSD
acl: add nmmintrin.h header to allow clang compilation
mk: add toolchain for clang and linuxapp target
config: add compile target for clang on BSD
config/defconfig_x86_64-native-bsdapp-clang | 71 ++++++++++++++++++++++++
config/defconfig_x86_64-native-linuxapp-clang | 63 ++++++++++++++++++++++
lib/librte_acl/acl_bld.c | 1 +
lib/librte_pmd_bond/rte_eth_bond_pmd.c | 2 +-
lib/librte_pmd_i40e/Makefile | 9 ++++
lib/librte_pmd_ixgbe/Makefile | 7 +++
lib/librte_pmd_vmxnet3/Makefile | 7 +++
mk/machine/native/rte.vars.mk | 12 +++++
mk/toolchain/clang/rte.toolchain-compat.mk | 43 +++++++++++++++
mk/toolchain/clang/rte.vars.mk | 77 +++++++++++++++++++++++++++
10 files changed, 291 insertions(+), 1 deletion(-)
create mode 100644 config/defconfig_x86_64-native-bsdapp-clang
create mode 100644 config/defconfig_x86_64-native-linuxapp-clang
create mode 100644 mk/toolchain/clang/rte.toolchain-compat.mk
create mode 100644 mk/toolchain/clang/rte.vars.mk
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 1/6] pmd_bond: add missing variable initialization
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 2/6] Makefiles: add clang to compiler if/else block Bruce Richardson
` (6 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
Variable "valid_slave" wasn't getting properly zero-initialized. This error is
flagged by clang on compile.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_pmd_bond/rte_eth_bond_pmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 048de7f..6ce4e57 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -920,7 +920,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
struct bond_dev_private *internals;
struct rte_eth_link link;
- int i, bonded_port_id, valid_slave, active_pos = -1;
+ int i, bonded_port_id, valid_slave = 0, active_pos = -1;
if (type != RTE_ETH_EVENT_INTR_LSC)
return;
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 2/6] Makefiles: add clang to compiler if/else block
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 1/6] pmd_bond: add missing variable initialization Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
` (5 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
The makefiles for a number of drivers conditionally disable certain warnings
depending on the compiler and version used. Add in clang to the list of
compiler options.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_pmd_i40e/Makefile | 9 +++++++++
lib/librte_pmd_ixgbe/Makefile | 7 +++++++
lib/librte_pmd_vmxnet3/Makefile | 7 +++++++
3 files changed, 23 insertions(+)
diff --git a/lib/librte_pmd_i40e/Makefile b/lib/librte_pmd_i40e/Makefile
index 14bce71..4b31675 100644
--- a/lib/librte_pmd_i40e/Makefile
+++ b/lib/librte_pmd_i40e/Makefile
@@ -45,6 +45,15 @@ CFLAGS += $(WERROR_FLAGS)
#
ifeq ($(CC), icc)
CFLAGS_BASE_DRIVER = -wd593
+else ifeq ($(CC), clang)
+CFLAGS_BASE_DRIVER += -Wno-sign-compare
+CFLAGS_BASE_DRIVER += -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing
+CFLAGS_BASE_DRIVER += -Wno-format
+CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers
+CFLAGS_BASE_DRIVER += -Wno-pointer-to-int-cast
+CFLAGS_BASE_DRIVER += -Wno-format-nonliteral
else
CFLAGS_BASE_DRIVER = -Wno-unused-but-set-variable
CFLAGS_BASE_DRIVER += -Wno-sign-compare
diff --git a/lib/librte_pmd_ixgbe/Makefile b/lib/librte_pmd_ixgbe/Makefile
index df47715..9278a17 100644
--- a/lib/librte_pmd_ixgbe/Makefile
+++ b/lib/librte_pmd_ixgbe/Makefile
@@ -44,6 +44,13 @@ ifeq ($(CC), icc)
# CFLAGS for icc
#
CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259
+else ifeq ($(CC), clang)
+#
+# CFLAGS for clang
+#
+CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
else
#
# CFLAGS for gcc
diff --git a/lib/librte_pmd_vmxnet3/Makefile b/lib/librte_pmd_vmxnet3/Makefile
index a44abe1..14726f9 100644
--- a/lib/librte_pmd_vmxnet3/Makefile
+++ b/lib/librte_pmd_vmxnet3/Makefile
@@ -44,6 +44,13 @@ ifeq ($(CC), icc)
# CFLAGS for icc
#
CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259
+else ifeq ($(CC), clang)
+#
+# CFLAGS for clang
+#
+CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
else
#
# CFLAGS for gcc
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 1/6] pmd_bond: add missing variable initialization Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 2/6] Makefiles: add clang to compiler if/else block Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-17 9:35 ` Thomas Monjalon
` (2 more replies)
2014-07-07 23:36 ` [dpdk-dev] [PATCH 4/6] acl: add nmmintrin.h header to allow clang compilation Bruce Richardson
` (4 subsequent siblings)
7 siblings, 3 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
Add a special case to the native target makefile, where we check if
-march=native shows SSE4.2 support. If it does not, then not everything may
build, so we check if the hardware supports SSE4.2, and use a corei7 target
explicitly to get the SSE4.2 support.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
mk/machine/native/rte.vars.mk | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mk/machine/native/rte.vars.mk b/mk/machine/native/rte.vars.mk
index da9aa71..f495973 100644
--- a/mk/machine/native/rte.vars.mk
+++ b/mk/machine/native/rte.vars.mk
@@ -56,3 +56,15 @@
# CPU_ASFLAGS =
MACHINE_CFLAGS = -march=native
+
+# on FreeBSD systems, sometimes the correct cputype is not picked up.
+# To get everything to compile, we need SSE4.2 support, so check if that is
+# reported by compiler. If not, check if the CPU actually supports it, and if
+# so, set the compilation target to be a corei7, minimum target with SSE4.2
+SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - < /dev/null | grep SSE4_2)
+ifeq ($(SSE42_SUPPORT),)
+ CPU_SSE42_SUPPORT=$(shell if [ -f /var/run/dmesg.boot ] ; then grep SSE4\.2 /var/run/dmesg.boot ; fi)
+ ifneq ($(CPU_SSE42_SUPPORT),)
+ MACHINE_CFLAGS= -march=corei7
+ endif
+endif
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 4/6] acl: add nmmintrin.h header to allow clang compilation
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
` (2 preceding siblings ...)
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target Bruce Richardson
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
Clang compile fails without nmmintrin.h being explicitly included.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_acl/acl_bld.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c
index fe7b824..873447b 100644
--- a/lib/librte_acl/acl_bld.c
+++ b/lib/librte_acl/acl_bld.c
@@ -31,6 +31,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <nmmintrin.h>
#include <rte_acl.h>
#include "tb_mem.h"
#include "acl.h"
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
` (3 preceding siblings ...)
2014-07-07 23:36 ` [dpdk-dev] [PATCH 4/6] acl: add nmmintrin.h header to allow clang compilation Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-17 10:23 ` Thomas Monjalon
2014-07-07 23:36 ` [dpdk-dev] [PATCH 6/6] config: add compile target for clang on BSD Bruce Richardson
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 8920 bytes --]
Add support for clang by adding a toolchain folder for it with the
appropriate files.
Add compilation support for clang on linux by adding a new target.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
config/defconfig_x86_64-native-linuxapp-clang | 63 ++++++++++++++++++++++
mk/toolchain/clang/rte.toolchain-compat.mk | 43 +++++++++++++++
mk/toolchain/clang/rte.vars.mk | 77 +++++++++++++++++++++++++++
3 files changed, 183 insertions(+)
create mode 100644 config/defconfig_x86_64-native-linuxapp-clang
create mode 100644 mk/toolchain/clang/rte.toolchain-compat.mk
create mode 100644 mk/toolchain/clang/rte.vars.mk
diff --git a/config/defconfig_x86_64-native-linuxapp-clang b/config/defconfig_x86_64-native-linuxapp-clang
new file mode 100644
index 0000000..31f2aa4
--- /dev/null
+++ b/config/defconfig_x86_64-native-linuxapp-clang
@@ -0,0 +1,63 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#include "common_linuxapp"
+
+#
+# machine can define specific variables or action for a specific board
+# RTE_MACHINE can be:
+# default nothing specific
+# native current machine
+# atm Intel® Atom™ microarchitecture
+# nhm Intel® microarchitecture code name Nehalem
+# wsm Intel® microarchitecture code name Westmere
+# snb Intel® microarchitecture code name Sandy Bridge
+# ivb Intel® microarchitecture code name Ivy Bridge
+#
+# Note: if your compiler does not support the relevant -march options,
+# it will be compiled with whatever latest processor the compiler supports!
+#
+CONFIG_RTE_MACHINE="native"
+
+#
+# define the architecture we compile for.
+# CONFIG_RTE_ARCH can be i686, x86_64, x86_64_32
+#
+CONFIG_RTE_ARCH="x86_64"
+CONFIG_RTE_ARCH_X86_64=y
+
+#
+# The compiler we use.
+# Can be gcc or icc.
+#
+CONFIG_RTE_TOOLCHAIN="clang"
+CONFIG_RTE_TOOLCHAIN_CLANG=y
diff --git a/mk/toolchain/clang/rte.toolchain-compat.mk b/mk/toolchain/clang/rte.toolchain-compat.mk
new file mode 100644
index 0000000..862b7df
--- /dev/null
+++ b/mk/toolchain/clang/rte.toolchain-compat.mk
@@ -0,0 +1,43 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# CPUID-related options
+#
+# This was added to support compiler versions which might not support all the
+# flags we need
+#
+
+#find out CLANG version
+
+CLANG_MAJOR_VERSION = $(shell $(CC) -dumpversion | cut -f1 -d.)
+
+CLANG_MINOR_VERSION = $(shell $(CC) -dumpversion | cut -f2 -d.)
diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk
new file mode 100644
index 0000000..d4e6862
--- /dev/null
+++ b/mk/toolchain/clang/rte.vars.mk
@@ -0,0 +1,77 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# toolchain:
+#
+# - define CC, LD, AR, AS, ... (overriden by cmdline value)
+# - define TOOLCHAIN_CFLAGS variable (overriden by cmdline value)
+# - define TOOLCHAIN_LDFLAGS variable (overriden by cmdline value)
+# - define TOOLCHAIN_ASFLAGS variable (overriden by cmdline value)
+#
+# examples for RTE_TOOLCHAIN: gcc, icc
+#
+
+ifeq ($(KERNELRELEASE),)
+CC = $(CROSS)clang
+else
+CC = $(CROSS)gcc
+endif
+CPP = $(CROSS)cpp
+# for now, we don't use as but nasm.
+# AS = $(CROSS)as
+AS = nasm
+AR = $(CROSS)ar
+LD = $(CROSS)ld
+OBJCOPY = $(CROSS)objcopy
+OBJDUMP = $(CROSS)objdump
+STRIP = $(CROSS)strip
+READELF = $(CROSS)readelf
+GCOV = $(CROSS)gcov
+
+HOSTCC = clang
+HOSTAS = as
+
+TOOLCHAIN_ASFLAGS =
+TOOLCHAIN_CFLAGS =
+TOOLCHAIN_LDFLAGS =
+
+WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
+WERROR_FLAGS += -Wnested-externs -Wcast-qual
+WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
+WERROR_FLAGS += -Wundef -Wwrite-strings
+
+# process cpu flags
+include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
+
+export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
+export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH 6/6] config: add compile target for clang on BSD
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
` (4 preceding siblings ...)
2014-07-07 23:36 ` [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target Bruce Richardson
@ 2014-07-07 23:36 ` Bruce Richardson
2014-07-11 5:31 ` [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Zhan, Zhaochen
2014-07-18 23:58 ` Thomas Monjalon
7 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-07 23:36 UTC (permalink / raw)
To: dev
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3346 bytes --]
Add option to compile on FreeBSD using the clang compiler, now the
default compiler on FreeBSD 10.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
config/defconfig_x86_64-native-bsdapp-clang | 71 +++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100644 config/defconfig_x86_64-native-bsdapp-clang
diff --git a/config/defconfig_x86_64-native-bsdapp-clang b/config/defconfig_x86_64-native-bsdapp-clang
new file mode 100644
index 0000000..55c7316
--- /dev/null
+++ b/config/defconfig_x86_64-native-bsdapp-clang
@@ -0,0 +1,71 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#include "common_bsdapp"
+
+#
+# define executive environment
+#
+# CONFIG_RTE_EXEC_ENV can be linuxapp, baremetal, bsdapp
+#
+CONFIG_RTE_EXEC_ENV="bsdapp"
+CONFIG_RTE_EXEC_ENV_BSDAPP=y
+
+#
+# machine can define specific variables or action for a specific board
+# RTE_MACHINE can be:
+# default nothing specific
+# native current machine
+# atm Intel® Atom™ microarchitecture
+# nhm Intel® microarchitecture code name Nehalem
+# wsm Intel® microarchitecture code name Westmere
+# snb Intel® microarchitecture code name Sandy Bridge
+# ivb Intel® microarchitecture code name Ivy Bridge
+#
+# Note: if your compiler does not support the relevant -march options,
+# it will be compiled with whatever latest processor the compiler supports!
+#
+CONFIG_RTE_MACHINE="native"
+
+#
+# define the architecture we compile for.
+# CONFIG_RTE_ARCH can be i686, x86_64, x86_64_32
+#
+CONFIG_RTE_ARCH="x86_64"
+CONFIG_RTE_ARCH_X86_64=y
+
+#
+# The compiler we use.
+# Can be gcc or icc.
+#
+CONFIG_RTE_TOOLCHAIN="clang"
+CONFIG_RTE_TOOLCHAIN_CLANG=y
--
1.9.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
` (5 preceding siblings ...)
2014-07-07 23:36 ` [dpdk-dev] [PATCH 6/6] config: add compile target for clang on BSD Bruce Richardson
@ 2014-07-11 5:31 ` Zhan, Zhaochen
2014-07-18 23:58 ` Thomas Monjalon
7 siblings, 0 replies; 16+ messages in thread
From: Zhan, Zhaochen @ 2014-07-11 5:31 UTC (permalink / raw)
To: Richardson, Bruce, dev
> > This patch set enables clang compilation on FreeBSD and Linux. It
> > includes patches to fix a number of compilation errors thrown up by
> > clang, and then adds in the appropriate toolchain makefiles and
> > compile-time configurations.
> >
> > This set has been tested with clang v3.3 on FreeBSD 10 and clang
> > v3.4 on Fedora linux 20. The example apps folder has not been tested
> > at this time, this patch set only focuses on the core libraries and apps.
> >
> > Bruce Richardson (6):
> > pmd_bond: add missing variable initialization
> > Makefiles: add clang to compiler if/else block
> > mk: Ensure correct detection of SSE4.2 on FreeBSD
> > acl: add nmmintrin.h header to allow clang compilation
> > mk: add toolchain for clang and linuxapp target
> > config: add compile target for clang on BSD
>
> Tested-by: Zhaochen Zhan <zhaochen.zhan@intel.com<mailto:zhaochen.zhan@intel.com>>
>
> We verified the compilation on FreeBSD 10.0 with Clang 3.3 and Fedora
> 20 with Clang 3.4.
> We also verified some simple test cases (pmd, cmdline, hello_world and
> timer) on FreeBSD with Clang 3.3.
Acked-by: Zhaochen Zhan <zhaochen.zhan@intel.com<mailto:zhaochen.zhan@intel.com>>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
@ 2014-07-17 9:35 ` Thomas Monjalon
2014-07-17 21:42 ` Bruce Richardson
2014-07-17 10:25 ` Thomas Monjalon
2014-07-17 21:47 ` [dpdk-dev] [PATCH v2 " Bruce Richardson
2 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2014-07-17 9:35 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
Hi Bruce,
2014-07-08 00:36, Bruce Richardson:
> Add a special case to the native target makefile, where we check if
> -march=native shows SSE4.2 support. If it does not, then not everything may
> build, so we check if the hardware supports SSE4.2, and use a corei7 target
> explicitly to get the SSE4.2 support.
[...]
> MACHINE_CFLAGS = -march=native
> +
> +# on FreeBSD systems, sometimes the correct cputype is not picked up.
> +# To get everything to compile, we need SSE4.2 support, so check if that is
> +# reported by compiler. If not, check if the CPU actually supports it, and if
> +# so, set the compilation target to be a corei7, minimum target with SSE4.2
> +SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - < /dev/null | grep SSE4_2)
> +ifeq ($(SSE42_SUPPORT),)
> + CPU_SSE42_SUPPORT=$(shell if [ -f /var/run/dmesg.boot ] ; then grep SSE4\.2 /var/run/dmesg.boot ; fi)
> + ifneq ($(CPU_SSE42_SUPPORT),)
> + MACHINE_CFLAGS= -march=corei7
> + endif
> +endif
What do you think of this change?
- CPU_SSE42_SUPPORT=$(shell if [ -f /var/run/dmesg.boot ] ; then grep SSE4\.2 /var/run/dmesg.boot ; fi)
+ CPU_SSE42_SUPPORT = $(shell grep SSE4\.2 /var/run/dmesg.boot 2>/dev/null)
It's simpler and should produce the same result.
If you agree, I'll change it before applying.
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target
2014-07-07 23:36 ` [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target Bruce Richardson
@ 2014-07-17 10:23 ` Thomas Monjalon
2014-07-17 17:54 ` Richardson, Bruce
0 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2014-07-17 10:23 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
2014-07-08 00:36, Bruce Richardson:
> --- /dev/null
> +++ b/mk/toolchain/clang/rte.vars.mk
[...]
> +ifeq ($(KERNELRELEASE),)
> +CC = $(CROSS)clang
> +else
> +CC = $(CROSS)gcc
> +endif
Why not use clang for FreeBSD modules?
This page seems to encourage clang:
https://wiki.freebsd.org/BuildingFreeBSDWithClang
--
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
2014-07-17 9:35 ` Thomas Monjalon
@ 2014-07-17 10:25 ` Thomas Monjalon
2014-07-17 14:41 ` Richardson, Bruce
2014-07-17 21:47 ` [dpdk-dev] [PATCH v2 " Bruce Richardson
2 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2014-07-17 10:25 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
2014-07-08 00:36, Bruce Richardson:
> Add a special case to the native target makefile, where we check if
> -march=native shows SSE4.2 support. If it does not, then not everything may
> build, so we check if the hardware supports SSE4.2, and use a corei7 target
> explicitly to get the SSE4.2 support.
Now that SSE4.2 support is better detected, can we remove these lines from
defconfig_x86_64-native-bsdapp-gcc?
-#
-# GCC doesn't detect SSE4.x support correctly on BSD, so disable ACL lib
-#
-CONFIG_RTE_LIBRTE_ACL=n
--
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-17 10:25 ` Thomas Monjalon
@ 2014-07-17 14:41 ` Richardson, Bruce
0 siblings, 0 replies; 16+ messages in thread
From: Richardson, Bruce @ 2014-07-17 14:41 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, July 17, 2014 3:26 AM
> To: Richardson, Bruce
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on
> FreeBSD
>
> 2014-07-08 00:36, Bruce Richardson:
> > Add a special case to the native target makefile, where we check if
> > -march=native shows SSE4.2 support. If it does not, then not everything may
> > build, so we check if the hardware supports SSE4.2, and use a corei7 target
> > explicitly to get the SSE4.2 support.
>
> Now that SSE4.2 support is better detected, can we remove these lines from
> defconfig_x86_64-native-bsdapp-gcc?
>
> -#
> -# GCC doesn't detect SSE4.x support correctly on BSD, so disable ACL lib
> -#
> -CONFIG_RTE_LIBRTE_ACL=n
>
> --
Good point, I'll check that out.
/Bruce
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target
2014-07-17 10:23 ` Thomas Monjalon
@ 2014-07-17 17:54 ` Richardson, Bruce
0 siblings, 0 replies; 16+ messages in thread
From: Richardson, Bruce @ 2014-07-17 17:54 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, July 17, 2014 3:23 AM
> To: Richardson, Bruce
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp
> target
>
> 2014-07-08 00:36, Bruce Richardson:
> > --- /dev/null
> > +++ b/mk/toolchain/clang/rte.vars.mk
> [...]
> > +ifeq ($(KERNELRELEASE),)
> > +CC = $(CROSS)clang
> > +else
> > +CC = $(CROSS)gcc
> > +endif
>
> Why not use clang for FreeBSD modules?
> This page seems to encourage clang:
> https://wiki.freebsd.org/BuildingFreeBSDWithClang
>
> --
That is an interesting one.
That branch is only really applicable for Linux. In the BSD modules makefile we explicitly unexport CC to allow the build system to use its own default. BSD 9 defaults to using gcc 4.2, and BSD 10 to clang, so this is probably the best approach, leaving the result in the hands of the user. Obviously this won't work with cross-compiling to BSD, but I don't think that is a scenario we support right now anyway.
/Bruce
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-17 9:35 ` Thomas Monjalon
@ 2014-07-17 21:42 ` Bruce Richardson
0 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-17 21:42 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
On Thu, Jul 17, 2014 at 11:35:46AM +0200, Thomas Monjalon wrote:
> Hi Bruce,
>
> 2014-07-08 00:36, Bruce Richardson:
> > Add a special case to the native target makefile, where we check if
> > -march=native shows SSE4.2 support. If it does not, then not everything may
> > build, so we check if the hardware supports SSE4.2, and use a corei7 target
> > explicitly to get the SSE4.2 support.
> [...]
> > MACHINE_CFLAGS = -march=native
> > +
> > +# on FreeBSD systems, sometimes the correct cputype is not picked up.
> > +# To get everything to compile, we need SSE4.2 support, so check if that is
> > +# reported by compiler. If not, check if the CPU actually supports it, and if
> > +# so, set the compilation target to be a corei7, minimum target with SSE4.2
> > +SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - < /dev/null | grep SSE4_2)
> > +ifeq ($(SSE42_SUPPORT),)
> > + CPU_SSE42_SUPPORT=$(shell if [ -f /var/run/dmesg.boot ] ; then grep SSE4\.2 /var/run/dmesg.boot ; fi)
> > + ifneq ($(CPU_SSE42_SUPPORT),)
> > + MACHINE_CFLAGS= -march=corei7
> > + endif
> > +endif
>
> What do you think of this change?
> - CPU_SSE42_SUPPORT=$(shell if [ -f /var/run/dmesg.boot ] ; then grep SSE4\.2 /var/run/dmesg.boot ; fi)
> + CPU_SSE42_SUPPORT = $(shell grep SSE4\.2 /var/run/dmesg.boot 2>/dev/null)
>
> It's simpler and should produce the same result.
> If you agree, I'll change it before applying.
>
I'm going to do up a second version of this patch to also re-enable the
ACL compile on BSD - as you pointed out in your other mail, so I'll include
this change in a rev 2. That ok?
/Bruce
^ permalink raw reply [flat|nested] 16+ messages in thread
* [dpdk-dev] [PATCH v2 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
2014-07-17 9:35 ` Thomas Monjalon
2014-07-17 10:25 ` Thomas Monjalon
@ 2014-07-17 21:47 ` Bruce Richardson
2 siblings, 0 replies; 16+ messages in thread
From: Bruce Richardson @ 2014-07-17 21:47 UTC (permalink / raw)
To: dev
Add a special case to the native target makefile, where we check if
-march=native shows SSE4.2 support. If it does not, then not everything may
build, so we check if the hardware supports SSE4.2, and use a corei7 target
explicitly to get the SSE4.2 support.
New in V2:
* Re-enable ACL library for FreeBSD using gcc, which requires SSE4.2
* Adjust SSE42 detection command based on feedback from Thomas Monjalon
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
config/defconfig_x86_64-native-bsdapp-gcc | 5 -----
mk/machine/native/rte.vars.mk | 12 ++++++++++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/config/defconfig_x86_64-native-bsdapp-gcc b/config/defconfig_x86_64-native-bsdapp-gcc
index 2234193..e91738b 100644
--- a/config/defconfig_x86_64-native-bsdapp-gcc
+++ b/config/defconfig_x86_64-native-bsdapp-gcc
@@ -69,8 +69,3 @@ CONFIG_RTE_ARCH_X86_64=y
#
CONFIG_RTE_TOOLCHAIN="gcc"
CONFIG_RTE_TOOLCHAIN_GCC=y
-
-#
-# GCC doesn't detect SSE4.x support correctly on BSD, so disable ACL lib
-#
-CONFIG_RTE_LIBRTE_ACL=n
diff --git a/mk/machine/native/rte.vars.mk b/mk/machine/native/rte.vars.mk
index da9aa71..baabb39 100644
--- a/mk/machine/native/rte.vars.mk
+++ b/mk/machine/native/rte.vars.mk
@@ -56,3 +56,15 @@
# CPU_ASFLAGS =
MACHINE_CFLAGS = -march=native
+
+# on FreeBSD systems, sometimes the correct cputype is not picked up.
+# To get everything to compile, we need SSE4.2 support, so check if that is
+# reported by compiler. If not, check if the CPU actually supports it, and if
+# so, set the compilation target to be a corei7, minimum target with SSE4.2
+SSE42_SUPPORT=$(shell $(CC) -march=native -dM -E - < /dev/null | grep SSE4_2)
+ifeq ($(SSE42_SUPPORT),)
+ CPU_SSE42_SUPPORT=$(shell grep SSE4\.2 /var/run/dmesg.boot 2>/dev/null)
+ ifneq ($(CPU_SSE42_SUPPORT),)
+ MACHINE_CFLAGS= -march=corei7
+ endif
+endif
--
2.0.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
` (6 preceding siblings ...)
2014-07-11 5:31 ` [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Zhan, Zhaochen
@ 2014-07-18 23:58 ` Thomas Monjalon
7 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2014-07-18 23:58 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
2014-07-08 00:36, Bruce Richardson:
> This patch set enables clang compilation on FreeBSD and Linux. It includes
> patches to fix a number of compilation errors thrown up by clang, and then
> adds in the appropriate toolchain makefiles and compile-time configurations.
>
> This set has been tested with clang v3.3 on FreeBSD 10 and clang v3.4 on
> Fedora linux 20. The example apps folder has not been tested at this time, this
> patch set only focuses on the core libraries and apps.
>
> Bruce Richardson (6):
> pmd_bond: add missing variable initialization
> Makefiles: add clang to compiler if/else block
> mk: Ensure correct detection of SSE4.2 on FreeBSD
> acl: add nmmintrin.h header to allow clang compilation
> mk: add toolchain for clang and linuxapp target
> config: add compile target for clang on BSD
Tested-by: Zhaochen Zhan <zhaochen.zhan@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Applied with some cleanups for version 1.7.1
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-07-18 23:57 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 23:36 [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 1/6] pmd_bond: add missing variable initialization Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 2/6] Makefiles: add clang to compiler if/else block Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 3/6] mk: Ensure correct detection of SSE4.2 on FreeBSD Bruce Richardson
2014-07-17 9:35 ` Thomas Monjalon
2014-07-17 21:42 ` Bruce Richardson
2014-07-17 10:25 ` Thomas Monjalon
2014-07-17 14:41 ` Richardson, Bruce
2014-07-17 21:47 ` [dpdk-dev] [PATCH v2 " Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 4/6] acl: add nmmintrin.h header to allow clang compilation Bruce Richardson
2014-07-07 23:36 ` [dpdk-dev] [PATCH 5/6] mk: add toolchain for clang and linuxapp target Bruce Richardson
2014-07-17 10:23 ` Thomas Monjalon
2014-07-17 17:54 ` Richardson, Bruce
2014-07-07 23:36 ` [dpdk-dev] [PATCH 6/6] config: add compile target for clang on BSD Bruce Richardson
2014-07-11 5:31 ` [dpdk-dev] [PATCH 0/6] Clang compilation support on FreeBSD and Linux Zhan, Zhaochen
2014-07-18 23:58 ` 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).