Skip to content

gdb: Default to _WIN32_WINNT=0x0600 #969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025
Merged

Conversation

stephanosio
Copy link
Member

@stephanosio stephanosio commented Jul 21, 2025

This commit pulls in the GDB patch that sets _WIN32_WINNT to 0x0600
when not explicitly defined in the CFLAGS.

Note that, libstdc++, when building with the win32 thread model, only
supports std::mutex and std:condition_variable if _WIN32_WINNT >=
0x0600.


GDB PR: zephyrproject-rtos/binutils-gdb#18

Tested in https://github.com/zephyrproject-rtos/sdk-ng/actions/runs/16438257464

Fixes #964

@stephanosio stephanosio marked this pull request as ready for review July 22, 2025 00:02
@stephanosio stephanosio added area: GDB Issues related to GDB (GNU Debugger) DNM DO NOT MERGE labels Jul 22, 2025
@stephanosio
Copy link
Member Author

DNM until zephyrproject-rtos/binutils-gdb#18 is merged.

@stephanosio stephanosio force-pushed the topic-sdk-build-mingw-gdb branch 2 times, most recently from ba9ae3b to 42bacb6 Compare July 22, 2025 07:55
@stephanosio stephanosio marked this pull request as draft July 22, 2025 12:19
@stephanosio
Copy link
Member Author

stephanosio commented Jul 22, 2025

In conjunction with #974, verified that the GDB executable builds successfully and runs on Windows with no direct MinGW dependencies; also note that it links against the UCRT (ucrtbase.dll) as intended.

$ ldd aarch64-zephyr-elf-gdb
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7fffe8a50000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7fffe6d00000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7fffe6440000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7fffe6190000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7fffe6340000)
        USER32.dll => /c/Windows/System32/USER32.dll (0x7fffe8810000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x7fffe60e0000)
        GDI32.dll => /c/Windows/System32/GDI32.dll (0x7fffe81a0000)
        gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7fffe67f0000)
        msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7fffe61c0000)
        WS2_32.dll => /c/Windows/System32/WS2_32.dll (0x7fffe80d0000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7fffe86e0000)
image

@stephanosio
Copy link
Member Author

stephanosio commented Jul 22, 2025

Reverting "workaround for issue wih gdb/mingw" and making GCC build with the sdk-build MinGW toolchain seems to have made GCC misbehave for some Xtensa targets, which is a separate issue from what this PR fixes:

