Skip to content

Commit a9573be

Browse files
lberkicopybara-github
authored andcommitted
Add comments about "native deps".
RELNOTES: None. PiperOrigin-RevId: 413663203
1 parent 40c69ed commit a9573be

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,19 @@ public static NativeDepsRunfiles createNativeDepsAction(
293293
}
294294

295295
/**
296-
* Returns the path of the shared native library. The name must be generated based on the
296+
* This method facilitates sharing C++ linking between multiple test binaries.
297+
*
298+
* <p>The theory is that since there are generally multiple test rules that test similar
299+
* functionality, their native dependencies must be exactly the same and therefore running C++
300+
* linking for each binary is wasteful.
301+
*
302+
* <p>The way this method gets around that is by computing a file name that depends on the
303+
* contents of the eventual shared library (but not on the rule it is generated for). Test actions
304+
* put their native dependencies at this place, so if multiple test rules have the same
305+
* dependencies it will be a shared action and therefore be executed only once instead of once per
306+
* test rule.
307+
*
308+
* <p>Returns the path of the shared native library. The name must be generated based on the
297309
* rule-specific inputs to the link actions. At this point this includes order-sensitive list of
298310
* linker inputs and options collected from the transitive closure and linkstamp-related artifacts
299311
* that are compiled during linking. All those inputs can be affected by modifying target

0 commit comments

Comments
 (0)