From b34d670722191c03f529fc943f006f6e2e8884fe Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 19 Feb 2016 10:28:10 +0100 Subject: csource: use dynamic libraries if static are not supported Fixes #20 --- csource/csource.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'csource') 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) -- cgit mrf-deployment