-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
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.