2025-07-22T12:27:55.7140088Z INFO    - The following issues were found (showing the top 10 items):
2025-07-22T12:27:55.7141297Z INFO    - 1) cpp.libcxx.glibcxx.picolibc on esp32_devkitc/esp32/procpu error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T12:27:55.7142281Z INFO    - 2) cpp.libcxx.glibcxx.picolibc on esp32s2_saola/esp32s2 error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T12:27:55.7143236Z INFO    - 3) cpp.libcxx.glibcxx.picolibc on esp32s3_devkitm/esp32s3/procpu error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T12:27:55.7144628Z INFO    - 4) cpp.libcxx.glibcxx.picolibc on imx8mp_evk/mimx8ml8/adsp error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T12:27:55.7145943Z INFO    - 5) cpp.libcxx.glibcxx.picolibc on intel_adsp/ace15_mtpm error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T12:27:55.7147144Z INFO    - 6) cpp.libcxx.glibcxx.picolibc on intel_adsp/cavs25 error (Build failure - error: bits/c++config.h: No such file or directory)
2025-07-22T11:32:32.0268762Z INFO    -  82/261 intel_adsp/cavs25         cpp.libcxx.glibcxx.picolibc                        �[31mERROR�[39m Build failure (build <zephyr/gnu>)
...
025-07-22T11:32:32.3706139Z -- Found GnuLd: C:/a/sdk-ng/sdk-ng/tools/zephyr-sdk-0.18.0-alpha4-23-g42bacb6/gnu/xtensa-intel_tgl_adsp_zephyr-elf/xtensa-intel_tgl_adsp_zephyr-elf/bin/ld.bfd.exe (found version "2.43.1")
2025-07-22T11:32:32.3707500Z -- The C compiler identification is GNU 14.3.0
2025-07-22T11:32:32.3708066Z -- The CXX compiler identification is GNU 14.3.0
2025-07-22T11:32:32.3708604Z -- The ASM compiler identification is GNU
2025-07-22T11:32:32.3709488Z -- Found assembler: S:/gnu/xtensa-intel_tgl_adsp_zephyr-elf/bin/xtensa-intel_tgl_adsp_zephyr-elf-gcc.exe
...
2025-07-22T11:32:32.3731686Z [14/160] Building CXX object CMakeFiles/app.dir/src/main.cpp.obj
2025-07-22T11:32:32.3732117Z 
2025-07-22T11:32:32.3732404Z FAILED: [code=1] CMakeFiles/app.dir/src/main.cpp.obj 
2025-07-22T11:32:32.3732807Z 
2025-07-22T11:32:32.3751930Z ccache S:\gnu\xtensa-intel_tgl_adsp_zephyr-elf\bin\xtensa-intel_tgl_adsp_zephyr-elf-g++.exe -DKERNEL -DK_HEAP_MEM_POOL_SIZE=0 -DPICOLIBC_LONG_LONG_PRINTF_SCANF -DTC_RUNID=cde2bf9719f72d1338d8b04cb0e20184 -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -IC:/a/sdk-ng/sdk-ng/test/twister-out/twister_links/test_167/zephyr/include/generated/zephyr -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/include -IC:/a/sdk-ng/sdk-ng/test/twister-out/twister_links/test_167/zephyr/include/generated -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp/common -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp/common/include -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp/cavs -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp/cavs/include -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/soc/intel/intel_adsp/cavs/include/cavs25 -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/subsys/testsuite/include -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/subsys/testsuite/coverage -IC:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/subsys/testsuite/ztest/include -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/ti/mspm0/source/ti/devices/msp/. -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/ti/mspm0/source/ti/devices/msp/m0p -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/ti/mspm0/source/ti/devices/msp/peripherals -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/ti/mspm0/source/ti/devices/msp/peripherals/m0p -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/ti/mspm0/source/ti/devices/msp/peripherals/m0p/sysctl -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/xtensa/include -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/xtensa/XTENSA_HAL -IC:/a/sdk-ng/sdk-ng/zephyrproject/modules/hal/xtensa/zephyr/soc/intel_tgl_adsp -isystem C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/lib/libc/common/include -fno-strict-aliasing -Werror -O2 -fcheck-new -std=c++17 -Wno-register -fno-rtti -imacros C:/a/sdk-ng/sdk-ng/test/twister-out/twister_links/test_167/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always --sysroot=S://gnu/xtensa-intel_tgl_adsp_zephyr-elf/xtensa-intel_tgl_adsp_zephyr-elf -imacros C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/tests/lib/cpp/libcxx=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -specs=picolibc.specs -MD -MT CMakeFiles/app.dir/src/main.cpp.obj -MF CMakeFiles\app.dir\src\main.cpp.obj.d -o CMakeFiles/app.dir/src/main.cpp.obj -c C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/tests/lib/cpp/libcxx/src/main.cpp
2025-07-22T11:32:32.3771425Z 
2025-07-22T11:32:32.3772486Z In file included from C:/a/sdk-ng/sdk-ng/tools/zephyr-sdk-0.18.0-alpha4-23-g42bacb6/gnu/xtensa-intel_tgl_adsp_zephyr-elf/xtensa-intel_tgl_adsp_zephyr-elf/include/c++/14.3.0/compare:36,
2025-07-22T11:32:32.3774630Z                  from C:/a/sdk-ng/sdk-ng/tools/zephyr-sdk-0.18.0-alpha4-23-g42bacb6/gnu/xtensa-intel_tgl_adsp_zephyr-elf/xtensa-intel_tgl_adsp_zephyr-elf/include/c++/14.3.0/array:38,
2025-07-22T11:32:32.3776251Z                  from C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/tests/lib/cpp/libcxx/src/main.cpp:7:
2025-07-22T11:32:32.3778118Z C:/a/sdk-ng/sdk-ng/tools/zephyr-sdk-0.18.0-alpha4-23-g42bacb6/gnu/xtensa-intel_tgl_adsp_zephyr-elf/xtensa-intel_tgl_adsp_zephyr-elf/include/c++/14.3.0/bits/version.h:49:10: fatal error: bits/c++config.h: No such file or directory
2025-07-22T11:32:32.3779739Z    49 | #include <bits/c++config.h>
2025-07-22T11:32:32.3780220Z       |          ^~~~~~~~~~~~~~~~~~
2025-07-22T11:32:32.3780670Z compilation terminated.

Full log: https://github.com/zephyrproject-rtos/sdk-ng/actions/runs/16438257464/job/46465635676

This is likely a file path length issue given that it only happens with the Xtensa toolchains with longer paths ...

UPDATE

It is indeed a long path issue. The issue is locally reproducible on a Windows 10 22H2 machine; moving the toolchain directory to a shorter path makes the compilation succeed.

Based on https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry, enabling system-wide long path support (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1) and patching the GCC executable manifest makes it work with longer paths.

This commit pulls in the GDB patch that sets `_WIN32_WINNT` to 0x0600
when not explicitly defined in the CFLAGS.

Note that, libstdc++, when building with the win32 thread model, only
supports std::mutex and std:condition_variable if _WIN32_WINNT >=
0x0600.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This reverts commit 5423f49 because the
GDB build issue has been fixed.

Signed-off-by: Stephanos Ioannidis <[email protected]>
@stephanosio
Copy link
Member Author

Re: #969 (comment)

Created a separate issue tracking this: #979

This will be fixed in a separate follow-up PR.

@stephanosio stephanosio marked this pull request as ready for review July 23, 2025 06:10
@stephanosio stephanosio force-pushed the topic-sdk-build-mingw-gdb branch from 42bacb6 to 93c46c3 Compare July 23, 2025 06:11
@stephanosio stephanosio merged commit 25fad5b into main Jul 23, 2025
3 of 221 checks passed
@stephanosio stephanosio deleted the topic-sdk-build-mingw-gdb branch July 23, 2025 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: GDB Issues related to GDB (GNU Debugger) DNM DO NOT MERGE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix GDB issues with sdk-build MinGW
1 participant