-
Notifications
You must be signed in to change notification settings - Fork 4k
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
cc_common.compile API broken/changed for virtual_includes in 7.2.1 to 6.2.1 #23061
Comments
It looks like the diff is the same for these testcases that were changed in the bisected Commit: 7e0df68#diff-f087e973daabb7df3b785dd5dba1b9c8250ac046c6fcf62109b7f19eb07a7da2L5548-R5549 |
Created #23064 to test for the supposed error. But i don't know yet where to attempt to fix it |
I believe i tracked down the root of the issue: The virtual includes and their include paths are created here: bazel/src/main/starlark/builtins_bzl/common/cc/cc_compilation_helper.bzl Lines 117 to 138 in 17eadaf
The discrepancy is introduced here: Which uses the label name internally to construct the unique _virtual_include dir that does not match the symlinked header from Backtrace of nameThe label is originally created here: bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java Lines 2005 to 2012 in 17eadaf
coming from:
which gets the
|
@comius @pzembrod I linked the PR that i managed to fix the error with. Would be awesome if you can take a look. If possible i would want to include this in the next 7.x release as well. There is a merge conflict with the cleanup in https://github.com/bazelbuild/bazel/pull/23071/files#diff-8c47ef0983742d8167b5bdaf3b4c6fe872365949ecf0ef64098e38458ba5a3a1L347-L366 |
@fmeum @meteorcloudy Sry for being annoying. I know that you are not the owners here, but I saw you as being active contributors in seemingly related parts so i am trying to reach somebody to get some feedback on the issue/fix🤞 I am happy to update the PR if there is anything more to do |
So far only the generated header in the virtual includes is tested but the Include path pointing to that directory isnt This is a testcase to reproduce the suspected error reported here: - bazelbuild#23061 Assuming that the location of the file is asserted: ```Java assertThat(artifactsToStrings(ccInfo.getCcCompilationContext().getDirectPublicHdrs())) .contains("bin third_party/bar/_virtual_includes/starlark_lib_suffix/starlark_lib.h"); ``` Adding a testcase for the include path seems reasonable. A local run of the testcase shows the error: ``` 1) testStripIncludePrefixIncludePath(com.google.devtools.build.lib.rules.cpp.StarlarkCcCommonTest) value of: getIncludeDirs().onlyElement() expected: bazel-out/k8-fastbuild/bin/third_party/bar/_virtual_includes/starlark_lib_suffix but was : bazel-out/k8-fastbuild/bin/third_party/bar/_virtual_includes/starlark_lib at com.google.devtools.build.lib.rules.cpp.StarlarkCcCommonTest.testStripIncludePrefixIncludePath(StarlarkCcCommonTest.java:5902) FAILURES!!! Tests run: 73, Failures: 1 ``` The change in behaviour was introduced in bazelbuild@7e0df68#diff-403c46ec3075b8e9e6d490ce955db88dae2d457b8046608884039b18b10ab6ccR774 Fixes: bazelbuild#23061 Closes bazelbuild#23071. PiperOrigin-RevId: 660681269 Change-Id: Ia3f8a8a6cf8bf0e093416a247e348e6de6719584
So far only the generated header in the virtual includes is tested but the Include path pointing to that directory isnt This is a testcase to reproduce the suspected error reported here: - #23061 Assuming that the location of the file is asserted: ```Java assertThat(artifactsToStrings(ccInfo.getCcCompilationContext().getDirectPublicHdrs())) .contains("bin third_party/bar/_virtual_includes/starlark_lib_suffix/starlark_lib.h"); ``` Adding a testcase for the include path seems reasonable. A local run of the testcase shows the error: ``` 1) testStripIncludePrefixIncludePath(com.google.devtools.build.lib.rules.cpp.StarlarkCcCommonTest) value of: getIncludeDirs().onlyElement() expected: bazel-out/k8-fastbuild/bin/third_party/bar/_virtual_includes/starlark_lib_suffix but was : bazel-out/k8-fastbuild/bin/third_party/bar/_virtual_includes/starlark_lib at com.google.devtools.build.lib.rules.cpp.StarlarkCcCommonTest.testStripIncludePrefixIncludePath(StarlarkCcCommonTest.java:5902) FAILURES!!! Tests run: 73, Failures: 1 ``` The change in behaviour was introduced in 7e0df68#diff-403c46ec3075b8e9e6d490ce955db88dae2d457b8046608884039b18b10ab6ccR774 Fixes: #23061 Closes #23071. PiperOrigin-RevId: 660681269 Change-Id: Ia3f8a8a6cf8bf0e093416a247e348e6de6719584 Closes #23221 Co-authored-by: FaBrand <[email protected]>
A fix for this issue has been included in Bazel 7.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. |
Conditions
The bug occurs when compling sources using the starlark api cc_common.compile under the following conditions:
name
argument set to a different value than whatctx.label.name
returnsstrip_include_prefix
is set to the common prefix of thepublic_hdrs
The artifact path for the virtual includes changed, but the created
-I
nclude remained the same7.2.1
-I
nclude points to ctx.label.name path_virtual_include
uses thename
passed to .compile6.2.1
-I
nclude points to ctx.label.name path_virtual_include
uses the ctx.label.nameError Case
The include paths include
-Ibazel-out/k8-fastbuild/bin/_virtual_includes/with_other_name
. This points to the_virtual_includes
created for the target name.However the files that are stripped are created in a different path, the one containing the
name
that is passed to.compile(name = "other_name")
$ tree bazel-bin bazel-bin ├── libother_name.a-2.params ├── libother_name.so-2.params ├── _objs │ └── other_name └── _virtual_includes └── other_name └── simple_header.h -> /home/user/github/bazel-cc-common-compile-api/v1/simple_header.h
Good Case in bazel 6.2.1
In this case the directory created below virtual_includes matches the label name
Conclusion
The created
_virtual_includes/<name>
does not match with the created include path anymore.It seems to me this was "incorrect" before, aka still consistent but probably not desired like this.
It now partly changed with 7e0df68 and is now inconsistent
Which category does this issue belong to?
C++ Rules
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
git clone https://github.com/FaBrand/bazel-cc-common-compile-api repro cd repro USE_BAZEL_VERSION=7.2.1 bazel build with_other_name
Which operating system are you running Bazel on?
Linux/Windows
What is the output of
bazel info release
?What's the output of
git remote get-url origin; git rev-parse HEAD
?If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
Have you found anything relevant by searching the web?
I found a few changes related to _virtual_includes, but none for this specific result
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: