Skip to contentSkip to conversation

build/pkg-config: Fix warning for Windows

PATCH In review William Tu 3 participants 5 messages Sep 24, 2021 – Oct 7, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH 1/1 build/pkg-config: Fix warning for Windows

Windows does not support linker option '/-no-whole-archive' or '/whole-archive'. The patch removes them under Windows build.

---
 buildtools/pkg-config/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
buildtools/pkg-config/meson.build +7 -3
index 0412883c8f..989033db89 100644
@@ -40,7 +40,13 @@ Use libdpdk.pc instead of this file to query DPDK compile/link arguments''',
 platform_flags = []
 if not is_windows
     platform_flags += ['-Wl,--export-dynamic'] # ELF only
+    libraries_args = ['-Wl,--whole-archive'] +
+                     dpdk_drivers + dpdk_static_libraries +
+                     ['-Wl,--no-whole-archive'] + platform_flags
+else
+     libraries_args = dpdk_drivers + dpdk_static_libraries
 endif
+
 pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
         filebase: 'libdpdk',
         version: meson.project_version(),
@@ -49,9 +55,7 @@ Note that CFLAGS might contain an -march flag higher than typical baseline.
 This is required for a number of static inline functions in the public headers.''',
         requires: ['libdpdk-libs', libbsd], # may need libbsd for string funcs
                       # if libbsd is not enabled, then this is blank
-        libraries_private: ['-Wl,--whole-archive'] +
-            dpdk_drivers + dpdk_static_libraries +
-            ['-Wl,--no-whole-archive'] + platform_flags
+        libraries_private: libraries_args
 )
 
 # For static linking with dependencies as shared libraries,
Signature · 1 line
2.33.0.windows.2
#1 lore raw

2021-09-24 18:08 (UTC+0000), William Tu:

Quoted 7 lines

Windows does not support linker option '/-no-whole-archive' or '/whole-archive'. The patch removes them under Windows build.

---
 buildtools/pkg-config/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Hi William,

We need to tell the linker to use whole archive somehow;
you write [1] that /WHOLEARCHIVE was required in the end. There's no "Windows linker", there are clang and GCC linkers, the latter supports --whole-archive, but the former needs it translated. Argument translation between compilers is handled by meson. I've filed a bug: https://github.com/mesonbuild/meson/issues/9296

[1]:
http://inbox.dpdk.org/dev/CALDO+SZ-FLPYNQbUJ-Ctwtph+M4_X_=zYAOKgkp5_un4QFq_eg@mail.gmail.com/

author
#2 lore raw
Quoted 19 lines · Dmitry Kozlyuk

2021-09-24 18:08 (UTC+0000), William Tu:

Quoted 7 lines

Windows does not support linker option '/-no-whole-archive' or '/whole-archive'. The patch removes them under Windows build.

---
 buildtools/pkg-config/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Hi William,

We need to tell the linker to use whole archive somehow;
you write [1] that /WHOLEARCHIVE was required in the end. There's no "Windows linker", there are clang and GCC linkers, the latter supports --whole-archive, but the former needs it translated. Argument translation between compilers is handled by meson. I've filed a bug: https://github.com/mesonbuild/meson/issues/9296

Quoted 2 lines

[1]:
http://inbox.dpdk.org/dev/CALDO+SZ-FLPYNQbUJ-Ctwtph+M4_X_=zYAOKgkp5_un4QFq_eg@mail.gmail.com/

Hi Dmitry,

Thank you!
One more thing, when I added /WHOLEARCHIVE, I hit some errors due to macro definitions.
ex:
ws2_32.lib(WS2_32.dll) : error LNK2005: WS2_32_NULL_THUNK_DATA already defined in mincore.lib(WS2_32.dll)
Shlwapi.lib(SHLWAPI.dll) : error LNK2005: __NULL_IMPORT_DESCRIPTOR already defined in mincore.lib(api-ms-win-core -com-l1-1-0.dll)
Iphlpapi.lib(IPHLPAPI.DLL) : error LNK2005:
__IMPORT_DESCRIPTOR_IPHLPAPI already defined in mincore.lib(IPHLPAPI. see:
https://github.com/smadaminov/ovs-dpdk-meson-issues/issues/65

In the end, I have to add also:
-Wl,/FORCE:MULTIPLE

Thanks
William

#3 lore raw

Hi,

What is the conclusion for this patch?

26/09/2021 05:22, William Tu:

Quoted 44 lines · Dmitry Kozlyuk
Quoted 19 lines

2021-09-24 18:08 (UTC+0000), William Tu:

Quoted 7 lines

Windows does not support linker option '/-no-whole-archive' or '/whole-archive'. The patch removes them under Windows build.

---
 buildtools/pkg-config/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Hi William,

We need to tell the linker to use whole archive somehow;
you write [1] that /WHOLEARCHIVE was required in the end. There's no "Windows linker", there are clang and GCC linkers, the latter supports --whole-archive, but the former needs it translated. Argument translation between compilers is handled by meson. I've filed a bug: https://github.com/mesonbuild/meson/issues/9296

Quoted 2 lines

[1]:
http://inbox.dpdk.org/dev/CALDO+SZ-FLPYNQbUJ-Ctwtph+M4_X_=zYAOKgkp5_un4QFq_eg@mail.gmail.com/

Hi Dmitry,

Thank you!
One more thing, when I added /WHOLEARCHIVE, I hit some errors due to macro definitions.
ex:
ws2_32.lib(WS2_32.dll) : error LNK2005: WS2_32_NULL_THUNK_DATA already defined in mincore.lib(WS2_32.dll)
Shlwapi.lib(SHLWAPI.dll) : error LNK2005: __NULL_IMPORT_DESCRIPTOR already defined in mincore.lib(api-ms-win-core -com-l1-1-0.dll)
Iphlpapi.lib(IPHLPAPI.DLL) : error LNK2005:
__IMPORT_DESCRIPTOR_IPHLPAPI already defined in mincore.lib(IPHLPAPI. see:
https://github.com/smadaminov/ovs-dpdk-meson-issues/issues/65

In the end, I have to add also:
-Wl,/FORCE:MULTIPLE

Thanks
William

author
#4 lore raw

Please don't apply this patch.

I think we're waiting for meson to fix it.
https://github.com/mesonbuild/meson/issues/9296

In the meantime, at OVS's meson build script,
I'm adding /WHOLEARCHIVE and /FORCE:MULTIPLE
when linking dpdk. So no need to fix it here.

Thanks
William

Quoted 54 lines · Thomas Monjalon

Hi,

What is the conclusion for this patch?

26/09/2021 05:22, William Tu:

Quoted 44 lines · Dmitry Kozlyuk
Quoted 19 lines

2021-09-24 18:08 (UTC+0000), William Tu:

Quoted 7 lines

Windows does not support linker option '/-no-whole-archive' or '/whole-archive'. The patch removes them under Windows build.

---
 buildtools/pkg-config/meson.build | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Hi William,

We need to tell the linker to use whole archive somehow;
you write [1] that /WHOLEARCHIVE was required in the end. There's no "Windows linker", there are clang and GCC linkers, the latter supports --whole-archive, but the former needs it translated. Argument translation between compilers is handled by meson. I've filed a bug: https://github.com/mesonbuild/meson/issues/9296

Quoted 2 lines

[1]:
http://inbox.dpdk.org/dev/CALDO+SZ-FLPYNQbUJ-Ctwtph+M4_X_=zYAOKgkp5_un4QFq_eg@mail.gmail.com/

Hi Dmitry,

Thank you!
One more thing, when I added /WHOLEARCHIVE, I hit some errors due to macro definitions.
ex:
ws2_32.lib(WS2_32.dll) : error LNK2005: WS2_32_NULL_THUNK_DATA already defined in mincore.lib(WS2_32.dll)
Shlwapi.lib(SHLWAPI.dll) : error LNK2005: __NULL_IMPORT_DESCRIPTOR already defined in mincore.lib(api-ms-win-core -com-l1-1-0.dll)
Iphlpapi.lib(IPHLPAPI.DLL) : error LNK2005:
__IMPORT_DESCRIPTOR_IPHLPAPI already defined in mincore.lib(IPHLPAPI. see:
https://github.com/smadaminov/ovs-dpdk-meson-issues/issues/65

In the end, I have to add also:
-Wl,/FORCE:MULTIPLE

Thanks
William