diff options
author | Andrew Wilkins <axwalk@gmail.com> | 2016-01-20 04:03:09 +0000 |
---|---|---|
committer | Andrew Wilkins <axwalk@gmail.com> | 2016-01-20 04:03:09 +0000 |
commit | 93083d498658f4c6da98e8950bd9f58c76080299 (patch) | |
tree | 02900f2aa12bbfde92af909c0b510e74aa144518 /tools/llvm-go | |
parent | 6e2f199988e7e89fb572a339247e6651d41272b4 (diff) |
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-go')
-rw-r--r-- | tools/llvm-go/llvm-go.go | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/tools/llvm-go/llvm-go.go b/tools/llvm-go/llvm-go.go index ed79ca67b89..d0f794177bb 100644 --- a/tools/llvm-go/llvm-go.go +++ b/tools/llvm-go/llvm-go.go @@ -88,17 +88,8 @@ func llvmConfig(args ...string) string { return outstr } -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") +func llvmFlags() compilerFlags { + ldflags := llvmConfig("--ldflags", "--libs", "--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 @@ -133,8 +124,8 @@ func printComponents() { fmt.Println(strings.Join(components, " ")) } -func printConfig(linkmode string) { - flags := llvmFlags(linkmode) +func printConfig() { + flags := llvmFlags() fmt.Printf(`// +build !byollvm @@ -153,7 +144,7 @@ type (run_build_sh int) `, flags.cpp, flags.cxx, flags.ld) } -func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags, linkmode string) { +func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags string) { args = addTag(args, "byollvm") srcdir := llvmConfig("--src-root") @@ -182,7 +173,7 @@ func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, l newgopathlist = append(newgopathlist, filepath.SplitList(os.Getenv("GOPATH"))...) newgopath := strings.Join(newgopathlist, string(filepath.ListSeparator)) - flags := llvmFlags(linkmode) + flags := llvmFlags() newenv := []string{ "CC=" + cc, @@ -250,7 +241,6 @@ func main() { ldflags := os.Getenv("CGO_LDFLAGS") gocmd := "go" llgo := "" - linkmode := linkmodeComponentLibs flags := []struct { name string @@ -262,7 +252,6 @@ func main() { {"llgo", &llgo}, {"cppflags", &cppflags}, {"ldflags", &ldflags}, - {"linkmode", &linkmode}, } args := os.Args[1:] @@ -283,11 +272,11 @@ LOOP: switch args[0] { case "build", "get", "install", "run", "test": - runGoWithLLVMEnv(args, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags, linkmode) + runGoWithLLVMEnv(args, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags) case "print-components": printComponents() case "print-config": - printConfig(linkmode) + printConfig() default: usage() } |