Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

aclements opened this issue Oct 17, 2017 · 2 comments

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

aclements opened this issue Oct 17, 2017 · 2 comments


Copy link

@aclements aclements commented Oct 17, 2017

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

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Mar 29, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jun 23, 2018
Copy link

@ianlancetaylor ianlancetaylor commented Dec 7, 2018

@ianlancetaylor ianlancetaylor modified the milestones: Go1.12, Go1.13 Dec 7, 2018
Copy link

@heschik heschik commented Dec 7, 2018

Oh, this is an old bug. It's hardcoded to . now.

func getCompilationDir() string {

@heschik heschik closed this Dec 7, 2018
@golang golang locked and limited conversation to collaborators Dec 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.