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/go: provide example documentation for trimpath arguments with spaces #37815

Closed
siddharth178 opened this issue Mar 12, 2020 · 3 comments
Closed

Comments

@siddharth178
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.14 darwin/amd64

Does this issue reproduce with the latest release?

Yes. It is also reproducible on linux amd64.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/siddharth/Library/Caches/go-build"
GOENV="/Users/siddharth/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/siddharth/myprogs/gillnet/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jw/khwlx1jx0y9b2c8fgbt0pd5h0000gn/T/go-build199978540=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

[~/myprogs/test 1]$ ls
main.go
[~/myprogs/test 1]$ cat main.go
package main

import "fmt"

func main() {
	fmt.Println("hello!")
}

[~/myprogs/test 1]$ go build -asmflags="all=-trimpath=`pwd`"

What did you expect to see?

Successful build with given path references removed.

What did you see instead?

[~/myprogs/test 1]$ go build -asmflags="all=-trimpath=`pwd`"
# runtime/internal/atomic
usage: asm [options] file.s ...
Flags:
  -D value
    	predefined symbol with optional simple value -D=identifier=value; can be set multiple times
  -I value
    	include directory; can be set multiple times
  -S	print assembly and machine code
  -V	print version and exit
  -debug
    	dump instructions as they are parsed
  -dynlink
    	support references to Go symbols defined in other shared libraries
  -e	no limit on number of errors reported
  -gensymabis
    	write symbol ABI information to output file, don't assemble
  -newobj
    	use new object file format
  -o string
    	output file; default foo.o for /a/b/c/foo.s as first argument
  -shared
    	generate code that can be linked into a shared library
  -trimpath string
    	remove prefix from recorded source file paths
# internal/cpu
usage: asm [options] file.s ...
Flags:
  -D value
    	predefined symbol with optional simple value -D=identifier=value; can be set multiple times
  -I value
    	include directory; can be set multiple times
  -S	print assembly and machine code
  -V	print version and exit
  -debug
    	dump instructions as they are parsed
  -dynlink
    	support references to Go symbols defined in other shared libraries
  -e	no limit on number of errors reported
  -gensymabis
    	write symbol ABI information to output file, don't assemble
  -newobj
    	use new object file format
  -o string
    	output file; default foo.o for /a/b/c/foo.s as first argument
  -shared
    	generate code that can be linked into a shared library
  -trimpath string
    	remove prefix from recorded source file paths
# sync/atomic
usage: asm [options] file.s ...
Flags:
  -D value
    	predefined symbol with optional simple value -D=identifier=value; can be set multiple times
  -I value
    	include directory; can be set multiple times
  -S	print assembly and machine code
  -V	print version and exit
  -debug
    	dump instructions as they are parsed
  -dynlink
    	support references to Go symbols defined in other shared libraries
  -e	no limit on number of errors reported
  -gensymabis
    	write symbol ABI information to output file, don't assemble
  -newobj
    	use new object file format
  -o string
    	output file; default foo.o for /a/b/c/foo.s as first argument
  -shared
    	generate code that can be linked into a shared library
  -trimpath string
    	remove prefix from recorded source file paths
@toothrot
Copy link
Contributor

Have you tried the following:

go build "-asmflags=all='-trimpath=`pwd`'"

I believe the incorrect argument is being quoted here. I'm closing as a dup of #33223 (comment). Please comment if I am incorrect.

@siddharth178
Copy link
Author

Yeah @toothrot that works! 👍
I find it to be a little odd syntax and none of the documentation mentions that? Should we add?

@toothrot toothrot changed the title asmflags: trimpath doesn't work for paths with spaces in them cmd/go: provide example documentation for trimpath arguments with spaces Mar 13, 2020
@toothrot
Copy link
Contributor

@siddharth178 This is part of how Unix shells interpret quoted arguments, and not part of Go, so I would lean against providing specific documentation for that.

/cc @bcmills @jayconrod

@golang golang locked and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants