diff options
author | George Burgess IV <gbiv@google.com> | 2020-06-11 14:27:13 -0700 |
---|---|---|
committer | George Burgess <gbiv@chromium.org> | 2020-06-15 22:30:38 +0000 |
commit | a6ad382ccc7f60ed9feda06d8fcbab62980c62f8 (patch) | |
tree | 1ff04f60665c1c81a49044bd54e35c44c6efc4d9 /compiler_wrapper | |
parent | 90f20eb35d5fd4bf1f63ca2ce751e60fca8b3143 (diff) | |
download | toolchain-utils-a6ad382ccc7f60ed9feda06d8fcbab62980c62f8.tar.gz |
wrapper: allow Android to specify their own llvm-flags
Given the discussion on
https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/1330695,
it sounds like our Android friends want to be able to tweak llvm-next
flags without going through chromium-review + having to pull their
changes back into Android.
This CL allows them to make changes to their llvm-next flags entirely
locally, and isolates CrOS' llvm-next flags from Android's.
BUG=None
TEST=Built the wrapper for CrOS and Android.
Change-Id: If1bcfe762a4f368db9816557752651edc877f497
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2247003
Reviewed-by: Pirama Arumuga Nainar <pirama@google.com>
Reviewed-by: Tiancong Wang <tcwang@google.com>
Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rwxr-xr-x | compiler_wrapper/build.py | 17 | ||||
-rw-r--r-- | compiler_wrapper/config.go | 5 | ||||
-rw-r--r-- | compiler_wrapper/cros_llvm_next_flags.go | 18 |
3 files changed, 32 insertions, 8 deletions
diff --git a/compiler_wrapper/build.py b/compiler_wrapper/build.py index 8ae23409..f98b2549 100755 --- a/compiler_wrapper/build.py +++ b/compiler_wrapper/build.py @@ -40,7 +40,7 @@ def parse_args(): return args -def calc_go_args(args, version): +def calc_go_args(args, version, build_dir): ldFlags = [ '-X', 'main.ConfigName=' + args.config, @@ -55,7 +55,17 @@ def calc_go_args(args, version): # If the wrapper is intended for Chrome OS, we need to use libc's exec. extra_args = [] if not args.static: - extra_args = ['-tags', 'libc_exec'] + extra_args += ['-tags', 'libc_exec'] + + if args.config == 'android': + # If android_llvm_next_flags.go DNE, we'll get an obscure "no + # llvmNextFlags" build error; complaining here is clearer. + if not os.path.exists( + os.path.join(build_dir, 'android_llvm_next_flags.go')): + sys.exit('In order to build the Android wrapper, you must have a local ' + 'android_llvm_next_flags.go file; please see ' + 'cros_llvm_next_flags.go.') + extra_args += ['-tags', 'android_llvm_next_flags'] return [ 'go', 'build', '-o', @@ -84,7 +94,8 @@ def main(): version = read_version(build_dir) # Note: Go does not support using absolute package names. # So we run go inside the directory of the the build file. - sys.exit(subprocess.call(calc_go_args(args, version), cwd=build_dir)) + sys.exit( + subprocess.call(calc_go_args(args, version, build_dir), cwd=build_dir)) if __name__ == '__main__': diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go index fc43a29b..e82e6b3d 100644 --- a/compiler_wrapper/config.go +++ b/compiler_wrapper/config.go @@ -93,11 +93,6 @@ func getConfig(configName string, useCCache bool, useLlvmNext bool, version stri return &cfg, nil } -// TODO: Enable test in config_test.go, once we have new llvm-next flags. -var llvmNextFlags = []string{} - -var llvmNextPostFlags = []string{} - // Full hardening. // Temporarily disable function splitting because of chromium:434751. var crosHardenedConfig = &config{ diff --git a/compiler_wrapper/cros_llvm_next_flags.go b/compiler_wrapper/cros_llvm_next_flags.go new file mode 100644 index 00000000..6cd7cd2a --- /dev/null +++ b/compiler_wrapper/cros_llvm_next_flags.go @@ -0,0 +1,18 @@ +// 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 !android_llvm_next_flags + +package main + +// This file defines extra flags for llvm-next testing for Chrome OS. Importantly, these flags don't +// apply to Android's llvm-next wrapper. Android's toolchain-utils copy has a +// `android_llvm_next_flags.go` file downstream that defines its llvm-next arguments. As you can +// probably infer, `android_llvm_next_flags.go` is only compiled if the `android_llvm_next_flags` +// tag is set. + +// TODO: Enable test in config_test.go, once we have new llvm-next flags. +var llvmNextFlags = []string{} + +var llvmNextPostFlags = []string{} |