Implement interface shared objects to avoid re-linking
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description:
As discussed on [this thread](https://groups.google.com/d/msg/bazel-discuss/8Wt3l9zfksY/E0HJNnWECwAJ), any changes to c++ sources or headers will trigger relinking of dynamically linked binaries. Bazel supports the concept of "interface shared objects", (*.ifso files), to separate the implementation from the interface, thus limiting the need to re-link for source-only changes. However, Google's current implementation of a tool that can create ifso files is not public.
This ticket is a request for a public implementation of an ifso tool. This is a non-trivial performance boost for users of dynamic linking. One compelling use case is for dynamically-linked unit test suites, where many linking tasks might be avoided.
### If possible, provide a minimal example to reproduce the problem:
To demonstrate this behavior, we can use the cpp-tutorial/stage2 hello-world application in the bazel tutorials: https://github.com/bazelbuild/examples/
Make the binary dynamic by adding "linkstatic=0" to the cc_binary rule. Change the string in hello-greet.cc, and the binary will re-link upon building //main:hello-world.
Subcommands show:
```
SUBCOMMAND: # //main:hello-greet [action 'Compiling main/hello-greet.cc']
SUBCOMMAND: # //main:hello-greet [action 'Linking main/libhello-greet.so']
SUBCOMMAND: # //main:hello-world [action 'Linking main/hello-world']
```
Explanations of rebuilds show:
```
Executing action 'BazelWorkspaceStatusAction stable-status.txt': unconditional execution is requested.
Executing action 'Compiling main/hello-greet.cc': One of the files has changed.
Executing action 'Linking main/libhello-greet.so': One of the files has changed.
Executing action 'SolibSymlink _solib_k8/libmain_Slibhello-greet.so': One of the files has changed.
Executing action 'Linking main/hello-world': One of the files has changed.
```
Since hello-greet.h wasn't changed, I think chain should have been able to stop after re-linking the shared library.
* Bazel version (output of `bazel info release`):
0.7.0
### Have you found anything relevant by searching the web?
There do not appear to be other issues on this topic.
Contributor guide
Research direction
Start with the cpp-tutorial/stage2 hello-world example and make the cc_binary dynamic with linkstatic=0. Reproduce the rebuild using the listed subcommands, focusing on hello-greet.cc, hello-greet.h, libhello-greet.so, and hello-world. Done means a public ifso implementation prevents relinking hello-world when only hello-greet.cc changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100