Page MenuHomeFreeBSD

Use -fdebug-prefix-map in the kernel build.
ClosedPublic

Authored by markj on Mar 19 2019, 2:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
May 21 2024, 8:18 AM
Unknown Object (File)
May 3 2024, 1:28 AM
Unknown Object (File)
May 3 2024, 1:25 AM
Unknown Object (File)
May 2 2024, 9:37 PM
Unknown Object (File)
Apr 24 2024, 9:21 AM
Unknown Object (File)
Apr 18 2024, 4:43 PM
Unknown Object (File)
Apr 17 2024, 6:42 PM
Unknown Object (File)
Mar 21 2024, 6:21 PM
Subscribers

Details

Summary

Our debug info currently contains a few magic paths that are
relative to the object directory. This confuses consumers of kernel
debug info, in particular, syzkaller's code coverage report generation.
In the past I used to frequently see kgdb complain about not being to
find headers under machine/.

clang and modern gcc support -fdebug-map-prefix=src=dst, which tells the
compiler to substitute dst for src in debug info when compiling files
whose path is prefixed by src. This helps with a couple of things:

  • The machine, x86 and MACHINE_CPUARCH symlinks. We can just map those to their canonical paths in the src tree, so e.g., machine/frame.h is translated to sys/amd64/include/frame.h.
  • Autogenerated headers, like vnode_if.h. We include them via a relative path (just "./") now, so substituting the object directory path gives a better chance of finding them.

TODO: add guards for gcc 4.2.

Test Plan

I verified that this works with in-tree clang and the amd64-gcc compiler from ports.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23200
Build 22243: arc lint + arc unit

Event Timeline

markj edited the summary of this revision. (Show Details)
markj edited the test plan for this revision. (Show Details)
markj added a subscriber: tuexen.

Ed pointed out that we may not want absolute paths in general. That's probably true, but I'll note that this change just makes things consistent for now. I think mapping the symlink paths is a no-brainer, at least.

Yes, as long as the main paths are absolute I think it's no worse to make these changes.

I'm not a huge fan of the OBJDIR one, but I don't see a better alternative. Definitely a fan of the symlink changes. Shame the code is duplicated in two places. It might make sense to have some kind of sys/conf/kern.common.mk or something that has shared logic between kmod.mk and kern.*.mk if that is feasible.

This revision is now accepted and ready to land.Mar 19 2019, 5:01 PM
  • Add compiler version guards.
This revision now requires review to proceed.Mar 20 2019, 1:03 AM
This revision is now accepted and ready to land.Mar 20 2019, 1:26 AM
This revision was automatically updated to reflect the committed changes.