Skip to content

Current implementation of remap_path_prefix breaks debugging on macOS #3476

Open
@csmulhern

Description

@csmulhern

Using an empty string for remap_path_prefix breaks debug info on macOS. Remapping to empty string causes paths to become relative paths, which is not supported in all situations for all binary info on all platforms (e.g. OSO stabs in debug info on macOS). For more background on exactly how this breaks debug info, see rust-lang/rust#132143.

Default value for construct_arguments, see:

remap_path_prefix = "",

Remapping of pwd here:

rustc_flags.add("--remap-path-prefix=${{pwd}}={}".format(remap_path_prefix))

This can be fixed in rules_rust by not using an empty string for remapping here, at least on macOS, or for all platforms.

In terms of prior art here...

rules_swift uses . for remapping instead:

https://github.com/bazelbuild/rules_swift/blob/321bf2611163f562884545cbb7b183988bb4f367/swift/internal/feature_names.bzl#L62-L65

https://github.com/bazelbuild/rules_swift/blob/321bf2611163f562884545cbb7b183988bb4f367/tools/worker/swift_runner.cc#L293-L297

rules_go does as well:

https://github.com/bazel-contrib/rules_go/blob/1172e60b3fdb3c1b1f6efc781eda9819533375ac/go/tools/builders/cgo2.go#L330-L333

Bazel appears to use /proc/self/cwd at times, but outside of linux you need to manually remap this when debugging, with e.g.

(lldb) settings set target.source-map /proc/self/cwd <...>

Not sure which of these approaches would be best, or who would be the best to consult on this, but I think moving to one of the above is a good path forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions