Revert r257003
This revision breaks llvm-config if you set
BUILD_SHARED_LIBS=on in a CMake build. Backing
out until the fix is ready to land.
llvm-svn: 257457
diff --git a/llvm/tools/llvm-go/llvm-go.go b/llvm/tools/llvm-go/llvm-go.go
index d0f7941..ed79ca6 100644
--- a/llvm/tools/llvm-go/llvm-go.go
+++ b/llvm/tools/llvm-go/llvm-go.go
@@ -88,8 +88,17 @@
return outstr
}
-func llvmFlags() compilerFlags {
- ldflags := llvmConfig("--ldflags", "--libs", "--system-libs")
+func llvmFlags(linkmode string) compilerFlags {
+ ldflags := llvmConfig("--ldflags")
+ switch linkmode {
+ case linkmodeComponentLibs:
+ ldflags += " " + llvmConfig(append([]string{"--libs"}, components...)...)
+ case linkmodeDylib:
+ ldflags += " -lLLVM"
+ default:
+ panic("invalid linkmode: " + linkmode)
+ }
+ ldflags += " " + llvmConfig("--system-libs")
if runtime.GOOS != "darwin" {
// OS X doesn't like -rpath with cgo. See:
// https://code.google.com/p/go/issues/detail?id=7293
@@ -124,8 +133,8 @@
fmt.Println(strings.Join(components, " "))
}
-func printConfig() {
- flags := llvmFlags()
+func printConfig(linkmode string) {
+ flags := llvmFlags(linkmode)
fmt.Printf(`// +build !byollvm
@@ -144,7 +153,7 @@
`, flags.cpp, flags.cxx, flags.ld)
}
-func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags string) {
+func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags, linkmode string) {
args = addTag(args, "byollvm")
srcdir := llvmConfig("--src-root")
@@ -173,7 +182,7 @@
newgopathlist = append(newgopathlist, filepath.SplitList(os.Getenv("GOPATH"))...)
newgopath := strings.Join(newgopathlist, string(filepath.ListSeparator))
- flags := llvmFlags()
+ flags := llvmFlags(linkmode)
newenv := []string{
"CC=" + cc,
@@ -241,6 +250,7 @@
ldflags := os.Getenv("CGO_LDFLAGS")
gocmd := "go"
llgo := ""
+ linkmode := linkmodeComponentLibs
flags := []struct {
name string
@@ -252,6 +262,7 @@
{"llgo", &llgo},
{"cppflags", &cppflags},
{"ldflags", &ldflags},
+ {"linkmode", &linkmode},
}
args := os.Args[1:]
@@ -272,11 +283,11 @@
switch args[0] {
case "build", "get", "install", "run", "test":
- runGoWithLLVMEnv(args, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags)
+ runGoWithLLVMEnv(args, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags, linkmode)
case "print-components":
printComponents()
case "print-config":
- printConfig()
+ printConfig(linkmode)
default:
usage()
}