[v3,4/7] build: MinGW-w64 support for Meson
Checks
Commit Message
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/meson.build | 8 ++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
Comments
18/02/2020 01:02, Dmitry Kozlyuk:
> --- a/config/meson.build
> +++ b/config/meson.build
> +# 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')
Please could you replace this FIXME with an actual fix in meson.build?
On Tue, Feb 18, 2020 at 03:26:47PM +0100, Thomas Monjalon wrote:
> 18/02/2020 01:02, Dmitry Kozlyuk:
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > +# 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')
>
> Please could you replace this FIXME with an actual fix in meson.build?
>
Best not to at this point, as even with an explicit version check for the
new function, you can still get a warning from meson about using functions
from versions greater than baseline. In this release we have removed most,
if not all, existing warnings and I'd rather not add any back in.
Suggest replacing the fixme with a NOTE or TODO, since it's not a bug that
needs to be fixed, rather a future enhancement once we update our meson
baseline.
/Bruce
@@ -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('.')
@@ -247,6 +251,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')
@@ -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