diff --git a/interpreter/cling/include/cling/Interpreter/InvocationOptions.h b/interpreter/cling/include/cling/Interpreter/InvocationOptions.h
index 3304e2ca41547efba19e9115254cb5cc3e837e1a..833d139284e9f15d5265312e695f1d6a162f94a0 100644
--- a/interpreter/cling/include/cling/Interpreter/InvocationOptions.h
+++ b/interpreter/cling/include/cling/Interpreter/InvocationOptions.h
@@ -58,6 +58,7 @@ namespace cling {
     unsigned HasOutput : 1;
     unsigned Verbose : 1;
     unsigned CxxModules : 1;
+    unsigned CUDA : 1;
     /// \brief The output path of any C++ PCMs we're building on demand.
     /// Equal to ModuleCachePath in the HeaderSearchOptions.
     std::string CachePath;
diff --git a/interpreter/cling/lib/Interpreter/CIFactory.cpp b/interpreter/cling/lib/Interpreter/CIFactory.cpp
index f08997196a1274d8598da3dd3f4948d83c1baa14..a211f746b4d4a70c62653ef1b07767b332535da6 100644
--- a/interpreter/cling/lib/Interpreter/CIFactory.cpp
+++ b/interpreter/cling/lib/Interpreter/CIFactory.cpp
@@ -885,6 +885,7 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts,
       argvCompile.push_back("-x");
       argvCompile.push_back( "c++");
     }
+
     if (COpts.DefaultLanguage()) {
       // By default, set the standard to what cling was compiled with.
       // clang::driver::Compilation will do various things while initializing
@@ -897,6 +898,13 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts,
         default: llvm_unreachable("Unrecognized C++ version");
       }
     }
+
+    // This argument starts the cling instance with the x86 target. Otherwise,
+    // the first job in the joblist starts the cling instance with the nvptx
+    // target.
+    if(COpts.CUDA)
+      argvCompile.push_back("--cuda-host-only");
+
     // argv[0] already inserted, get the rest
     argvCompile.insert(argvCompile.end(), argv+1, argv + argc);
 
diff --git a/interpreter/cling/lib/Interpreter/InvocationOptions.cpp b/interpreter/cling/lib/Interpreter/InvocationOptions.cpp
index f3d7123e6dbad53cbdd67bf1b09b64064dc6a510..77dd965a42b9882aa6d78766a41bea5e8188c7eb 100644
--- a/interpreter/cling/lib/Interpreter/InvocationOptions.cpp
+++ b/interpreter/cling/lib/Interpreter/InvocationOptions.cpp
@@ -100,7 +100,7 @@ static const char kNoStdInc[] = "-nostdinc";
 CompilerOptions::CompilerOptions(int argc, const char* const* argv)
     : Language(false), ResourceDir(false), SysRoot(false), NoBuiltinInc(false),
       NoCXXInc(false), StdVersion(false), StdLib(false), HasOutput(false),
-      Verbose(false), CxxModules(false) {
+      Verbose(false), CxxModules(false), CUDA(false) {
   if (argc && argv) {
     // Preserve what's already in Remaining, the user might want to push args
     // to clang while still using main's argc, argv
@@ -126,7 +126,9 @@ void CompilerOptions::Parse(int argc, const char* const argv[],
       // case options::OPT_d_Flag:
       case options::OPT_E:
       case options::OPT_o: HasOutput = true; break;
-      case options::OPT_x: Language = true; break;
+      case options::OPT_x: Language = true;
+                           CUDA = llvm::StringRef(arg->getValue()) == "cuda";
+                           break;
       case options::OPT_resource_dir: ResourceDir = true; break;
       case options::OPT_isysroot: SysRoot = true; break;
       case options::OPT_std_EQ: StdVersion = true; break;
@@ -158,7 +160,7 @@ bool CompilerOptions::DefaultLanguage(const LangOptions* LangOpts) const {
   // Also don't set up the defaults when language is explicitly set; unless
   // the language was set to generate a PCH, in which case definitely do.
   if (Language)
-    return HasOutput || (LangOpts && LangOpts->CompilingPCH);
+    return HasOutput || (LangOpts && LangOpts->CompilingPCH) || CUDA;
 
   return true;
 }
diff --git a/interpreter/cling/test/Interfaces/invocationFlags.C b/interpreter/cling/test/Interfaces/invocationFlags.C
index fe252f2028b16b2b757efff0d33ef850cf0a4222..6ba276d89a13c373b46f29faed5610b9a9787b2c 100644
--- a/interpreter/cling/test/Interfaces/invocationFlags.C
+++ b/interpreter/cling/test/Interfaces/invocationFlags.C
@@ -36,12 +36,19 @@ COpts.NoBuiltinInc
 // CHECK-NEXT: (unsigned int) 1
 COpts.NoCXXInc
 // CHECK-NEXT: (unsigned int) 0
+COpts.CUDA
+// CHECK-NEXT: (unsigned int) 0
+
+COpts.DefaultLanguage()
+// CHECK-NEXT: false
 
 // library caller options: arguments passed as is
 COpts.Remaining
 // CHECK-NEXT: {{.*}} { "progname", "-", "-xobjective-c", "FileToExecuteA", "-isysroot", "APAth", "-nobuiltininc", "-v", "FileToExecuteB", "-L/Path/To/Libs", "-lTest" }
 
+argv[2] = "-xcuda";
 argv[6] = "-nostdinc++";
+
 cling::InvocationOptions IOpts(argc, argv);
 IOpts.Inputs
 // CHECK-NEXT: {{.*}} { "-", "FileToExecuteA", "FileToExecuteB" }
@@ -60,12 +67,18 @@ IOpts.CompilerOpts.NoBuiltinInc
 // CHECK-NEXT: (unsigned int) 0
 IOpts.CompilerOpts.NoCXXInc
 // CHECK-NEXT: (unsigned int) 1
+IOpts.CompilerOpts.CUDA
+// CHECK-NEXT: (unsigned int) 1
+
+// if the language is cuda, it should set automatically the c++ standard
+IOpts.CompilerOpts.DefaultLanguage()
+// CHECK-NEXT: true
 
 // user options from main: filtered by cling (no '-')
 IOpts.CompilerOpts.Remaining
 
 // Windows translates -nostdinc++ to -nostdinc++. Ignore that fact for the test.
-// CHECK-NEXT: {{.*}} { "progname", "-xobjective-c", "FileToExecuteA", "-isysroot", "APAth", {{.*}}, "-v", "FileToExecuteB" }
+// CHECK-NEXT: {{.*}} { "progname", "-xcuda", "FileToExecuteA", "-isysroot", "APAth", {{.*}}, "-v", "FileToExecuteB" }
 
 // expected-no-diagnostics
 .q