bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.86k stars 4.01k forks source link

Modifying headers does not trigger a rebuild of related C\C++ source files when tasking compiler is used #12921

Open sslobodanka opened 3 years ago

sslobodanka commented 3 years ago

Description of the problem / feature request:

The project/source files compilation (C\C++) is not triggered when related header file is changed. Currently Bazel is re-triggering the build only when a .c source file is changed and changes in a header file(s) are ignored. Based on the initial analysis the assumption is that the dependency parser in Bazel doesn't parse properly the dependency file created by tasking compiler during the compilation phase.

It seems that the main issue is that the dependency file contains tabs after the target name that are not process by Bazel. In the parser the tabs are handled like any normal character and they become part of the target name. As consequence multiple lines (if not all) of the dependency file are completely ignored. Because of that the dependency list is not filled correctly and does not contain the dependency files which results the compilation not to be triggered when changing some header file.

Example .d file generated when the tasking compiler is called with the “--dep-file” option:

hello_world.o :             application/swc/common/startup/hello_world.c
application/swc/common/startup/hello_world.c:
hello_world.o :             application\swc\common\startup\hello_world.h
application\swc\common\startup\hello_world.h :
hello_world.o : "C:\tools\tasking-v6.2r2-expanded\ctc\include\stdlib.h"
"C:\tools\tasking-v6.2r2-expanded\ctc\include\stdlib.h" :
hello_world.o : "C:\tools\tasking-v6.2r2-expanded\ctc\include\stdbool.h"
"C:\tools\tasking-v6.2r2-expanded\ctc\include\stdbool.h" :
hello_world.o : "C:\tools\tasking-v6.2r2-expanded\ctc\include\sfr\regx.sfr"
"C:\tools\tasking-v6.2r2-expanded\ctc\include\sfr\regx.sfr" :

Feature requests: what underlying problem are you trying to solve with this feature?

Improve parsing of dependency file for C\C++ projects

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

To reproduce the issue it's required to setup and configure build environment with tasking toolchain . The corresponding flag in tasking for the dependency feature is “--dep-file”. The build then can be called with the corresponding config e.g.

bazel build --config=tasking_config hello-world

What operating system are you running Bazel on?

Windows 10

What's the output of bazel info release?

release 4.0.0

Have you found anything relevant by searching the web?

No

rdeushane commented 1 year ago

This isn't an issue with Bazel, it's an issue with how Tasking writes dependency files in a non-standard way that Bazel cannot read. You need to implement a wrapper around your compiler that swallows the GCC depfile arg and rewrites it as --dep-file, and following compilation, rewrites to depfile to be GNU style:

# GCC typically writes dependency files something like:
# ----------------------GCC DEPENDENCY FILE--------------------------------------------------------
# main.o: \
# main.c \
# os_system.h \
# /opt/tasking/TriCore/ctc/include/stdbool.h \
# -------------------------------------------------------------------------------------------------
# Where the equivalent in Tasking is:
# ----------------------TASKING DEPENDENCY FILE----------------------------------------------------
# main.o :  main.c
# main.c :
# main.o :  os_system.h
# os_system.h :
# main.o :  /opt/tasking/TriCore/ctc/include/stdbool.h
# /opt/tasking/TriCore/ctc/include/stdbool.h :
# -------------------------------------------------------------------------------------------------
github-actions[bot] commented 6 months ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

tejaspawar1200 commented 4 months ago

I am using TASKING compiler with GNU make. I am not using Cmake or bazel. To generate dependencies I use option --dep-file. But in some .d dependencies files targets are created like below. Path of header files which are at TASKING compiler installation path , added with double quotes in .d files. Because of that, when i tried to do incremental build I am getting error. Every time I have to give clean build.

If I manually remove double quotes , then incremental build is possible. Anybody aware of this issue?

error =>

"main.d:15: *** target pattern contains no '%'. Stop."

main.d =>

main.o : "C:\TASKING\TriCorev6_3r1\ctc\include\stdint.h" "C:\TASKING\TriCorev6_3r1\ctc\include\stdint.h" : main.o : "C:\TASKING\TriCorev6_3r1\ctc\include\typeinfo.h" "C:\TASKING\TriCorev6_3r1\ctc\include\typeinfo.h" :