diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-03-21 13:22:07 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-03-21 13:30:12 +0100 |
| commit | e6d1a816d8ee66336ab745bd1e99c8d231bcf10c (patch) | |
| tree | 80304acbde704e680eaa5556073c4177ad753fad /pkg | |
| parent | 44270612b458144e4c3e881bac376d32bb395ee8 (diff) | |
pkg/csource: allow to ignore warnings during build
Running bisection using an older repro failed with:
<stdin>: In function ‘syz_mount_image.constprop’:
<stdin>:298:3: error: argument 1 null where non-null expected [-Werror=nonnull]
In file included from <stdin>:26:0:
/usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here
extern int mkdir (const char *__path, __mode_t __mode)
Let's be safe and ignore warnings during repro/bisect.
Everything that runs during tests still has all warnings.
Update #501
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/csource/build.go | 17 | ||||
| -rw-r--r-- | pkg/instance/instance.go | 2 | ||||
| -rw-r--r-- | pkg/repro/repro.go | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/pkg/csource/build.go b/pkg/csource/build.go index 35ac28e83..56d5487a8 100644 --- a/pkg/csource/build.go +++ b/pkg/csource/build.go @@ -18,15 +18,23 @@ import ( // Build builds a C program from source src and returns name of the resulting binary. func Build(target *prog.Target, src []byte) (string, error) { - return build(target, src, "") + return build(target, src, "", true) +} + +// BuildNoWarn is the same as Build, but ignores all compilation warnings. +// Should not be used in tests, but may be used e.g. when we are bisecting and potentially +// using an old repro with newer compiler, or a compiler that we never seen before. +// In these cases it's more important to build successfully. +func BuildNoWarn(target *prog.Target, src []byte) (string, error) { + return build(target, src, "", false) } // BuildFile builds a C/C++ program from file src and returns name of the resulting binary. func BuildFile(target *prog.Target, src string) (string, error) { - return build(target, nil, src) + return build(target, nil, src, true) } -func build(target *prog.Target, src []byte, file string) (string, error) { +func build(target *prog.Target, src []byte, file string, warn bool) (string, error) { sysTarget := targets.Get(target.OS, target.Arch) compiler := sysTarget.CCompiler if _, err := exec.LookPath(compiler); err != nil { @@ -55,6 +63,9 @@ func build(target *prog.Target, src []byte, file string) (string, error) { // We do generate uint64's for syscall arguments that overflow longs on 32-bit archs. flags = append(flags, "-Wno-overflow") } + if !warn { + flags = append(flags, "-fpermissive", "-w") + } cmd := osutil.Command(compiler, flags...) if file == "" { cmd.Stdin = bytes.NewReader(src) diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index ac553c2b9..7df34d191 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -342,7 +342,7 @@ func (inst *inst) testRepro() error { if err != nil { return err } - bin, err := csource.Build(target, inst.reproC) + bin, err := csource.BuildNoWarn(target, inst.reproC) if err != nil { return err } diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go index 2c6a0e6ed..7aafdde31 100644 --- a/pkg/repro/repro.go +++ b/pkg/repro/repro.go @@ -556,7 +556,7 @@ func (ctx *context) testCProg(p *prog.Prog, duration time.Duration, opts csource if err != nil { return false, err } - bin, err := csource.Build(p.Target, src) + bin, err := csource.BuildNoWarn(p.Target, src) if err != nil { return false, err } |
