Repository navigation
Closed
Labels
P3We're not considering working on this, but happy to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
Description
Description of the problem / feature request / question:
I know this is an issue with the toolchain, I've just filed a bug report it. But I think bazel should be able to handle this situation better.
The toolchain in question: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
This is just sample code:
cc_library(
name = "headers",
hdrs = [ "Inc/fileA.h", "Inc/fileB.h"],
includes = ["Inc/"]
)
cc_binary(
name = "bin",
srcs = ["Src/fileA.cpp"],
deps = [":headers"]
)
I would get a build with something like this:
external/stm32/tools/arm_compiler/arm_none_gcc/arm-none-eabi-gcc '-mcpu=cortex-m4' -mthumb '-mfloat-abi=hard' '-mfpu=fpv4-sp-d16' -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -I external/com_arm_developer_toolchain_gcc_6_2/arm-none-eabi/include/c++/6.3.1/arm-none-eabi -I external/com_arm_developer_toolchain_gcc_6_2/arm-none-eabi/include/c++/6.3.1 -I external/com_arm_developer_toolchain_gcc_6_2/arm-none-eabi/libc/usr/include '-std=c++11' -MD -MF bazel-out/clang_linux_arm-fastbuild/bin/_objs/Src/fileA.d '-frandom-seed=bazel-out/clang_linux_arm-fastbuild/bin/_objs/Src/fileA.o' -iquote . -iquote external/bazel_tools -iquote bazel-out/clang_linux_arm-fastbuild/genfiles/external/bazel_tools -isystem Inc -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c Src/fileA.cpp -o bazel-out/clang_linux_arm-fastbuild/bin/_objs/Src/fileA.o
The issue being the -isystem Inc. If bazel handled it as -IInc this issues doesn't happen, so for now I'm using copts = ["-IInc"], but that doesn't propagate to other libraries as includes does.
If possible, provide a minimal example to reproduce the problem:
Environment info
- Operating System: ubuntu 16.04
- Bazel version (output of
bazel info release): release 0.5.1
Reacted by Nathaniel Brough and jemeador
Metadata
Metadata
Assignees
Labels
P3We're not considering working on this, but happy to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
Activity
kersson commentedon Jul 26, 2017
Yes, can someone explain the reasoning behind propagating
includesas-isystemand not-I? We have a similar issue where compile warnings are being ignored in our headers because they're being treated as system headers when propagated to projects that depend on them.hlopko commentedon Aug 17, 2017
Well the reasoning is simple, although not what you'd expect. Internally we don't use <> includes at all, and includes attribute was only introduced for the third_party code, for which we didn't want to show warnings. We will definitely improve the support for includes, but not in the short term, as we need to finish higher priority features first.
nicolov commentedon Aug 27, 2017
From what I can tell, using
strip_include_prefixon libA adds a flag that looks like:And the flag is indeed passed on to dependents.
driveraid commentedon Jun 14, 2018
We were just hit by this in our company, wasted 6 hours debugging due to a missing return statement in a header file exposed by includes, in a build with -Werror enabled. -Wsystem-headers is hopeless due to our big exposure against system and 3rdparty stuff. Any chance this could be fixed near term?
hlopko commentedon Jun 15, 2018
Unfortunately unlikely in 2018 (roadmap: https://docs.google.com/document/d/1K3Dq1JDDWjGtvTyFcIwy_-Crm7ZuD9FzSxjDawDhJRA/edit)
jgavris commentedon Jan 14, 2019
If you're using the Clang compiler, you can workaround this by marking certain include paths as 'not system headers'.
https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers
nathaniel-brough commentedon Mar 4, 2019
I've been working on a few work arounds for this. Though I have had little success at this point. What I have tried so far;
First Method:
The first method I tried was to string replace all
-isystemto-Iflags inside a wrapper script for gcc.e.g.
However for whatever reason this results in an error about undeclared includusions:
File list above has been truncated for brevity.
For reference here is the relevant section of my toolchain_config _impl.
NOTE: All "missing dependency" errors are about files that have been included using the "toolchain_include_directories" feature.
I am not sure how to go about fixing these errors, but I suspect it is something to do with the
{target}.dfiles that are generated by bazel with string replacement from-isystem>>-I.Second Method:
The second method was to include the system headers with the
-Iflag directly in the bazel toolchain. In other words the include path function changes the-isystemflag to-I. This would only be a partial fix as the-isystemflag is used for all targets normally.This however resulted in the same errors as seen in the first method.
Future Approaches
-Iinstead of -isystem`. Doable but I wouldn't have any idea about where to start or what side effects it may have on the build system.If you have any suggestions or see any workarounds based on what I have above let me know. At this point I am at a bit of a loss. I am definitely a novice user of starlark, so I'd be keen for a hand if anyone has an idea as to why I might be getting these errors.
Environment Info
Manjaro Linux (Rolling Release)
bazel info release
release 0.23.0
sgowroji commentedon Feb 14, 2023
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.