From 47f23f8c31103c4365ce5992cae34cd12a9d4bab Mon Sep 17 00:00:00 2001 From: Stefan Wiehler Date: Thu, 28 Nov 2024 14:57:27 +0100 Subject: sys/targets: allow users to override hardcoded cross-compilers Currently, cross compiler names are hardcoded for each OS/arch combo. However, toolchain tuples differ, especially when using vendor provided toolchains or building with Yocto. Allow users to specify the cross compiler for an OS/arch combo using SYZ_CC__ environment variables. --- sys/targets/targets.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sys') diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 38ebeb365..121d137ed 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -715,6 +715,16 @@ func initTarget(target *Target, OS, arch string) { for i := range target.CFlags { target.replaceSourceDir(&target.CFlags[i], sourceDir) } + + if cc := os.Getenv("SYZ_CC_" + OS + "_" + arch); cc != "" { + target.CCompiler = strings.Fields(cc)[0] + target.CFlags = append(target.CFlags, strings.Fields(cc)[1:]...) + } + if cxx := os.Getenv("SYZ_CXX_" + OS + "_" + arch); cxx != "" { + target.CxxCompiler = strings.Fields(cxx)[0] + target.CxxFlags = append(target.CxxFlags, strings.Fields(cxx)[1:]...) + } + if OS == Linux && arch == runtime.GOARCH { // Don't use cross-compiler for native compilation, there are cases when this does not work: // https://github.com/google/syzkaller/pull/619 -- cgit mrf-deployment