diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1856,6 +1856,12 @@
   if (A)
     return A->getValue();
 
+  // If --gcc-toochain is not set, we then check the environment variable
+  // GCC_TOOLCHAIN because sometimes it is not easy to pass the option to the
+  // driver.
+  if (const char *GCCToolchainEnv = ::getenv("GCC_TOOLCHAIN"))
+    return GCCToolchainEnv;
+
   // If we have a SysRoot, ignore GCC_INSTALL_PREFIX.
   // GCC_INSTALL_PREFIX specifies the gcc installation for the default
   // sysroot and is likely not valid with a different sysroot.