From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A9155429D8; Tue, 25 Apr 2023 22:08:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB44342B8E; Tue, 25 Apr 2023 22:08:52 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id CED6A40ED6 for ; Tue, 25 Apr 2023 22:08:50 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3504F21C2B2C; Tue, 25 Apr 2023 13:08:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3504F21C2B2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1682453330; bh=biM2Y9lxIyG6GjOvd5N4UAUr2SQaeCpJdltVQ3Z9w3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZ6hxh3a0K+I0vlf/wSbidDf1jx3wRcn6cWpwCkJUMlGPCyX89yOqIs8kXBhGZpAq mgK4/gAI74UmTga0Jq1w40kO3Nfb+FlhAL48memCymxuGzMegyKcrdh39fzlf3NsGO xDbBnR8dz1aTCPO8bcacF81k0KfXQW11r08C+e1k= From: Tyler Retzlaff To: dev@dpdk.org Cc: bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v3 1/4] build: unblock the use of the MSVC compiler Date: Tue, 25 Apr 2023 13:08:46 -0700 Message-Id: <1682453329-20435-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682453329-20435-1-git-send-email-roretzla@linux.microsoft.com> References: <1674674707-3094-1-git-send-email-roretzla@linux.microsoft.com> <1682453329-20435-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Detect when MSVC toolset is available and tweak toolchain arguments where the meson build system offers no abstraction. Signed-off-by: Tyler Retzlaff Acked-by: Bruce Richardson --- buildtools/meson.build | 10 +++++++--- config/meson.build | 21 ++++++++++++++------- config/x86/meson.build | 8 +++++--- lib/meson.build | 13 ++++++++++--- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/buildtools/meson.build b/buildtools/meson.build index e1c600e..838c39f 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -4,7 +4,9 @@ pkgconf = find_program('pkg-config', 'pkgconf', required: false) check_symbols = find_program('check-symbols.sh') ldflags_ibverbs_static = find_program('options-ibverbs-static.sh') -objdump = find_program('objdump', 'llvm-objdump') +if cc.get_id() != 'msvc' + objdump = find_program('objdump', 'llvm-objdump') +endif python3 = import('python').find_installation(required: false) if python3.found() @@ -18,8 +20,10 @@ map_to_win_cmd = py3 + files('map_to_win.py') sphinx_wrapper = py3 + files('call-sphinx-build.py') get_cpu_count_cmd = py3 + files('get-cpu-count.py') get_numa_count_cmd = py3 + files('get-numa-count.py') -binutils_avx512_check = (py3 + files('binutils-avx512-check.py') + - [objdump] + cc.cmd_array()) +if cc.get_id() != 'msvc' + binutils_avx512_check = (py3 + files('binutils-avx512-check.py') + + [objdump] + cc.cmd_array()) +endif # select library and object file format pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()] diff --git a/config/meson.build b/config/meson.build index fa730a1..9a3f499 100644 --- a/config/meson.build +++ b/config/meson.build @@ -16,7 +16,8 @@ endforeach # MS linker requires special treatment. # TODO: use cc.get_linker_id() with Meson >= 0.54 -is_ms_linker = is_windows and (cc.get_id() == 'clang') +is_ms_compiler = is_windows and (cc.get_id() == 'msvc') +is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler) # set the major version, which might be used by drivers and libraries # depending on the configuration options @@ -130,11 +131,13 @@ dpdk_conf.set('RTE_MACHINE', cpu_instruction_set) machine_args = [] # ppc64 does not support -march= at all, use -mcpu and -mtune for that -if host_machine.cpu_family().startswith('ppc') - machine_args += '-mcpu=' + cpu_instruction_set - machine_args += '-mtune=' + cpu_instruction_set -else - machine_args += '-march=' + cpu_instruction_set +if not is_ms_compiler + if host_machine.cpu_family().startswith('ppc') + machine_args += '-mcpu=' + cpu_instruction_set + machine_args += '-mtune=' + cpu_instruction_set + else + machine_args += '-march=' + cpu_instruction_set + endif endif toolchain = cc.get_id() @@ -253,7 +256,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false endif # add -include rte_config to cflags -add_project_arguments('-include', 'rte_config.h', language: 'c') +if is_ms_compiler + add_project_arguments('/FI', 'rte_config.h', language: 'c') +else + add_project_arguments('-include', 'rte_config.h', language: 'c') +endif # enable extra warnings and disable any unwanted warnings # -Wall is added by default at warning level 1, and -Wextra diff --git a/config/x86/meson.build b/config/x86/meson.build index 54345c4..11f0bcc 100644 --- a/config/x86/meson.build +++ b/config/x86/meson.build @@ -25,9 +25,11 @@ if cc.has_argument('-mavx512f') endif # we require SSE4.2 for DPDK -if cc.get_define('__SSE4_2__', args: machine_args) == '' - message('SSE 4.2 not enabled by default, explicitly enabling') - machine_args += '-msse4' +if not is_ms_compiler + if cc.get_define('__SSE4_2__', args: machine_args) == '' + message('SSE 4.2 not enabled by default, explicitly enabling') + machine_args += '-msse4' + endif endif base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2'] diff --git a/lib/meson.build b/lib/meson.build index dc8aa4a..40c632a 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -241,9 +241,16 @@ foreach l:libraries output: '@0@_exports.def'.format(libname)) lk_deps += [def_file] - lk_args = ['-Wl,/def:' + def_file.full_path()] - if meson.version().version_compare('<0.54.0') - lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a'] + if is_ms_compiler + lk_args = ['/def:' + def_file.full_path()] + if meson.version().version_compare('<0.54.0') + lk_args += ['/implib:lib\\librte_' + l + '.dll.a'] + endif + else + lk_args = ['-Wl,/def:' + def_file.full_path()] + if meson.version().version_compare('<0.54.0') + lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a'] + endif endif else if is_windows -- 1.8.3.1