Closed Bug 1524662 Opened 5 years ago Closed 3 years ago

Support gcc/clang-like build path prefix map in generated code

Categories

(Firefox Build System :: General, enhancement)

enhancement
Not set
normal

Tracking

(firefox91 fixed)

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: nalexander, Assigned: nalexander)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file, 3 obsolete files)

This ticket tracks substituting sentinels like "{topsrcdir}" and "{topobjdir}" into generated code in our build system.

The motivation is to achieve sccache hits across source and object directories by reducing "pointless" changes; it's part of the programme of using -fdebug-prefix-map, etc and similar flags to achieve reproducible builds. However this isn't really necessary for reproducible builds, since those tend to assume a fixed toolchain and filesystem, but it doesn't hurt.

In particular, we embed full paths into preprocessed sources and into generated XPIDL sources. We can stop doing that pretty cheaply!

The new option can be set in mozconfig files. It defaults to mapping
the objdir to "/topobjdir/" (or, on Windows, "c:\topobjdir", with the
same drive letter as the original objdir) and the srcdir to
"/topsrcdir/" (or "c:\topsrcdir", again with the same drive letter).

This should improve (s)ccache hits between object directories.

Depends on D18382

ted, dmajor: this is what I was talking about in #build today. I'm not sure it's relevant, but maybe it is?

The next step in this process would be to pass -fdebug-prefix-map=... to relevant compilers and then to update .{gdb,lldb}init scripts to do the unmapping.

Flags: needinfo?(ted)
Flags: needinfo?(dmajor)

Neat! I think the specific case that I was investigating was fixed by merely the -EP switch, but the prefix map sounds like it could bring even more cache hits on top of that.

Flags: needinfo?(dmajor)

So part 1 looks totally reasonable. I'm less sure about part 2--where are we outputting file names in Preprocessor.py output currently? As dmajor mentioned sccache will use -EP when running the preprocessor internally, which leaves out the file markers that would normally cause preprocessor output to be different between different srcdirs.

Flags: needinfo?(ted)
Attachment #9040800 - Attachment is obsolete: true
Attachment #9040802 - Attachment is obsolete: true

For "c" (i.e., gcc, clang, and clang-cl), this configures the
-f{debug,macro}-path-prefix flags. We'd prefer to use
-ffile-path-prefix, but it seems that clang-cl does not recognize
that flag.

For "rust" (i.e., rustc/cargo), this configures --remap-path-prefix.

This is one step toward getting sccache hits across source and
object directories.

Assignee: nobody → nalexander
Status: NEW → ASSIGNED

The big win with the patch I've just submitted is that __FILE__ macros no longer embed build environment-specific paths, opening the possibility for cross source directory sccache hits. Actually realizing those sccache hits can take some work, though; I'm hoping to push on this more in the near future.

Blocks: 1714209
Attachment #9225974 - Attachment is obsolete: true
Pushed by nalexander@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7780b7c82d22
Add --enable-path-remapping producing compiled objects with generic paths. r=glandium
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Blocks: 1742885
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: