diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-05-21 07:14:39 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-05-21 09:32:43 +0000 |
| commit | a38fb99b3fbff0c988e64bf4bf277071e18b18af (patch) | |
| tree | 1497a8c5077b5b07f230a6adf0842fd717b6d15c /sys | |
| parent | 98aa8d464020910064d862eff99440bfdf0dc03c (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 'sys')
| -rw-r--r-- | sys/targets/targets.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 8a1b80f27..f5092b8c1 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -27,8 +27,10 @@ type Target struct { Int64Alignment uint64 LittleEndian bool CFlags []string + CxxFlags []string Triple string CCompiler string + CxxCompiler string Objdump string // name of objdump executable KernelCompiler string // override CC when running kernel make KernelLinker string // override LD when running kernel make @@ -584,9 +586,6 @@ var oses = map[string]osCommon{ var ( commonCFlags = []string{ - "-std=c++11", - "-I.", - "-Iexecutor/_include", "-O2", "-pthread", "-Wall", @@ -614,6 +613,13 @@ var ( fallbackCFlags = map[string]string{ "-static-pie": "-static", // if an ASLR static binary is impossible, build just a static one } + // These are used only when building executor. + // For C repros and syz-extract, we build C source files. + commonCxxFlags = []string{ + "-std=c++14", + "-I.", + "-Iexecutor/_include", + } ) func fuchsiaCFlags(arch, clangArch string) []string { @@ -646,9 +652,6 @@ func init() { } arch32, arch64 := splitArch(runtime.GOARCH) goos := runtime.GOOS - if goos == "android" { - goos = Linux - } for _, target := range List[TestOS] { if List[goos] == nil { continue @@ -662,6 +665,7 @@ func init() { continue } target.CCompiler = host.CCompiler + target.CxxCompiler = host.CxxCompiler target.CPP = host.CPP target.CFlags = append(append([]string{}, host.CFlags...), target.CFlags...) target.CFlags = processMergedFlags(target.CFlags) @@ -719,6 +723,9 @@ func initTarget(target *Target, OS, arch string) { if target.CCompiler == "" { target.setCompiler(useClang) } + if target.CxxCompiler == "" { + target.CxxCompiler = strings.TrimSuffix(strings.TrimSuffix(target.CCompiler, "cc"), "++") + "++" + } if target.CPP == "" { target.CPP = "cpp" } @@ -734,6 +741,7 @@ func initTarget(target *Target, OS, arch string) { if runtime.GOOS != target.BuildOS { // Spoil native binaries if they are not usable, so that nobody tries to use them later. target.CCompiler = fmt.Sprintf("cant-build-%v-on-%v", target.OS, runtime.GOOS) + target.CxxCompiler = target.CCompiler target.CPP = target.CCompiler } for _, flags := range [][]string{commonCFlags, target.osCommon.cflags} { @@ -945,6 +953,7 @@ func (target *Target) lazyInit() { } } target.CFlags = newCFlags + target.CxxFlags = append(target.CFlags, commonCxxFlags...) // Check that the compiler is actually functioning. It may be present, but still broken. // Common for Linux distros, over time we've seen: // Error: alignment too large: 15 assumed |
