[1/7] linuxapp: build with _GNU_SOURCE defined by default
Checks
Commit Message
We use _GNU_SOURCE all over the place, but often times we miss
defining it, resulting in broken builds on musl. Rather than
fixing every library's and driver's and application's makefile,
fix it by simply defining _GNU_SOURCE by default for all
Linuxapp builds.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
app/meson.build | 9 ++++++++-
drivers/bus/pci/linux/Makefile | 2 --
drivers/meson.build | 6 ++++++
drivers/net/softnic/conn.c | 1 -
examples/meson.build | 6 ++++++
lib/librte_eal/linuxapp/eal/Makefile | 16 ----------------
lib/meson.build | 6 ++++++
mk/exec-env/linuxapp/rte.vars.mk | 2 ++
test/test/meson.build | 5 +++++
9 files changed, 33 insertions(+), 20 deletions(-)
@@ -11,13 +11,20 @@ apps = ['pdump',
# for BSD only
lib_execinfo = cc.find_library('execinfo', required: false)
+default_cflags = machine_args
+
+# on Linux, specify -D_GNU_SOURCE unconditionally
+if host_machine.system() == 'linux'
+ default_cflags += '-D_GNU_SOURCE'
+endif
+
foreach app:apps
build = true
name = app
allow_experimental_apis = false
sources = []
includes = []
- cflags = machine_args
+ cflags = default_cflags
objs = [] # other object files to link against, used e.g. for
# instruction-set optimized versions of code
@@ -4,5 +4,3 @@
SRCS += pci.c
SRCS += pci_uio.c
SRCS += pci_vfio.c
-
-CFLAGS += -D_GNU_SOURCE
@@ -15,6 +15,12 @@ default_cflags = machine_args
if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
+
+# on Linux, specify -D_GNU_SOURCE unconditionally
+if host_machine.system() == 'linux'
+ default_cflags += '-D_GNU_SOURCE'
+endif
+
foreach class:driver_classes
drivers = []
std_deps = []
@@ -8,7 +8,6 @@
#include <unistd.h>
#include <sys/types.h>
-#define __USE_GNU
#include <sys/socket.h>
#include <sys/epoll.h>
@@ -22,6 +22,12 @@ default_cflags = machine_args
if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
+
+# on Linux, specify -D_GNU_SOURCE unconditionally
+if host_machine.system() == 'linux'
+ default_cflags += '-D_GNU_SOURCE'
+endif
+
foreach example: examples
name = example
build = true
@@ -85,22 +85,6 @@ SRCS-y += rte_cycles.c
CFLAGS_eal_common_cpuflags.o := $(CPUFLAGS_LIST)
-CFLAGS_eal.o := -D_GNU_SOURCE
-CFLAGS_eal_interrupts.o := -D_GNU_SOURCE
-CFLAGS_eal_vfio_mp_sync.o := -D_GNU_SOURCE
-CFLAGS_eal_timer.o := -D_GNU_SOURCE
-CFLAGS_eal_lcore.o := -D_GNU_SOURCE
-CFLAGS_eal_memalloc.o := -D_GNU_SOURCE
-CFLAGS_eal_thread.o := -D_GNU_SOURCE
-CFLAGS_eal_log.o := -D_GNU_SOURCE
-CFLAGS_eal_common_log.o := -D_GNU_SOURCE
-CFLAGS_eal_hugepage_info.o := -D_GNU_SOURCE
-CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE
-CFLAGS_eal_common_options.o := -D_GNU_SOURCE
-CFLAGS_eal_common_thread.o := -D_GNU_SOURCE
-CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE
-CFLAGS_rte_cycles.o := -D_GNU_SOURCE
-
# workaround for a gcc bug with noreturn attribute
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
@@ -30,6 +30,12 @@ default_cflags = machine_args
if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
+
+# on Linux, specify -D_GNU_SOURCE unconditionally
+if host_machine.system() == 'linux'
+ default_cflags += '-D_GNU_SOURCE'
+endif
+
foreach l:libraries
build = true
name = l
@@ -17,6 +17,8 @@ else
EXECENV_CFLAGS = -pthread
endif
+EXECENV_CFLAGS += -D_GNU_SOURCE
+
EXECENV_LDLIBS =
EXECENV_ASFLAGS =
@@ -242,6 +242,11 @@ if cc.has_argument('-Wno-format-truncation')
cflags += '-Wno-format-truncation'
endif
+# on Linux, specify -D_GNU_SOURCE unconditionally
+if host_machine.system() == 'linux'
+ default_cflags += '-D_GNU_SOURCE'
+endif
+
test_dep_objs = []
compress_test_dep = dependency('zlib', required: false)
if compress_test_dep.found()