Double-dot in path's may cause problems with gcc under Windows #28893
Labels
area: Build System
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Describe the bug
In our project that is using Zephyr 2.4.0 in combination with GCC for ARM under Windows we struggled over an issue that was totally confusing. In our CMakeFiles.txt we set some additional paths for SO, BOARD and DTS. Based on our directory structure we had paths with double-dots in it (e.g. "c:/myroot/main/../device/board"). The project could be configured with cmake, but when the Ninja was triggered to build the project a re-run of cmake is triggered. This ends in an endless loop with re-run of the cmake.
After a lot of reading and studying the CMake/Ninja functionality I found out that the re-run is caused by an entry in the ninja.build file inputs. Somehow a "c$:" entry was added to the input files that always triggered the re-run.
Remark: This can be found out by activating the explain feature of Ninja (e.g. => "ninja -C [build-path] -d explain").
My first thought was that it's a bug in cmake, but after updating to the latest version and additionally debugging cmake based on the git repository I came to the conclusion that the unexpected dependency 'c$:' comes from the zephyr environment.
In the next step I found that the includes in my .dts file are somehow the source for the issue. Looking at the .dts.pre.d file in the build folder showed the source of the problem:
empty_file.o: \ C:/Daten/git/topic-mcuboot/zephyr/misc/empty_file.c \ C:/Daten/git/topic-mcuboot/device/boards/arm/myboard/myboard.dts \ c:\daten\git\topic-mcuboot\device\dts\arm\silabs\efr32fg14p231f128gm32.dtsi \ C:/Daten/git/topic-mcuboot/zephyr/dts/common/mem.h
The paths of files that are in a folder that is added by the double-dots have a backslash notation and the others have a forward slash. This file is afterwards split into the different dependency files by a split based on backslash's in dts.cmake. The path with the backslashes is into multiple elements and also a "c:".
If the paths for the board, soc and dts are given without double-dots all files are given with forward slashes.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Double-dots should work as other path variants.
Impact
The issue could be fixed by not using double-dots, but it took me a full day to get the reason for the strange behavior.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: