From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Thomas Monjalon <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH v2 5/7] build: MinGW-w64 support for Meson
Date: Thu, 6 Feb 2020 09:44:24 +0300 [thread overview]
Message-ID: <20200206064426.45697-6-dmitry.kozliuk@gmail.com> (raw)
In-Reply-To: <20200206064426.45697-1-dmitry.kozliuk@gmail.com>
MinGW-w64 linker does not mimic MS linker options, so the build system
must differentiate between linkers on Windows. Use GNU linker options
with GCC and MS linker options with Clang.
MinGW-w64 by default uses MSVCRT stdio, which does not comply to ANSI,
most notably its formatting and string handling functions. MinGW-w64
support for the Universal CRT (UCRT) is ongoing, but the toolchain
provides its own standard-complying implementation of stdio. The latter
is used in the patch to support formatting in DPDK.
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
config/meson.build | 14 ++++++++++++++
lib/librte_eal/meson.build | 3 +++
lib/meson.build | 8 ++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/config/meson.build b/config/meson.build
index 28a57f56f..9b955f9ef 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,10 @@ foreach env:supported_exec_envs
set_variable('is_' + env, exec_env == env)
endforeach
+# MS linker requires special treatment.
+# FIXME: use cc.get_linker_id() with Meson >= 0.54
+is_ms_linker = is_windows and (cc.get_id() == 'clang')
+
# set the major version, which might be used by drivers and libraries
# depending on the configuration options
pver = meson.project_version().split('.')
@@ -241,6 +245,16 @@ if is_freebsd
add_project_arguments('-D__BSD_VISIBLE', language: 'c')
endif
+if is_windows
+ # Minimum supported API is Windows 7.
+ add_project_arguments('-D_WIN32_WINNT=0x0601', language: 'c')
+
+ # Use MinGW-w64 stdio, because DPDK assumes ANSI-compliant formatting.
+ if cc.get_id() == 'gcc'
+ add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c')
+ endif
+endif
+
if get_option('b_lto')
if cc.has_argument('-ffat-lto-objects')
add_project_arguments('-ffat-lto-objects', language: 'c')
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 4be5118ce..eae8c2ba8 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -20,6 +20,9 @@ endif
if cc.has_function('getentropy', prefix : '#include <unistd.h>')
cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
endif
+if cc.get_id() == 'gcc'
+ cflags += '-D__USE_MINGW_ANSI_STDIO'
+endif
sources = common_sources + env_sources
objs = common_objs + env_objs
headers = common_headers + env_headers
diff --git a/lib/meson.build b/lib/meson.build
index 0af3efab2..9c3cc55d5 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -148,12 +148,16 @@ foreach l:libraries
command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'],
input: version_map,
output: 'rte_@0@_exports.def'.format(name))
- lk_deps = [version_map, def_file]
- if is_windows
+
+ if is_ms_linker
lk_args = ['-Wl,/def:' + def_file.full_path(),
'-Wl,/implib:lib\\' + implib]
else
lk_args = ['-Wl,--version-script=' + version_map]
+ endif
+
+ lk_deps = [version_map, def_file]
+ if not is_windows
# on unix systems check the output of the
# experimental syms script, using it as a
# dependency of the .so build
--
2.25.0
next prev parent reply other threads:[~2020-02-06 6:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-06 6:44 [dpdk-dev] [PATCH v2 0/7] MinGW-w64 support Dmitry Kozlyuk
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 1/7] eal: introduce portable format attribute Dmitry Kozlyuk
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 2/7] eal: use " Dmitry Kozlyuk
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 3/7] cmdline: " Dmitry Kozlyuk
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 4/7] eal/windows: use lowercase filenames for system headers Dmitry Kozlyuk
2020-02-06 6:44 ` Dmitry Kozlyuk [this message]
2020-02-06 11:38 ` [dpdk-dev] [PATCH v2 5/7] build: MinGW-w64 support for Meson Bruce Richardson
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 6/7] build: add cross-file for MinGW-w64 Dmitry Kozlyuk
2020-02-06 6:44 ` [dpdk-dev] [PATCH v2 7/7] doc: guide for Windows build using MinGW-w64 Dmitry Kozlyuk
2020-02-06 20:22 ` [dpdk-dev] [PATCH v2 0/7] MinGW-w64 support William Tu
2020-02-07 10:24 ` Dmitry Kozliuk
2020-02-07 17:47 ` William Tu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200206064426.45697-6-dmitry.kozliuk@gmail.com \
--to=dmitry.kozliuk@gmail.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).