aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/kernel_bug.go
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2021-01-25 13:11:02 -0800
committerGeorge Burgess <gbiv@chromium.org>2021-01-29 18:25:20 +0000
commitcbc852e1f58da2a4eb07e8446d5a7a84c68621c1 (patch)
tree535e2b6a62390224b64f8ba6a142db85ebae0abf /compiler_wrapper/kernel_bug.go
parent8126715006b533888697689276b771cf6cdc2063 (diff)
downloadtoolchain-utils-cbc852e1f58da2a4eb07e8446d5a7a84c68621c1.tar.gz
compiler_wrapper: work around gcc failing due to a kernel bug
Very rarely on old GCCs, we'll complaints about GCC itself being handed ERESTARTSYS. Retry the compilation in those cases. Similarly, we'll sometimes see `run()` give us random errors with things like `waitid()`, so handle those. BUG=chromium:1166017 TEST=CQ Change-Id: If9b6fdc523f60719608739da0eefa94c82164ae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2648090 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/kernel_bug.go')
-rw-r--r--compiler_wrapper/kernel_bug.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler_wrapper/kernel_bug.go b/compiler_wrapper/kernel_bug.go
new file mode 100644
index 00000000..55817cb6
--- /dev/null
+++ b/compiler_wrapper/kernel_bug.go
@@ -0,0 +1,25 @@
+// Copyright 2021 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+package main
+
+import (
+ "bytes"
+ "strings"
+)
+
+// crbug.com/1166017
+
+const kernelBugRetryLimit = 25
+
+// GCC will sometimes fail to wait on subprocesses due to this kernel bug. It always fails the
+// compilation and prints "Unknown error 512" in that case.
+func containsTracesOfKernelBug(buf []byte) bool {
+ return bytes.Contains(buf, []byte("Unknown error 512"))
+}
+
+func errorContainsTracesOfKernelBug(err error) bool {
+ // We'll get errors that look like "waitid: errno 512." Presumably, this isn't specific to
+ // waitid, so just try to match the "errno 512" ending.
+ return err != nil && strings.HasSuffix(err.Error(), "errno 512")
+}