diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4520,6 +4520,7 @@ llvm::PrettyStackTraceString CrashInfo("Building compilation jobs"); Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o); + bool SyntaxOnly = C.getArgs().getLastArg(options::OPT_fsyntax_only); // It is an error to provide a -o option if we are making multiple output // files. There are exceptions: @@ -4536,7 +4537,8 @@ // // OffloadClass of type TY_Nothing: device-only output will place many outputs // into a single offloading action. We should count all inputs to the action - // as outputs. + // as outputs. Also ignore device-only outputs if we're compiling with + // -fsyntax-only. if (FinalOutput) { unsigned NumOutputs = 0; unsigned NumIfsOutputs = 0; @@ -4550,7 +4552,7 @@ A->getInputs().front()->getKind() == Action::IfsMergeJobClass))) ++NumOutputs; else if (A->getKind() == Action::OffloadClass && - A->getType() == types::TY_Nothing) + A->getType() == types::TY_Nothing && !SyntaxOnly) NumOutputs += A->size(); } diff --git a/clang/test/Driver/cuda-bindings.cu b/clang/test/Driver/cuda-bindings.cu --- a/clang/test/Driver/cuda-bindings.cu +++ b/clang/test/Driver/cuda-bindings.cu @@ -39,9 +39,19 @@ // // Test two gpu architectures with complete compilation. // -// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ -// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --offload-arch=sm_30,sm_35 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=BIN2 %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --offload-arch=sm_30,sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s +// .. same, but with explicitly specified output. +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s // BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 // BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: @@ -54,7 +64,25 @@ // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 // BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 -// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out" +// AOUT: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out" +// TOUT: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "{{.*}}/out" + +// .. same, but with -fsyntax-only +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// SYN-DAG: # "powerpc64le-ibm-linux-gnu" - "clang", inputs: [{{.*}}], output: (nothing) +// SYN-DAG: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) +// SYN-DAG: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) // // Test two gpu architectures up to the assemble phase.