Use git worktree in the LLVM helper scripts

This commit adds a new script, llvm-env, which sets up the environment for
working with LLVM. It looks for an environment variable LLVM_ROOT and tries to
create the following hierarchy:

$LLVM_ROOT
  `- repos
  |    `- llvm
  |    `- clang
  |    `- compiler-rt
  |     [...]
  `- <branch1>
  |    `- llvm
  |    `- build
  |    `- debug
  `- <branch2>
  |    `- llvm
  |    `- build
  |    `- debug
  [...]

The $LLVM_ROOT/repos directory contains all the repositories, as checked out by
llvm-prepare, and will always track master. For other branches,
llvm-env <branch_name> will create a new directory, $LLVM_ROOT/<branch_name>,
and will add an llvm worktree directory there. If -d is passed, it will also
create a debug directory there, otherwise it will create a build directory.
Notice that these 2 can live in parallel, and we can switch between them at any
time by invoking llvm-env. It will set LLVM_SRC and LLVM_BLD accordingly, and
also modify the path to point to the binaries in LLVM_BLD.

The other scripts will now work with the LLVM_SRC and LLVM_BLD set by llvm-env
in the current shell. Because llvm-env controls whether or not we're doing a
debug build, llvm-build will no longer take a -d flag (it will instead look
after a LLVM_DEBUG environment variable, also set by llvm-env). There are
changes in llvm-projs, too, because now it no longer creates links - instead it
creates worktree directories in the corresponding $LLVM_ROOT/<branch>/llvm.
Other scripts have also been updated accordingly.

To make things easier, here are some of the changes that I had to make that are
not particularly important for the review (pretty mechanical stuff):
* Moved function has() from llvm-branch to llvm-common, so I could reuse it
* Because of this, I had to rename the has() function in llvm-projs to
has_link(), which is actually a better name for it anyway
* Disable the checks for LLVM_SRC and LLVM_BLD in llvm-common

Change-Id: I9e02f6d8e0c803e79838845013b81331dffba99c
diff --git a/helpers/llvm-build b/helpers/llvm-build
index 938caa5..b674fa9 100755
--- a/helpers/llvm-build
+++ b/helpers/llvm-build
@@ -8,6 +8,8 @@
 
 . llvm-common
 
+safe_run verify_env
+
 ## CMD line options and defaults
 CPUs=`grep -c proc /proc/cpuinfo`
 build_dir=$LLVM_BLD
@@ -16,13 +18,12 @@
 shared=
 targets=
 prog=`basename $0`
-syntax="Syntax: $prog [-u(pdate)] [-c(check-all)] [-i(nstall)] [-d(debug)]"
+syntax="Syntax: $prog [-u(pdate)] [-c(check-all)] [-i(nstall)]"
 update=false
 check=false
 master=false
-debug=false
 inst=false
-while getopts "ucimd" opt; do
+while getopts "ucim" opt; do
   case $opt in
     u)
       update=true
@@ -36,10 +37,6 @@
     m)
       master=true
       ;;
-    d)
-      debug=true
-      build_dir=$LLVM_BLD/../debug
-      ;;
     *)
       echo $syntax
       exit 1
@@ -68,7 +65,7 @@
 fi
 
 ## Debug mode, make it lighter
-if $debug; then
+if [ "$LLVM_DEBUG" = true ]; then
   build_type=Debug
   shared=-DBUILD_SHARED_LIBS=True
   targets=-DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"