diff options
| author | Teddy Wing | 2020-03-10 23:44:32 +0100 |
|---|---|---|
| committer | Teddy Wing | 2020-03-11 00:41:34 +0100 |
| commit | 428fb6dcab1377dd887d65eb2a496f6d5bbe1b6c (patch) | |
| tree | 8a49ff14471a8678e552710e833230ab5ee7880a | |
| parent | 17405ab3fd75474562f921a58715a50ca28f1b5a (diff) | |
| download | go-notifier-428fb6dcab1377dd887d65eb2a496f6d5bbe1b6c.tar.bz2 | |
Fix `-sectcreate` LDFLAGS error when building on Go >= 1.10
I was trying to build the project and ended up with this error:
$ go get
go build github.com/keybase/go-notifier: invalid flag in #cgo LDFLAGS: -sectcreate
Found this issue https://github.com/golang/go/issues/23937 related to Go
1.10 that describes compiler flags as needing to be whitelisted for
security.
> Options specified by cgo using #cgo CFLAGS and the like are now
> checked against a whitelist of permitted options. This closes a
> security hole in which a downloaded package uses compiler options like
> -fplugin to run arbitrary code on the machine where it is being built.
> This can cause a build error such as invalid flag in #cgo CFLAGS.
https://tip.golang.org/doc/go1.10#cgo
https://github.com/golang/go/wiki/InvalidFlag
The `-sectcreate` flag is included in the whitelist:
re(`-Wl,-sectcreate,([^,@\-][^,]+),([^,@\-][^,]+),([^,@\-][^,]+)`),
https://github.com/golang/go/commit/eef2fd28ca7023be3a3f1c62039c2643bffac948#diff-4edde0d5efc092a14e579fd0de312bdeR149
However, the format is different from before. The linker flag arguments
must now be comma-separated, and prefixed with `-Wl,`.
Fixes #3.
| -rw-r--r-- | notifier_darwin.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/notifier_darwin.go b/notifier_darwin.go index d69a89c..e6f9c07 100644 --- a/notifier_darwin.go +++ b/notifier_darwin.go @@ -5,7 +5,7 @@ package notifier /* #cgo CFLAGS: -x objective-c -#cgo LDFLAGS: -framework Cocoa -sectcreate __TEXT __info_plist Info.plist +#cgo LDFLAGS: -framework Cocoa -Wl,-sectcreate,__TEXT,__info_plist,Info.plist #import <Cocoa/Cocoa.h> extern CFStringRef deliverNotification(CFStringRef title, CFStringRef subtitle, CFStringRef message, CFStringRef appIconURLString, CFArrayRef actions, CFStringRef groupID, CFStringRef bundleID, NSTimeInterval timeout, bool debug); */ |
