Brightspace / rules_csharp

Bazel rules for C#
Apache License 2.0
8 stars 5 forks source link

Use pathmap for cross-machine determinism #13

Open j3parker opened 4 years ago

j3parker commented 4 years ago

This is at least required for PDBs, as documented here but I also noticed absolute paths in our DLLs.

We can't trivially do this in Bazel. We need to figure out all of our command line flags during the analysis phase, which doesn't (afaik) know where the build will actually execute (it could be on a remote machine, and analysis also gets cached) so we can't know what paths to map.

We could wrap the compiler to inject this argument at runtime.

We're talking about adding a wrapper already in #12, but I have some concerns. That thing itself needs to be compiled, and probably also needs pathmap to be deterministic, so we've got an even worse chicken and egg problem. Maybe when we compile the wrapper we need a small C program to inject this argument?

I think we need to be flexible and experiment to find out what will work best. The experiments should look at how local and remote caching behave.

j3parker commented 4 years ago

I did some digging on MacOS and this is what I found:

We're going to need to paths mapped (either with /pathmap:{x}={y},{a}={b} or with two /pathmap args) to get full reproducibility.

  1. It seems we need to path map the real dir containing WORKSPACE to something stable. This gets deterministic PDBs, which is good but not mission-critical (for D2L). We mightttt be able to figure that out in csharp_repositories but then that also might not work the same for remote builds. Needs investigation.
  2. Some path related to exec/the output root gets embedded into DLLs. This is very important for our caching story. I don't have the full details right now. Bazel likes to have lots of symlinks, so it's a bit of investigation to figure out what we should do here. This also might be different in remote builds.

So we still want to have a wrapper to do the injections as far as I can tell, but it's still a bit of work to figure out what they should be.