Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit fde9f20

Browse files
committed
Merging r325946:
------------------------------------------------------------------------ r325946 | echristo | 2018-02-23 21:12:24 +0100 (Fri, 23 Feb 2018) | 15 lines Because of CVE-2018-6574, some compiler options and linker options are restricted to prevent arbitrary code execution. golang/go#23672 By this change, building a Go code with LLVM Go bindings causes a compilation error as follows. go build llvm.org/llvm/bindings/go/llvm: invalid flag in #cgo LDFLAGS: -Wl,-headerpad_max_install_names llvm-go tool generates cgo LDFLAGS directive from `llvm-config --ldflags` and it contains -Wl,option options. But -Wl,option is banned by default. To avoid this problem, we need to set $CGO_LDFLAGS_ALLOW environment variable to notify a compiler that the flags should be allowed. $ export CGO_LDFLAGS_ALLOW='-Wl,(-search_paths_first|-headerpad_max_install_names)' By default for go 1.10 and go 1.9.5 these options should appear in the accepted set of options, however, if you're running into the error it's useful to have this documented. Patch by Ryuichi Hayashida ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@326076 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c93e390 commit fde9f20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bindings/go/README.txt

+8
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ CGO_CPPFLAGS, CGO_CXXFLAGS and CGO_LDFLAGS environment variables:
5151
$ export CGO_CXXFLAGS=-std=c++11
5252
$ export CGO_LDFLAGS="`/path/to/llvm-build/bin/llvm-config --ldflags --libs --system-libs all`"
5353
$ go build -tags byollvm
54+
55+
If you see a compilation error while compiling your code with Go 1.9.4 or later as follows,
56+
57+
go build llvm.org/llvm/bindings/go/llvm: invalid flag in #cgo LDFLAGS: -Wl,-headerpad_max_install_names
58+
59+
you need to setup $CGO_LDFLAGS_ALLOW to allow a compiler to specify some linker options:
60+
61+
$ export CGO_LDFLAGS_ALLOW='-Wl,(-search_paths_first|-headerpad_max_install_names)'

0 commit comments

Comments
 (0)