aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-02-19 10:28:10 +0100
committerDmitry Vyukov <dvyukov@google.com>2016-02-19 10:28:34 +0100
commitb34d670722191c03f529fc943f006f6e2e8884fe (patch)
tree63f803a08bbd9375e0be1b9e84fc86a00448a915 /csource
parent862594f1b6b764f3149d90fcd8a83ddad6b7ee20 (diff)
csource: use dynamic libraries if static are not supported
Fixes #20
Diffstat (limited to 'csource')
-rw-r--r--csource/csource.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/csource/csource.go b/csource/csource.go
index d56735f2d..9640a9d46 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -199,7 +199,11 @@ func Build(src string) (string, error) {
return "", fmt.Errorf("failed to create temp file: %v", err)
}
bin.Close()
- out, err := exec.Command("gcc", "-x", "c++", "-std=gnu++11", src, "-o", bin.Name(), "-lpthread", "-static", "-O1", "-g").CombinedOutput()
+ out, err := exec.Command("gcc", "-x", "c++", "-std=gnu++11", src, "-o", bin.Name(), "-pthread", "-static", "-O1", "-g").CombinedOutput()
+ if err != nil {
+ // Some distributions don't have static libraries.
+ out, err = exec.Command("gcc", "-x", "c++", "-std=gnu++11", src, "-o", bin.Name(), "-pthread", "-O1", "-g").CombinedOutput()
+ }
if err != nil {
os.Remove(bin.Name())
data, _ := ioutil.ReadFile(src)