Skip to content

cmd/link: records absolute working directory in binary #22311

@aclements

Description

@aclements

The linker records the result of os.Getwd() in the DWARF compilation unit's DW_AT_comp_dir attribute. This is almost certainly wrong since we've been working to keep information like this out of the binary (for example, it's not affected by -trimpath). It's also additionally wrong because it records the linker's working directory, where it's supposed to record the compiler's working directory [1].

It would be nice if we could just omit it, but there's a comment in writelines that says "OS X linker requires compilation dir or absolute path in comp unit name to output debug info." We could perhaps always make the value "/". Or perhaps we could use the package's source directory (with -trimpath applied).

[1] DWARF4: A DW_AT_comp_dir attribute whose value is a null-terminated string containing the current
working directory of the compilation command that produced this compilation unit in
whatever form makes sense for the host system. See also @thanm's comment.

/cc @rsc @thanm

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggingFrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions