[dpdk-dev] [PATCH] eal/windows: fix link error with MinGW

Nick Connolly nick.connolly at mayadata.io
Sat Nov 21 00:43:33 CET 2020


> 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.

Hi Tal,

Sure - latest MinGW-w64 (v8.0.0 I believe, but the versioning isn't too 
clear to me!).  gcc -v reports:

> 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 
> -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 
> -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=' 
> -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 
> -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 '
> 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:
> 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


More information about the dev mailing list