-
Notifications
You must be signed in to change notification settings - Fork 248
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
cmake: file installed from the source directory are only symlinked #1129
Comments
See also bazelbuild/bazel#10299 |
This is likely the issue I was seeing here: https://bazelbuild.slack.com/archives/CGA9QFQ8H/p1701343519010999 |
for those that get here and aren't on the bazel slack, the temporary workaround is the flag |
There are two workarounds we tested:
Solution 2. Could also be implemented natively by |
if feedback from the peanut gallery is welcome, option 2 seems like the option least-likely to have baffling corner cases. we're already doing a bunch of backbends with rules_foreign_cc involving multiple cmake projects reading config from each other, so any straightforward patching approach probably wouldn't work for our admittedly goofy usage. |
bazelbuild/bazel#20603 - this may fix this issue too |
@jsharpe It does not fix the issue for me. The same error happens and the same sandbox-relative symlink appears in the cache. |
for the record, the slightly less scary |
that has the same effect as |
Possibly this'll fix this issue, and is marked for 7.1: bazelbuild/bazel#21215 |
For the record,
worked for me on Bazel 7, while (presumably) still preserving the hermetic tmp directory which is necessary for us to address occasional hotspot crashes during Java compilations. |
Speaking of the second workaround, I thought I may provide the current implementation I'm using, in case someone needs it. # Just add the 'postfix_script' to ensure that symbolic links are copied from the original files, removing the dangling problem
cmake(
name = "external_lib",
lib_source = ":all_srcs",
# ...
postfix_script = """find $INSTALLDIR -type l -exec sh -c 'for i in "$@"; do cp --preserve --remove-destination "$(readlink -f "$i")" "$i"; done' sh {} +""",
)
filegroup(
name = "all_srcs",
srcs = glob(["**"], exclude = ["bazel-*"]),
) I am not an expert, and there may be some good reasons not to do so, but you may want to consider whether to add such a line directly into the official script |
When using
cmake()
together with Bazel 7.0 with exported headers the build fails.And indeed the installed header file is a symlink:
$ ls -l /home/me/.cache/bazel/_bazel_me/691c198c0f7498b76c679347f393fea9/execroot/_main/bazel-out/k8-fastbuild/bin/cmake_hello_world_ lib/shared/libhello/include/hello.h lrwxrwxrwx 1 me me 66 Dec 11 16:57 /home/me/.cache/bazel/_bazel_tweisssc/691c198c0f7498b76c679347f393fea9/execroot/_main/bazel-out/k8-fastbuild/bin/cmake_hello_world_lib/shared/libhello/include/hello.h -> /tmp/bazel-source-roots/0/cmake_hello_world_lib/shared/src/hello.h
The problem is that cmake will preserve symlinks when installing them instead of resolving them to the contents (see
cmFileCopier::Install()
).cmake() with filegroup() symlinks all the sources into the internal build tree, leading for example headers from the source tree to be also installed as (broken) symlink.
The text was updated successfully, but these errors were encountered: