build: propagate Windows system dependencies to pkg-config
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Thu, 19 Aug 2021 23:14:46 +0000 (02:14 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 14 Sep 2021 13:58:34 +0000 (15:58 +0200)
Windows EAL depends on some system libraries. They were linked using
add_project_link_arguments('-l<LIB>'), which prevented meson from adding
them to Libs.private of pkg-config file. As a result, applications using
pkg-config to find DPDK hit link errors, for example:

    librte_eal.a(eal_windows_eal_debug.c.obj) : error LNK2019: unresolved
    external symbol __imp_SymInitialize referenced in function
    rte_dump_stack

Reference required libraries in EAL using ext_deps meson variable.
bus/pci and net/pcap depend on lib/eal and will pull them automatically.
Drop advapi32 dependency, as MinGW locates VirtualAlloc2() dynamically.

Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
Fixes: c91717eb75c8 ("eal/windows: support exit and panic")
Cc: stable@dpdk.org
Reported-by: William Tu <u9012063@gmail.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Tested-by: William Tu <u9012063@gmail.com>
config/meson.build
lib/eal/windows/meson.build

index 3b5966e..0b83594 100644 (file)
@@ -340,7 +340,8 @@ if is_freebsd
 endif
 
 if is_windows
-    # VirtualAlloc2() is available since Windows 10 / Server 2016.
+    # VirtualAlloc2() is available since Windows 10 / Server 2019.
+    # It's essential for EAL, so we don't support older versions.
     add_project_arguments('-D_WIN32_WINNT=0x0A00', language: 'c')
 
     # Use MinGW-w64 stdio, because DPDK assumes ANSI-compliant formatting.
@@ -352,17 +353,6 @@ if is_windows
     if cc.get_id() == 'clang'
         add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
     endif
-
-    add_project_link_arguments('-lws2_32', language: 'c')
-
-    # Contrary to docs, VirtualAlloc2() is exported by mincore.lib
-    # in Windows SDK, while MinGW exports it by advapi32.a.
-    if is_ms_linker
-        add_project_link_arguments('-lmincore', language: 'c')
-    endif
-
-    add_project_link_arguments('-ladvapi32', '-lsetupapi', language: 'c')
-    add_project_link_arguments('-ldbghelp', language: 'c')
 endif
 
 if get_option('b_lto')
index fc12fef..845e406 100644 (file)
@@ -24,3 +24,13 @@ sources += files(
 )
 
 dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
+
+ext_deps += [
+        cc.find_library('dbghelp'),
+        cc.find_library('setupapi'),
+        cc.find_library('ws2_32'),
+]
+if is_ms_linker
+        # Contrary to docs, VirtualAlloc2() is exported by mincore.lib.
+        ext_deps += cc.find_library('mincore')
+endif