Add toolchain info when building a kernel package

In order to use kernel CI's artifacts with the matching
toolchain the toolchain information (download source and env)
needs to be provided to a consumer too. Add two files,
toolchain_url and toolchain_env, when building a kernel
package. The CI script later can save them to the respective GCS
bucket.

BUG=b/224985283

Change-Id: I2563352b1c3abda50ec37524fc281337f6d6cbbe
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/35029
Tested-by: Oleksandr Tymoshenko <ovt@google.com>
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
Reviewed-by: Meena Shanmugam <meenashanmugam@google.com>
diff --git a/src/cmd/cos_kernel_devenv/devenv.sh b/src/cmd/cos_kernel_devenv/devenv.sh
index 8b4b953..cf5f476 100755
--- a/src/cmd/cos_kernel_devenv/devenv.sh
+++ b/src/cmd/cos_kernel_devenv/devenv.sh
@@ -190,6 +190,9 @@
   if [[ ! -L "${BUILD_DIR}/toolchain" ]]; then
     ln -s "${toolchain_dir}" "${BUILD_DIR}/toolchain"
   fi
+
+  # keep toolchain source information
+  echo -n "${download_url}" > "${BUILD_DIR}/toolchain_url"
 }
 
 install_release_cross_toolchain() {
@@ -311,7 +314,7 @@
     export CXX
   else
     export CC="${TOOLCHAIN_ARCH}-cros-linux-gnu-clang"
-    export CXX="${TOOLCHAIN_ARCH}-cros-linux-gnu-clang"
+    export CXX="${TOOLCHAIN_ARCH}-cros-linux-gnu-clang++"
   fi
   info "Configuring environment variables for cross-compilation"
   # CC and CXX are already set in toolchain_env
@@ -449,6 +452,15 @@
   if [[ "${BUILD_HEADERS_PACKAGE}" = "true" ]]; then
     tar_kernel_headers
   fi
+
+  # pass env information
+  echo "CC=${CC}" >  "${KBUILD_OUTPUT}/toolchain_env"
+  echo "CXX=${CXX}" >>  "${KBUILD_OUTPUT}/toolchain_env"
+
+  # pass toolchain source location
+  if [[ -f "${BUILD_DIR}/toolchain_url" ]]; then
+    cp "${BUILD_DIR}/toolchain_url" "${KBUILD_OUTPUT}/toolchain_url";
+  fi
 }
 
 module_build() {