aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/go_exec.go
diff options
context:
space:
mode:
authorTiancong Wang <tcwang@google.com>2020-02-12 13:41:01 -0800
committerTiancong Wang <tcwang@google.com>2020-02-13 18:13:48 +0000
commit22e3075e965be294d2b080752a113788c3cf136a (patch)
tree91618629b7ee190ce9e9622ba288a0bd5cfb18e7 /compiler_wrapper/go_exec.go
parent43c9066b1889baaa0a6077399deb6a4d503551e6 (diff)
downloadtoolchain-utils-22e3075e965be294d2b080752a113788c3cf136a.tar.gz
compiler_wrapper: Use syscall.exec on platforms other than Chrome OS
In crbug.com/1000863, it's reported that golang exec don't play well on Chrome OS, portage sandbox to be exact. That's when we start to use libc's exec. However, the wrapper is also used on non-Chrome OS platforms, such as Android, and linking against libc has no benefit, and might be the root cause of a recent bug. This patch adds code to selectively use Golang's or libc's exec, depending on the platform. BUG=chromium:1000863 BUG=b:144783188 TEST=Build the wrapper locally with Chrome OS and Android configurations Change-Id: Ifd6fa8223205536450b65f728060d7c5556d7619 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2051669 Tested-by: Tiancong Wang <tcwang@google.com> Commit-Queue: Tiancong Wang <tcwang@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/go_exec.go')
-rw-r--r--compiler_wrapper/go_exec.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler_wrapper/go_exec.go b/compiler_wrapper/go_exec.go
new file mode 100644
index 00000000..2f2e5ad9
--- /dev/null
+++ b/compiler_wrapper/go_exec.go
@@ -0,0 +1,23 @@
+// Copyright 2020 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.
+
+// +build !libc_exec
+
+package main
+
+import (
+ "os/exec"
+ "syscall"
+)
+
+// Implement exec for users that don't need to dynamically link with glibc
+// See b/144783188 and libc_exec.go.
+
+func execCmd(env env, cmd *command) error {
+ execCmd := exec.Command(cmd.Path, cmd.Args...)
+ mergedEnv := mergeEnvValues(env.environ(), cmd.EnvUpdates)
+
+ ret := syscall.Exec(execCmd.Path, execCmd.Args, mergedEnv)
+ return newErrorwithSourceLocf("exec error: %v", ret)
+}