aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-05-21 07:14:39 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-05-21 09:32:43 +0000
commita38fb99b3fbff0c988e64bf4bf277071e18b18af (patch)
tree1497a8c5077b5b07f230a6adf0842fd717b6d15c /pkg
parent98aa8d464020910064d862eff99440bfdf0dc03c (diff)
Makefile: build executor with C++ compiler
Add C++ compiler and flags to the target and build executor with the C++ compiler. This will be needed to merge syz-fuzzer in to syz-executor since it will be beefier and will most likely require linking in libc++. But also this should fix #4821 since we won't use C++ flags when building C sources (we already had work-around in pkg/csource, but not in syz-extract). Fixes #4821
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/build.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/csource/build.go b/pkg/csource/build.go
index 5dd1234a7..0625e9a03 100644
--- a/pkg/csource/build.go
+++ b/pkg/csource/build.go
@@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
"runtime"
- "slices"
"strings"
"testing"
@@ -46,8 +45,6 @@ func BuildExecutor(t *testing.T, target *prog.Target, rootDir string, cflags ...
}
func build(target *prog.Target, src []byte, dir, file string, cflags ...string) (string, error) {
- sysTarget := targets.Get(target.OS, target.Arch)
- compiler := sysTarget.CCompiler
// We call the binary syz-executor because it sometimes shows in bug titles,
// and we don't want 2 different bugs for when a crash is triggered during fuzzing and during repro.
bin, err := osutil.TempFile("syz-executor")
@@ -66,18 +63,17 @@ func build(target *prog.Target, src []byte, dir, file string, cflags ...string)
} else {
flags = append(flags, file)
}
- flags = append(flags, sysTarget.CFlags...)
+ sysTarget := targets.Get(target.OS, target.Arch)
+ compiler, targetCFlags := sysTarget.CCompiler, sysTarget.CFlags
+ if file != "" && !strings.HasSuffix(file, ".c") {
+ compiler, targetCFlags = sysTarget.CxxCompiler, sysTarget.CxxFlags
+ }
+ flags = append(flags, targetCFlags...)
+ flags = append(flags, cflags...)
if sysTarget.PtrSize == 4 {
// We do generate uint64's for syscall arguments that overflow longs on 32-bit archs.
flags = append(flags, "-Wno-overflow")
}
- flags = append(flags, cflags...)
- if file == "" || strings.HasSuffix(file, ".c") {
- // Building C source, so remove C++ flags.
- flags = slices.DeleteFunc(flags, func(flag string) bool {
- return strings.HasPrefix(flag, "-std=c++")
- })
- }
cmd := osutil.Command(compiler, flags...)
cmd.Dir = dir
if file == "" {