From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7596A0524; Fri, 31 Jan 2020 04:08:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F31C1C0AF; Fri, 31 Jan 2020 04:08:02 +0100 (CET) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id A8EC31C0B0 for ; Fri, 31 Jan 2020 04:07:55 +0100 (CET) Received: by mail-lj1-f194.google.com with SMTP id o15so58790ljg.6 for ; Thu, 30 Jan 2020 19:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lqfbabfrWSJAOsLi7d8Doq9bLNlFJak8eOTz/WMgvOU=; b=BZCWYcqx2FIBRWZtSCEbRVdJDJKH089gOTDScTCZfVijNvKK1CUXs9F0aapaLHF/Q5 7wrKU974YhAo9/40cEs/XMDhqM9Jij0W2zN/EmUnCcjPg3w907ipMRjuIha6BBMDfbie C8MYy9Ds0/+rllCT7DdaFQXuf+8wdXPlWgROZ5FtkC+QD9blTsf6GjqbNko94IHk8j1a VcYocNcu3+WiwXXr7l6xyU62zyGhlNpMg2szytnDAxMRNC2NtZqy7AK/GlLvAoNuX92e x96fwYCMEvcVyOMql8Ay/pi3FjEsdDQu2sL/qgVA+LU5j3YJ+PGsWDVh1lYY3u8rpdGq xZ2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lqfbabfrWSJAOsLi7d8Doq9bLNlFJak8eOTz/WMgvOU=; b=l9Rfw01MHF6vAFpOw2SL4GgOSAlmmHIGOUuxSUoFWtwoGhWFXbQDl3rE/kxLlRqD+O 4YqdJD7PsUMM7BQ/lf8tqZDD3H8LR//8mJyFWrVO+S+lohK2R3tFnNy+GEBhI+MmuV7U 7LrVQB59MDq+MkFX7x8mrpszKmapr0TzJJGlHrcvLdkFGGswVCXDvAbUr2o2Wq7DqcJC 9SHM9L46BxqlA1HO0oVkHL1QvfUFsnA7Efd5Y+C5m+utn2dpmcXvIsPVUEyzw+7RBMIv IB5HzTDGgNIJ5OUZA0DrC0hy4O5uAlWcJ3yYN/I0lXaKTKAeboI0rx11Cc6QglmmDrIp iSkA== X-Gm-Message-State: APjAAAWAODNwpgvgJKdDMoRikGZm5RnEm3sHjt0itaUjxYHC0GDEjDn2 a5kvve7l0lN/wEajiMBIlwDfXrrPGjU3Kg== X-Google-Smtp-Source: APXvYqy1wHDFbwJ0nS9NmiRRwjEKQCfy2n30IlYw21UHKIpHm9qcfFwXCIGv8TqWXo9N+Rs66NKrGw== X-Received: by 2002:a2e:1459:: with SMTP id 25mr4777782lju.189.1580440074963; Thu, 30 Jan 2020 19:07:54 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:54 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Bruce Richardson , Thomas Monjalon Date: Fri, 31 Jan 2020 06:07:42 +0300 Message-Id: <20200131030744.19596-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 4/6] build: MinGW-w64 support for Meson X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 diff --git a/config/meson.build b/config/meson.build index 28a57f56f..a2f6f5ab1 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() after upgrading to Meson >=0.53. +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 + # Require platform SDK for Windows 7 and above. + 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 ') 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