Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-static should not be used for build #20

Closed
jirislaby opened this issue Feb 18, 2016 · 4 comments
Closed

-static should not be used for build #20

jirislaby opened this issue Feb 18, 2016 · 4 comments

Comments

@jirislaby
Copy link

The syz-repro tries to build with -static (csource/csource.go: Build), but this does not work on openSUSE, as we do not have static libraries. -static should be configurable at least.

@dvyukov
Copy link
Collaborator

dvyukov commented Feb 18, 2016

It is configurable already. But maybe you won't like the default :)

NOSTATIC ?= 0
ifeq ($(NOSTATIC), 0)
        STATIC_FLAG=-static
endif

executor:
        $(CC) -o ./bin/syz-executor executor/executor.cc -pthread -Wall -O1 -g $(STATIC_FLAG) $(CFLAGS)

@dvyukov
Copy link
Collaborator

dvyukov commented Feb 18, 2016

Ah, you mean csource/csource.go...

@dvyukov
Copy link
Collaborator

dvyukov commented Feb 18, 2016

Will something like this work for you?

--- 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)

@jirislaby
Copy link
Author

Yes, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants