aboutsummaryrefslogtreecommitdiffstats
path: root/sys/targets/targets.go
diff options
context:
space:
mode:
authorStefan Wiehler <me@sephalon.net>2024-11-28 14:57:27 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-01-14 08:31:31 +0000
commit47f23f8c31103c4365ce5992cae34cd12a9d4bab (patch)
tree5162fed3cd0a552f3c67fe2f7ace6a30c14c7838 /sys/targets/targets.go
parent4a955342afa8e02b8a7848f968bb4236b8f3d8f0 (diff)
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_<os>_<arch> environment variables.
Diffstat (limited to 'sys/targets/targets.go')
-rw-r--r--sys/targets/targets.go10
1 files changed, 10 insertions, 0 deletions
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