You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Dominic Della Valle\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Dominic Della Valle\Projects\Go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\DOMINI~1\AppData\Local\Temp\go-build550192770=/tmp/go-build -gno-record-gcc-switches
What did you do?
Tried stripping path prefix during build with a path containing whitespace on Windows. C:\Users\Dominic Della Valle\Projects\Go\src\local\hello>go build -asmflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello" -gcflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello"
What did you expect to see?
Successful build.
What did you see instead?
C:\Users\Dominic Della Valle\Projects\Go\src\local\hello>go build -asmflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello" -gcflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello"
# unicode/utf8
Della:0: open Della: The system cannot find the file specified.
# runtime/internal/sys
Della:0: open Della: The system cannot find the file specified.
# internal/race
Della:0: open Della: The system cannot find the file specified.
# errors
Della:0: open Della: The system cannot find the file specified.
# unicode/utf16
Della:0: open Della: The system cannot find the file specified.
# unicode
Della:0: open Della: The system cannot find the file specified.
# internal/syscall/windows/sysdll
Della:0: open Della: The system cannot find the file specified.
# math/bits
Della:0: open Della: The system cannot find the file specified.
# 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
-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
-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
# 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
-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
Moving the package to a path that doesn't contain whitespace, and changing the trimpath argument to match, results in a successful build with stripped paths.
It seems like it's trying to pass the words after the space, as arguments to the assembler/compiler.
contents of hello/main.go is just hello world:
package main
import"fmt"funcmain() {
fmt.Println("Hello")
}
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
cmd/build: trimpath containing whitespace fails on Windows
cmd/go: trimpath containing whitespace fails on Windows
Jul 22, 2019
ianlancetaylor
changed the title
cmd/go: trimpath containing whitespace fails on Windows
cmd/go: -trimpath option fails if it contains whitespace
Jul 22, 2019
Here the Unix shell will remove the outer " characters, and pass
-gcflags=all='-trimpath=a b'
to cmd/go. That quoting style will work for cmd/go to do the right thing when invoking the other tools. Basically you have to quote the entire argument to -gcflags=all=, not just the -trimpath argument.
I can properly pass the arguments to the assembler/compiler in the cmd interpreter if I quote paths as such (there may be a more concise manner): go build -asmflags=all='-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello"' -gcflags=all='-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello"'
More generally
in cmd -asmflags=all='-trimpath="%PREFIX%"' -gcflags=all='-trimpath="%PREFIX%"'
in make GOFLAGS += "-asmflags=all='-trimpath=$(PREFIX)'" "-gcflags=all='-trimpath=$(PREFIX)'"
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried stripping path prefix during build with a path containing whitespace on Windows.
C:\Users\Dominic Della Valle\Projects\Go\src\local\hello>go build -asmflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello" -gcflags=all=-trimpath="C:\Users\Dominic Della Valle\Projects\Go\src\local\hello"
What did you expect to see?
Successful build.
What did you see instead?
Moving the package to a path that doesn't contain whitespace, and changing the trimpath argument to match, results in a successful build with stripped paths.
It seems like it's trying to pass the words after the space, as arguments to the assembler/compiler.
contents of
hello/main.go
is just hello world:The text was updated successfully, but these errors were encountered: