From 3a0aee13340e60f3a5d54bc113299e1759d5154a Mon Sep 17 00:00:00 2001 From: Quentin Casasnovas Date: Thu, 29 Feb 2024 15:44:44 +0100 Subject: [PATCH] llamacc: add option to always fallback to local build on error. Workaround for https://github.com/nelhage/llama/issues/69 Signed-off-by: Quentin Casasnovas --- cmd/llamacc/config.go | 3 +++ cmd/llamacc/main.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/llamacc/config.go b/cmd/llamacc/config.go index f2e557c..570cdad 100644 --- a/cmd/llamacc/config.go +++ b/cmd/llamacc/config.go @@ -26,6 +26,7 @@ type Config struct { FullPreprocess bool Function string LocalPreprocess bool + LocalFallback bool BuildID string // FilteredWarnings is a list of warnings that we should always filter @@ -102,6 +103,8 @@ func ParseConfig(env []string) Config { out.LocalCC = val case "LOCAL_CXX": out.LocalCXX = val + case "LOCAL_FALLBACK": + out.LocalFallback = BoolConfigTrue(val) case "FILTER_WARNINGS": out.FilteredWarnings = StringArrayConfig(val) default: diff --git a/cmd/llamacc/main.go b/cmd/llamacc/main.go index 9da0f5e..88cc182 100644 --- a/cmd/llamacc/main.go +++ b/cmd/llamacc/main.go @@ -296,7 +296,9 @@ func main() { if ex, ok := err.(*exec.ExitError); ok { os.Exit(ex.ExitCode()) } - if strings.Contains(err.Error(), "timed out") { + if cfg.LocalFallback { + goto RetryLocal + } else if strings.Contains(err.Error(), "timed out") { goto RetryLocal } else { fmt.Fprintf(os.Stderr, "Running llamacc: %s\n", err.Error())