aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/env.go
AgeCommit message (Collapse)Author
2019-09-13Use execve with properly merged env variables.Tobias Bosch
This reverts 478cfee03066d58ca3899753de95a58f35a96835 (Modify hostenv and use execv instead of execve). The original problem was actually that execve doesn't merge updates into the environment variables, in contrast to exec.Command. Now that we have our own merging logic (to e.g. support removal of variables), we can just use that. BUG=chromium:773875 TEST=emerge-kevin sci-libs/tensorflow Change-Id: I4a8412a73f4e79ad7b6d502602f442b2524efb06 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1804354 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-09-13Allow to remove env variables.Tobias Bosch
Previously, we only supported setting env variables to empty, but not to remove it. This lead to the case that we never removed the CCACHE_DISABLE env variable, which kept the ccache disabled, and caused a performance regression compared to the old wrapper as the new wrapper didn't use the ccache in this case. This cl also adds tests for the real exec and run commands to prevent regressions in these cases. BUG=chromium:773875 TEST=new unit tests TEST=performance analysis for TEST=emerge-veyron_jerry --nodeps chromeos-kernel-4_19 Change-Id: I5ca88ba8d7b05c3e12e292465fcd4ff9925b0344 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1802159 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-09-09Modify hostenv and use execv instead of execve.Tobias Bosch
This is needed so that the gentoo sandbox picks up changes to the SANDBOX_WRITE env variable correctly, which we update for ccache. BUG=chromium:773875 TEST=emerge-kevin sci-libs/tensorflow Change-Id: I6377c109f30071182b5af6948f320c7c53df4062 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1792228 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-09-06Use libc execve instead of syscall.ExecveTobias Bosch
Also create a dynamically linked binary. BUG=chromium:1000863 TEST=manual test against portage sandbox Change-Id: I36db7eac14466f41fbc1f0a41979039d8eaa1d83 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1789670 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-08-22Always use /proc/self/cwd to get current directory.Tobias Bosch
We are not using os.getwd() as this sometimes uses the value of the PWD env variable. This has the following problems: - if PWD=/proc/self/cwd, os.getwd() will return "/proc/self/cwd", and we need to read the link to get the actual wd. However, we can't always do this as we are calculating the path to clang, and following a symlinked cwd first would make this calculation invalid. - the old python wrapper doesn't respect the PWD env variable either, so if we did we would fail the comparison to the old wrapper. BUG=chromium:773875 TEST=emerge-lakitu app-emulation/docker Change-Id: Ifc49ab4eed66121f6710b38cf8457173fb559204 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1764624 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-08-22Only resolve symlinks for wd for /proc/self/cwdTobias Bosch
This is important as we are calculating the path to clang sometimes relative, and resolving regular symlinked directories makes this calculation invalid. BUG=chromium:773875 TEST=executed the clang wrapper in a symlinked directory Change-Id: I695db983861dea9fd047fb0bdf265a732a184963 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1764505 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-08-21Support symlinks as value of os.Getwd()Tobias Bosch
Also print the input command when the old and new wrapper differ. This happends when the wrapper is invoked like this: PWD=/proc/self/cwd x86_64-cros-linux-gnu-clang ... BUG=chromium:773875 TEST=emerge sci-libs/tensorflow Change-Id: Ic5441c05241ad07d10f60c90b7dbfaa60e8018dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1764490 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-08-21Only tee stdin if a "-" was passed the compiler.Tobias Bosch
This allows to remove the workaround in env.Run, and fixes the bug in the workaround that it didn't return exit code errors correctly. BUG=chromium:773875 TEST=manually tested in the chroot. Change-Id: I486b30b65ba3ad6249aa89e82e292c66378187a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1762345 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-08-20Forward os.Stdin to child processes.Tobias Bosch
BUG=chromium:773875 TEST=unit tests, build glibc with compiler wrapper Change-Id: I0b5c1f5adaee18499b72747cd6042b00a9d52c1d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1760973 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-07-22Add license headers to all go files.Tobias Bosch
Required as of https://chromium.git.corp.google.com/chromiumos/repohooks/+/9732e38a5551e4bbcd222d2bbb89ee0fc5c95dee BUG=chromium:773875 TEST=unit test Change-Id: I8dfed85b0fbd528084ff2e585bbf3624ac358135 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1710404 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-07-18Add json mapping for command and commandResult.Tobias Bosch
Also exports the fields on these structs so that json can read/write them. BUG=chromium:773875 TEST=unit test Change-Id: I0efead41693dd35548738a0b3a3e5c71c97c319c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1706790 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-07-13Add -print-cmdline and -print-configTobias Bosch
BUG=chromium:773875 TEST=unit test Change-Id: Ib25e582257694f3a3457795873a249735e3aaf82 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1697931 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
2019-07-10Support second execution of the compiler with -Wno-errorTobias Bosch
BUG=chromium:773875 TEST=unit test Change-Id: Ib77fd7c166a13acb733a1dbdfd88129141c4227a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1692969 Reviewed-by: Tobias Bosch <tbosch@google.com> Tested-by: Tobias Bosch <tbosch@google.com>
2019-06-28Introduce infrastructure for calling and testing nestedTobias Bosch
commands, error messages and exit codes. Also: - implements the -Xclang-path= flag as use case of calling a nested command. - adds tests for forwarding errors, comparing against the old wrapper, and exit codes. - captures the source locations of errors in error messages. - compares exit codes of new wrapper and old wrapper. BUG=chromium:773875 TEST=unit test Change-Id: I919e58091d093d68939809f676f799a68ec7a34e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1676833 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
2019-06-20Initial version of a go version of the compiler wrapper.Tobias Bosch
Still calls the old wrapper if one of the following flags is given: - Xclang-path - clang-syntax - env WITH_TIDY - env FORCE_DISABLE_WERROR - env GETRUSAGE - env BISECT_STAGE BUG=chromium:773875 TEST=Unit tests that also verify the produced command against the TEST=existing compiler wrapper. Change-Id: I1e0a720ce9f485d8015deefb2682f2cb760d82e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1652057 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>