bazel-contrib / bazel-contrib/rules_foreign_cc

Symlinking the sub directory should be disabled by default

Open
#1,284 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

As a regression of https://github.com/bazelbuild/rules_foreign_cc/pull/983, directories in a repository
is symlinked by default. This is IMO not the correct behaviour as it will cause the object file and target
file to generate in the original repsitory folder, if the build system is a simple `make` or `configure_make`
that generates file in place. The respository is supposed to not get changed after analysis phase otherwise
it's no longer hermetic.

Assume I have a project, in the repository, something like `execroot/_main/external/myrepo` in path:
```
src/
src/main.c
Makefile
```
After the mentioned PR, in `BUILD_TMPDIR` we will have (something like `external/myrepo/myproject.build_tmpdir` in path):
```
src@
Makefile
```

After this PR we end up writing `main.o` and `main` back to `execroot/_main/external/myrepo/src`.

This will further cause problem if a target are required to compile in both exec and target configuration,
a race condition will happen to create either artifacts with exec or target configuration, or fail the build
completely.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the symlink behavior introduced by pull request #983, focusing on the BUILD_TMPDIR layout and the configure_make or simple make path described here. Reproduce a build with both exec and target configurations, then verify that subdirectories are not symlinked by default and generated artifacts remain outside the repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.