Skip to contentSkip to conversation

Fix meson build on FreeBSD

PATCH Superseded Bruce Richardson 2 participants 15 messages Jan 31, 2018 – Feb 2, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Fix meson build on FreeBSD

There are a few issues with building DPDK for FreeBSD using the meson build system, specifically:
* the kernel modules aren't compiling due to an incorrect VPATH
* a number of unit tests depend on libraries not supported on BSD
* applications and examples need to be linked with execinfo library.

Bruce Richardson (6):
eal/bsdapp: fix building kernel modules
build: add dependency on execinfo for BSD meson builds test/test: mark tests as skipped when required lib not available test/test: fix dependency on power lib for BSD meson build test/test: fix dependency on KNI lib for BSD meson build
examples: fix meson build on FreeBSD

 app/test-eventdev/meson.build           |  1 +
 app/test-pmd/meson.build                |  1 +
 examples/meson.build                    |  3 ++-
 lib/librte_eal/bsdapp/BSDmakefile.meson |  1 +
 lib/librte_eal/meson.build              |  1 -
 test/test/meson.build                   |  8 +++++++-
 test/test/test_kni.c                    | 13 +++++++++++++
 test/test/test_power.c                  | 12 ++++++++++++
 test/test/test_power_acpi_cpufreq.c     | 11 +++++++++++
 test/test/test_power_kvm_vm.c           | 11 +++++++++++
 10 files changed, 59 insertions(+), 3 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/6 eal/bsdapp: fix building kernel modules

The kernel module source file directory passed via VPATH was wrong, which caused the source files to be not found via make. Rather than explicitly passing VPATH, make use of the fact that the full path to the source files is passed by meson, so split that into directory part - to be used as VPATH - and file part - to be used as the source filename.

Fixes 610beca42ea4 ("build: remove library special cases")
---
 lib/librte_eal/bsdapp/BSDmakefile.meson | 1 +
 lib/librte_eal/meson.build              | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/BSDmakefile.meson +1 -0
index 2f16ac05b..42f5b2b9d 100644
@@ -36,6 +36,7 @@
 # source file is passed via KMOD_SRC as full path, we only use final
 # component of it, as VPATH is used to find actual file, so as to
 # have the .o files placed in the build, not source directory
+VPATH = ${KMOD_SRC:H}
 SRCS = ${KMOD_SRC:T} device_if.h bus_if.h pci_if.h
 CFLAGS += $(KMOD_CFLAGS)
 
lib/librte_eal/meson.build +0 -1
index 6fb2ef17f..d9ba38533 100644
@@ -36,7 +36,6 @@ elif host_machine.system() == 'freebsd'
 			command: ['make', '-f', '@INPUT0@',
 				'KMOD_SRC=@INPUT1@',
 				'KMOD=' + k,
-				'VPATH=' + join_paths(meson.current_source_dir(), k),
 				'KMOD_CFLAGS=' + ' '.join(kmod_cflags)],
 			build_by_default: get_option('enable_kmods'))
 	endforeach
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/6 build: add dependency on execinfo for BSD meson builds

In reply to Bruce Richardson

The binaries and apps in DPDK all need to be linked against the execinfo library on FreeBSD so add this as a dependency in cases where it is found. It's available by default on BSD, but not at all on Linux

---
 app/test-eventdev/meson.build | 1 +
 app/test-pmd/meson.build      | 1 +
 test/test/meson.build         | 1 +
 3 files changed, 3 insertions(+)
app/test-eventdev/meson.build +1 -0
index 7fb3a280a..7c373c87b 100644
@@ -13,6 +13,7 @@ sources = files('evt_main.c',
 		'test_perf_queue.c')
 
 dep_objs = [get_variable(get_option('default_library') + '_rte_eventdev')]
+dep_objs += cc.find_library('execinfo', required: false) # BSD only
 
 link_libs = []
 if get_option('default_library') == 'static'
app/test-pmd/meson.build +1 -0
index 9964dae75..7ed74db2b 100644
@@ -37,6 +37,7 @@ dep_objs = []
 foreach d:deps
 	dep_objs += get_variable(get_option('default_library') + '_rte_' + d)
 endforeach
+dep_objs += cc.find_library('execinfo', required: false) # for BSD only
 
 link_libs = []
 if get_option('default_library') == 'static'
test/test/meson.build +1 -0
index d5b768b9d..2457a2adb 100644
@@ -234,6 +234,7 @@ foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
+test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
Signature · 1 line
2.14.1
#3 lore raw

PATCH 3/6 test/test: mark tests as skipped when required lib not available

In reply to Bruce Richardson

The power management and KNI libraries are not compiled on a FreeBSD platform, which means that the tests can't run. Add in stub code for these cases, allowing the tests to still be compiled, but to report as skipped in those cases.

---
 test/test/test_kni.c                | 13 +++++++++++++
 test/test/test_power.c              | 12 ++++++++++++
 test/test/test_power_acpi_cpufreq.c | 11 +++++++++++
 test/test/test_power_kvm_vm.c       | 11 +++++++++++
 4 files changed, 47 insertions(+)
test/test/test_kni.c +13 -0
index 539d23184..c669785ae 100644
@@ -10,6 +10,17 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_KNI
+
+static int
+test_kni(void)
+{
+	printf("KNI not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_string_fns.h>
 #include <rte_mempool.h>
 #include <rte_ethdev.h>
@@ -605,4 +616,6 @@ test_kni(void)
 	return ret;
 }
 
+#endif
+
 REGISTER_TEST_COMMAND(kni_autotest, test_kni);
test/test/test_power.c +12 -0
index d601a2730..a0ee21983 100644
@@ -10,6 +10,17 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_power.h>
 
 static int
@@ -74,5 +85,6 @@ test_power(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_autotest, test_power);
test/test/test_power_acpi_cpufreq.c +11 -0
index ad948fbe1..3bfd03351 100644
@@ -10,6 +10,16 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power_acpi_cpufreq(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
 #include <rte_power.h>
 
 #define TEST_POWER_LCORE_ID      2U
@@ -507,5 +517,6 @@ test_power_acpi_cpufreq(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_acpi_cpufreq_autotest, test_power_acpi_cpufreq);
test/test/test_power_kvm_vm.c +11 -0
index 97b8af9b5..91b31c442 100644
@@ -10,6 +10,16 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power_kvm_vm(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
 #include <rte_power.h>
 
 #define TEST_POWER_VM_LCORE_ID            0U
@@ -270,5 +280,6 @@ test_power_kvm_vm(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_kvm_vm_autotest, test_power_kvm_vm);
Signature · 1 line
2.14.1
#4 lore raw

Re: [PATCH 3/6] test/test: mark tests as skipped when required lib not available

Hi Bruce,

Quoted 8 lines · Bruce Richardson

The power management and KNI libraries are not compiled on a FreeBSD platform, which means that the tests can't run. Add in stub code for these cases, allowing the tests to still be compiled, but to report as skipped in those cases.

Quoted 6 lines
---
  test/test/test_kni.c                | 13 +++++++++++++
  test/test/test_power.c              | 12 ++++++++++++
  test/test/test_power_acpi_cpufreq.c | 11 +++++++++++
  test/test/test_power_kvm_vm.c       | 11 +++++++++++
  4 files changed, 47 insertions(+)

--snip--

Acked-by David Hunt <[email protected]>

#5 lore raw

PATCH 4/6 test/test: fix dependency on power lib for BSD meson build

In reply to Bruce Richardson

The power library is not built on FreeBSD, so it needs to be an optional rather than a mandatory dependency for building the autotest binary.

Fixes b5dc795a8a55 ("test: build app with meson as dpdk-test")
---
 test/test/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
test/test/meson.build +3 -1
index 2457a2adb..e8ddb76e3 100644
@@ -111,7 +111,6 @@ test_deps = ['acl',
 	'member',
 	'pipeline',
 	'port',
-	'power',
 	'reorder',
 	'ring',
 	'timer'
@@ -228,6 +227,9 @@ endif
 if dpdk_conf.has('RTE_LIBRTE_RING_PMD')
 	test_deps += 'pmd_ring'
 endif
+if dpdk_conf.has('RTE_LIBRTE_POWER')
+	test_deps += 'power'
+endif
 
 test_dep_objs = []
 foreach d:test_deps
Signature · 1 line
2.14.1
#6 lore raw

PATCH 5/6 test/test: fix dependency on KNI lib for BSD meson build

In reply to Bruce Richardson

The KNI library is not built on FreeBSD, so it needs to be an optional rather than a mandatory dependency for building the autotest binary.

Fixes b5dc795a8a55 ("test: build app with meson as dpdk-test")
---
 test/test/meson.build | 3 +++
 1 file changed, 3 insertions(+)
test/test/meson.build +3 -0
index e8ddb76e3..eb3d87a4d 100644
@@ -230,6 +230,9 @@ endif
 if dpdk_conf.has('RTE_LIBRTE_POWER')
 	test_deps += 'power'
 endif
+if dpdk_conf.has('RTE_LIBRTE_KNI')
+	test_deps += 'kni'
+endif
 
 test_dep_objs = []
 foreach d:test_deps
Signature · 1 line
2.14.1
#7 lore raw

PATCH 6/6 examples: fix meson build on FreeBSD

In reply to Bruce Richardson
Fixes 89f0711f9ddf ("examples: build some samples with meson")
---
 examples/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
examples/meson.build +2 -1
index 5658fbe04..2c6b3f889 100644
@@ -6,12 +6,13 @@ if get_option('default_library') == 'static'
 	driver_libs = dpdk_drivers
 endif
 
+execinfo = cc.find_library('execinfo', required: false)
 foreach example: get_option('examples').split(',')
 	name = example
 	sources = []
 	allow_experimental_apis = false
 	cflags = machine_args
-	ext_deps = []
+	ext_deps = [execinfo]
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)
Signature · 1 line
2.14.1
#8 lore raw

v2 cover Fix meson build on FreeBSD

In reply to Bruce Richardson

There are a few issues with building DPDK for FreeBSD using the meson build system, specifically:
* the kernel modules aren't compiling due to an incorrect VPATH
* a number of unit tests depend on libraries not supported on BSD
* applications and examples need to be linked with execinfo library.

----
V2: merged patch 6 in with patch 2, since it's the same fix for main apps
and for the examples.

Bruce Richardson (5):
eal/bsdapp: fix building kernel modules
build: fix dependency on execinfo for BSD meson builds test/test: mark tests as skipped when required lib not available test/test: fix dependency on power lib for BSD meson build test/test: fix dependency on KNI lib for BSD meson build

 app/test-eventdev/meson.build           |  1 +
 app/test-pmd/meson.build                |  1 +
 examples/meson.build                    |  3 ++-
 lib/librte_eal/bsdapp/BSDmakefile.meson |  1 +
 lib/librte_eal/meson.build              |  1 -
 test/test/meson.build                   |  8 +++++++-
 test/test/test_kni.c                    | 13 +++++++++++++
 test/test/test_power.c                  | 12 ++++++++++++
 test/test/test_power_acpi_cpufreq.c     | 11 +++++++++++
 test/test/test_power_kvm_vm.c           | 11 +++++++++++
 10 files changed, 59 insertions(+), 3 deletions(-)
Signature · 1 line
2.14.1
#9 lore raw

PATCH v2 1/5 eal/bsdapp: fix building kernel modules

The kernel module source file directory passed via VPATH was wrong, which caused the source files to be not found via make. Rather than explicitly passing VPATH, make use of the fact that the full path to the source files is passed by meson, so split that into directory part - to be used as VPATH - and file part - to be used as the source filename.

Fixes 610beca42ea4 ("build: remove library special cases")
---
 lib/librte_eal/bsdapp/BSDmakefile.meson | 1 +
 lib/librte_eal/meson.build              | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/BSDmakefile.meson +1 -0
index 2f16ac05b..42f5b2b9d 100644
@@ -36,6 +36,7 @@
 # source file is passed via KMOD_SRC as full path, we only use final
 # component of it, as VPATH is used to find actual file, so as to
 # have the .o files placed in the build, not source directory
+VPATH = ${KMOD_SRC:H}
 SRCS = ${KMOD_SRC:T} device_if.h bus_if.h pci_if.h
 CFLAGS += $(KMOD_CFLAGS)
 
lib/librte_eal/meson.build +0 -1
index 6fb2ef17f..d9ba38533 100644
@@ -36,7 +36,6 @@ elif host_machine.system() == 'freebsd'
 			command: ['make', '-f', '@INPUT0@',
 				'KMOD_SRC=@INPUT1@',
 				'KMOD=' + k,
-				'VPATH=' + join_paths(meson.current_source_dir(), k),
 				'KMOD_CFLAGS=' + ' '.join(kmod_cflags)],
 			build_by_default: get_option('enable_kmods'))
 	endforeach
Signature · 1 line
2.14.1
#10 lore raw

PATCH v2 2/5 build: fix dependency on execinfo for BSD meson builds

In reply to Bruce Richardson

The binaries and apps in DPDK all need to be linked against the execinfo library on FreeBSD so add this as a dependency in cases where it is found. It's available by default on BSD, but not at all on Linux

Fixes 16ade738fd0d ("app/testpmd: build with meson")
Fixes 89f0711f9ddf ("examples: build some samples with meson")
Fixes b5dc795a8a55 ("test: build app with meson as dpdk-test")
Fixes 2ff67267b049 ("app/eventdev: build with meson")
---
 app/test-eventdev/meson.build | 1 +
 app/test-pmd/meson.build      | 1 +
 examples/meson.build          | 3 ++-
 test/test/meson.build         | 1 +
 4 files changed, 5 insertions(+), 1 deletion(-)
app/test-eventdev/meson.build +1 -0
index 7fb3a280a..7c373c87b 100644
@@ -13,6 +13,7 @@ sources = files('evt_main.c',
 		'test_perf_queue.c')
 
 dep_objs = [get_variable(get_option('default_library') + '_rte_eventdev')]
+dep_objs += cc.find_library('execinfo', required: false) # BSD only
 
 link_libs = []
 if get_option('default_library') == 'static'
app/test-pmd/meson.build +1 -0
index 9964dae75..7ed74db2b 100644
@@ -37,6 +37,7 @@ dep_objs = []
 foreach d:deps
 	dep_objs += get_variable(get_option('default_library') + '_rte_' + d)
 endforeach
+dep_objs += cc.find_library('execinfo', required: false) # for BSD only
 
 link_libs = []
 if get_option('default_library') == 'static'
examples/meson.build +2 -1
index 5658fbe04..2c6b3f889 100644
@@ -6,12 +6,13 @@ if get_option('default_library') == 'static'
 	driver_libs = dpdk_drivers
 endif
 
+execinfo = cc.find_library('execinfo', required: false)
 foreach example: get_option('examples').split(',')
 	name = example
 	sources = []
 	allow_experimental_apis = false
 	cflags = machine_args
-	ext_deps = []
+	ext_deps = [execinfo]
 	includes = [include_directories(example)]
 	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
 	subdir(example)
test/test/meson.build +1 -0
index d5b768b9d..2457a2adb 100644
@@ -234,6 +234,7 @@ foreach d:test_deps
 	def_lib = get_option('default_library')
 	test_dep_objs += get_variable(def_lib + '_rte_' + d)
 endforeach
+test_dep_objs += cc.find_library('execinfo', required: false)
 
 link_libs = []
 if get_option('default_library') == 'static'
Signature · 1 line
2.14.1
#11 lore raw

PATCH v2 3/5 test/test: mark tests as skipped when required lib not available

In reply to Bruce Richardson

The power management and KNI libraries are not compiled on a FreeBSD platform, which means that the tests can't run. Add in stub code for these cases, allowing the tests to still be compiled, but to report as skipped in those cases.

---
 test/test/test_kni.c                | 13 +++++++++++++
 test/test/test_power.c              | 12 ++++++++++++
 test/test/test_power_acpi_cpufreq.c | 11 +++++++++++
 test/test/test_power_kvm_vm.c       | 11 +++++++++++
 4 files changed, 47 insertions(+)
test/test/test_kni.c +13 -0
index c6867f256..e4839cdb7 100644
@@ -10,6 +10,17 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_KNI
+
+static int
+test_kni(void)
+{
+	printf("KNI not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_string_fns.h>
 #include <rte_mempool.h>
 #include <rte_ethdev.h>
@@ -609,4 +620,6 @@ test_kni(void)
 	return ret;
 }
 
+#endif
+
 REGISTER_TEST_COMMAND(kni_autotest, test_kni);
test/test/test_power.c +12 -0
index d601a2730..a0ee21983 100644
@@ -10,6 +10,17 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_power.h>
 
 static int
@@ -74,5 +85,6 @@ test_power(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_autotest, test_power);
test/test/test_power_acpi_cpufreq.c +11 -0
index ad948fbe1..3bfd03351 100644
@@ -10,6 +10,16 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power_acpi_cpufreq(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
 #include <rte_power.h>
 
 #define TEST_POWER_LCORE_ID      2U
@@ -507,5 +517,6 @@ test_power_acpi_cpufreq(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_acpi_cpufreq_autotest, test_power_acpi_cpufreq);
test/test/test_power_kvm_vm.c +11 -0
index 97b8af9b5..91b31c442 100644
@@ -10,6 +10,16 @@
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power_kvm_vm(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
 #include <rte_power.h>
 
 #define TEST_POWER_VM_LCORE_ID            0U
@@ -270,5 +280,6 @@ test_power_kvm_vm(void)
 	rte_power_unset_env();
 	return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_kvm_vm_autotest, test_power_kvm_vm);
Signature · 1 line
2.14.1
#12 lore raw

PATCH v2 4/5 test/test: fix dependency on power lib for BSD meson build

In reply to Bruce Richardson

The power library is not built on FreeBSD, so it needs to be an optional rather than a mandatory dependency for building the autotest binary.

Fixes b5dc795a8a55 ("test: build app with meson as dpdk-test")
---
 test/test/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
test/test/meson.build +3 -1
index 2457a2adb..e8ddb76e3 100644
@@ -111,7 +111,6 @@ test_deps = ['acl',
 	'member',
 	'pipeline',
 	'port',
-	'power',
 	'reorder',
 	'ring',
 	'timer'
@@ -228,6 +227,9 @@ endif
 if dpdk_conf.has('RTE_LIBRTE_RING_PMD')
 	test_deps += 'pmd_ring'
 endif
+if dpdk_conf.has('RTE_LIBRTE_POWER')
+	test_deps += 'power'
+endif
 
 test_dep_objs = []
 foreach d:test_deps
Signature · 1 line
2.14.1
#13 lore raw

PATCH v2 5/5 test/test: fix dependency on KNI lib for BSD meson build

In reply to Bruce Richardson

The KNI library is not built on FreeBSD, so it needs to be an optional rather than a mandatory dependency for building the autotest binary.

Fixes b5dc795a8a55 ("test: build app with meson as dpdk-test")
---
 test/test/meson.build | 3 +++
 1 file changed, 3 insertions(+)
test/test/meson.build +3 -0
index e8ddb76e3..eb3d87a4d 100644
@@ -230,6 +230,9 @@ endif
 if dpdk_conf.has('RTE_LIBRTE_POWER')
 	test_deps += 'power'
 endif
+if dpdk_conf.has('RTE_LIBRTE_KNI')
+	test_deps += 'kni'
+endif
 
 test_dep_objs = []
 foreach d:test_deps
Signature · 1 line
2.14.1
#14 lore raw
In reply to Bruce Richardson
Quoted 17 lines · Bruce Richardson

There are a few issues with building DPDK for FreeBSD using the meson build system, specifically:
* the kernel modules aren't compiling due to an incorrect VPATH
* a number of unit tests depend on libraries not supported on BSD
* applications and examples need to be linked with execinfo library.

----
V2: merged patch 6 in with patch 2, since it's the same fix for main apps
and for the examples.

Bruce Richardson (5):
eal/bsdapp: fix building kernel modules
build: fix dependency on execinfo for BSD meson builds test/test: mark tests as skipped when required lib not available test/test: fix dependency on power lib for BSD meson build test/test: fix dependency on KNI lib for BSD meson build

Quoted 13 lines
 app/test-eventdev/meson.build           |  1 +
 app/test-pmd/meson.build                |  1 +
 examples/meson.build                    |  3 ++-
 lib/librte_eal/bsdapp/BSDmakefile.meson |  1 +
 lib/librte_eal/meson.build              |  1 -
 test/test/meson.build                   |  8 +++++++-
 test/test/test_kni.c                    | 13 +++++++++++++
 test/test/test_power.c                  | 12 ++++++++++++
 test/test/test_power_acpi_cpufreq.c     | 11 +++++++++++
 test/test/test_power_kvm_vm.c           | 11 +++++++++++
 10 files changed, 59 insertions(+), 3 deletions(-)

Applied to dpdk-next-build

/Bruce