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

go/build: sourcehut requires characters considered unsafe for cgo names #32260

ddevault opened this issue May 26, 2019 · 1 comment


None yet
4 participants
Copy link

commented May 26, 2019

build.go has a set of safe characters which can be present in CFLAGS:


Lines 1553 to 1559 in c290cb6

// NOTE: $ is not safe for the shell, but it is allowed here because of linker options like -Wl,$ORIGIN.
// We never pass these arguments to a shell (just to programs we construct argv for), so this should be okay.
// See
// The @ is for OS X. See
// The % is for Jenkins. See
// The ! is because module paths may use them. See
const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! "

Sourcehut packages always have ~ in the URL, and in the future will likely have ^ as well. Importing a package from which uses ${SRCDIR} in its CFLAGS accordingly causes this error:

widgets/terminal.go:11:2: /home/sircmpwn/.local/share/go/pkg/mod/ malformed #cgo argument: -I/home/sircmpwn/.local/share/go/pkg/mod/

~ has a special meaning in the shell, but it is URL safe and, per the comments in build.go, this string is never expanded with a shell.

EDIT: added permalink


This comment has been minimized.

Copy link

commented May 26, 2019

@ianlancetaylor ianlancetaylor changed the title cgo can fail when used with packages on sourcehut due to unsafe characters go/build: sourcehut requires characters considered unsafe for cgo names May 27, 2019

@ianlancetaylor ianlancetaylor added this to the Go1.13 milestone May 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.