eal/windows: fix link error with MinGW
PATCH 1/1 eal/windows: fix link error with MinGW
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol 'GUID_DEVCLASS_NET'. This occurs because devguid.h is included in rte_windows.h before INITGUID is defined.
Resolved by moving the include of devguid.h after the definition of INITGUID.
--- lib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/windows/include/rte_windows.h +1 -1
@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /**
Signature · 1 line
2.25.1
Quoted 7 lines
Subject: [PATCH] eal/windows: fix link error with MinGW
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol '
GUID_DEVCLASS_NET'.
This occurs becausedevguid.his included inrte_windows.hbefore INITGUID is defined.
Hi Nick,
I can't seem to reproduce the link error you've mentioned (I'm building hello_world on master). can you share more information on how to reproduce it? (MinGW version, build env variables, build OS).
Thanks,
Tal.
Quoted 32 lines
Resolved by moving the include of
devguid.hafter the definition of INITGUID.Fixes b762221ac24f ("bus/pci: support Windows with bifurcated drivers")Signed-off-by Nick Connolly <[email protected]>--- lib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/windows/include/rte_windows.h +1
-2@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /** -- 2.25.1
Quoted 7 lines
I can't seem to reproduce the link error you've mentioned (I'm building
hello_worldon master). can you share more information on how to reproduce it? (MinGW version, build env variables, build OS).Thanks,
Tal.
Hi Tal,
Sure - latest MinGW-w64 (v8.0.0 I believe, but the versioning isn't too clear to me!). gcc -v reports:
Quoted 41 lines
C:\Users\Nick>c:\MinGW\mingw64\bin\gcc -v
Using built-in specs.
COLLECT_GCC=c:\MinGW\mingw64\bin\gcc COLLECT_LTO_WRAPPER=c:/MinGW/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure
--host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic
--enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls
--disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv
--with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2(quoted diff) +0
-4-pipe -fno-ident -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include'CXXFLAGS='-O2 -pipe -fno-ident
(quoted diff) +0
-3-I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include'CPPFLAGS='
(quoted diff) +0
-3-I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include'LDFLAGS='-pipe -fno-ident
(quoted diff) +0
-3-L/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Quoted 2 lines
Thread model: win32
gcc version 8.1.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)
No special build args, just Meson (0.55.3) with --buildtype==debug -Dexamples=helloworld
DPDK builds just fine with both MinGW and Clang, but when I try and use it to build the SPDK the linking fails with MinGW (but works fine with Clang). The error message is:
Quoted 3 lines
CC
app/trace_record/trace_record.o
LINK spdk_trace_record.exe C:/Users/Nick/Repos/upstream/build/lib/librte_bus_pci.a(bus_pci_windows_pci.c.obj):pci.c:(.rdata$.refptr.GUID_DEVCLASS_NET[.refptr.GUID_DEVCLASS_NET]+0x0): undefined reference to `GUID_DEVCLASS_NET'
As far as I can see this is because the GUID_DEVCLASS_NET structure has not been created within the DPDK object files - it requires INITGUID to be set when devguid.h is included in order to create a 'select any' initialised structure. Moving devguid.h after defining INITGUID resolves the issue. Arguably, it would perhaps be better to define INITGUID in the source files that use the guids instead of in a shared header, but I think this can safely be left until after 20.11 is finalized - if there's any impact on the code produced it will be negligible.
I haven't worked it through but I suspect the reason it's ok with clang is because of a difference between the Microsoft headers and those shipped with MinGW.
Regards,
Nick
Build OS is Windows 10 2004
Hi Nick,
Thanks for detailed explanation. It can be reproduced even without DPDK:
#include <windows.h>
#include <devguid.h>
int
main(int argc, char **argv) {
return (int)&GUID_DEVCLASS_NET;
}This links with clang, but not with MinGW-w64. AFAIK, it should not link, because INITGUID is not defined. @DmitryM, @Naty, correct me if I'm wrong. So I agree your fix is needed.
Quoted 2 lines
Sure - latest MinGW-w64 (v8.0.0 I believe, but the versioning isn't too clear to me!).
This is correct, MinGW-w64 version is different from GCC version, so it's MinGW-w64 8.0.0 with GCC 8.1.0.
Quoted 5 lines
[...] Arguably, it would perhaps be better to define INITGUID in the source files that use the guids instead of in a shared header, but I think this can safely be left until after 20.11 is finalized - if there's any impact on the code produced it will be negligible.
I disagree. Just because we have rte_windows.h to properly plug Windows SDK in, other DPDK code doesn't need to care about these details. Unused GUIDs do take some space in static libraries, but IMO it's a fair trade for ease of development. They shouldn't have any impact on resulting binaries.
Hi Dmitry,
Quoted 4 lines · Dmitry Kozlyuk
I disagree. Just because we have
rte_windows.hto properly plug Windows SDK in, other DPDK code doesn't need to care about these details. Unused GUIDs do take some space in static libraries, but IMO it's a fair trade for ease of development. They shouldn't have any impact on resulting binaries.
Ah! I hadn't spotted that rte_windows.h is intended to wrap the Windows SDK. In which case, I agree with you - best to take care of it there.
Regards,
Nick
Quoted 7 lines · Nick Connolly
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol '
GUID_DEVCLASS_NET'. This occurs becausedevguid.his included inrte_windows.hbefore INITGUID is defined.Resolved by moving the include of
devguid.hafter the definition of INITGUID.
Commit changes should be described in present tense.
Quoted 3 lines
Fixes b762221ac24f ("bus/pci: support Windows with bifurcated drivers")
A blank line should be here.
Quoted 2 lines
Signed-off-by Nick Connolly <[email protected]>---
Apart from those nits,
PATCH v2 1/1 eal/windows: fix link error with MinGW
In reply to Nick ConnollyLinking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol 'GUID_DEVCLASS_NET'. This occurs because devguid.h is included in rte_windows.h before INITGUID is defined.
Move the include of devguid.h after the definition of INITGUID.
---
v2
* Fix commit message - add blank line, use present tense
lib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/windows/include/rte_windows.h +1 -1
@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /**
Signature · 1 line
2.25.1
Quoted 11 lines
Subject: [PATCH v2] eal/windows: fix link error with MinGW
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol '
GUID_DEVCLASS_NET'.
This occurs becausedevguid.his included inrte_windows.hbefore INITGUID is defined.Move the include of
devguid.hafter the definition of INITGUID.Fixes b762221ac24f ("bus/pci: support Windows with bifurcated drivers")
https://doc.dpdk.org/guides-20.08/contributing/stable.html#what-changes-should-be-backported
Quoted 31 lines
Signed-off-by Nick Connolly <[email protected]>---
v2
* Fix commit message - add blank line, use present tenselib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/windows/include/rte_windows.h +1
-2@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /** -- 2.25.1
PATCH v3 1/1 eal/windows: fix link error with MinGW
In reply to Nick ConnollyLinking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol 'GUID_DEVCLASS_NET'. This occurs because devguid.h is included in rte_windows.h before INITGUID is defined.
Move the include of devguid.h after the definition of INITGUID.
---
v2
* Change Cc to [email protected]
v2
* Fix commit message - add blank line, use present tense
lib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/windows/include/rte_windows.h +1 -1
@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /**
Signature · 1 line
2.25.1
Quoted 43 lines
Subject: [PATCH v3] eal/windows: fix link error with MinGW
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol '
GUID_DEVCLASS_NET'.
This occurs becausedevguid.his included inrte_windows.hbefore INITGUID is defined.Move the include of
devguid.hafter the definition of INITGUID.Fixes b762221ac24f ("bus/pci: support Windows with bifurcated drivers")Signed-off-by Nick Connolly <[email protected]>---
v2
* Change Cc to [email protected]
v2
* Fix commit message - add blank line, use present tenselib/librte_eal/windows/include/rte_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/windows/include/rte_windows.h +1
-2@@ -25,13 +25,13 @@#include <psapi.h> #include <setupapi.h> #include <winioctl.h> -#include <devguid.h> /* Have GUIDs defined. */ #ifndef INITGUID #define INITGUID #endif #include <initguid.h> +#include <devguid.h> #include <rte_log.h> /** --
Quoted 1 line
2.25.1
Thomas Monjalon
AppliedQuoted 5 lines
Quoted 5 lines
Linking with the 'pci' driver when building with MinGW on Windows fails with undefined symbol '
GUID_DEVCLASS_NET'.
This occurs becausedevguid.his included inrte_windows.hbefore INITGUID is defined.
Quoted 8 lines
Quoted 6 lines
Move the include of
devguid.hafter the definition of INITGUID.Fixes b762221ac24f ("bus/pci: support Windows with bifurcated drivers")Signed-off-by Nick Connolly <[email protected]>Reviewed-by Tal Shnaiderman <[email protected]>
Applied, thanks