Index: clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -82,6 +82,8 @@ "by colon, e.g. 'gfx908:sram-ecc+:xnack-')">; def err_drv_bad_offload_arch_combo : Error<"Invalid offload arch combinations: %0 and %1 (For a specific " "processor, a feature should either exist in all offload archs, or not exist in any offload archs)">; +def warn_drv_no_offload_arch : Warning<"no offload arch is specified. Assuming %0. Use --offload-arch= to" + " specify offload arch">, InGroup; def err_drv_invalid_thread_model_for_target : Error< "invalid thread model '%0' in '%1' for this target">; def err_drv_invalid_linker_name : Error< Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -1174,6 +1174,9 @@ // ignored by CUDA. def HIPOnly : DiagGroup<"hip-only">; +// A warning group for warnings about missing HIP options. +def HIPOptionMising : DiagGroup<"hip-option-missing">; + // Warnings which cause linking of the runtime libraries like // libc and the CRT to be skipped. def AVRRtlibLinkingQuirks : DiagGroup<"avr-rtlib-linking-quirks">; Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -2646,8 +2646,12 @@ // Default to sm_20 which is the lowest common denominator for // supported GPUs. sm_20 code should work correctly, if // suboptimally, on all newer GPUs. - if (GpuArchList.empty()) + if (GpuArchList.empty()) { GpuArchList.push_back(DefaultCudaArch); + if (AssociatedOffloadKind == Action::OFK_HIP) + C.getDriver().Diag(clang::diag::warn_drv_no_offload_arch) + << CudaArchToString(DefaultCudaArch); + } return Error; } Index: clang/test/Driver/hip-no-offload-arch.hip =================================================================== --- /dev/null +++ clang/test/Driver/hip-no-offload-arch.hip @@ -0,0 +1,9 @@ +// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target, nvptx-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \ +// RUN: %s 2>&1 | FileCheck -check-prefix=WARN %s +// WARN: warning: no offload arch is specified. Assuming gfx803. Use --offload-arch= to specify offload arch [-Whip-option-missing] + +// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \ +// RUN: -x cuda %s 2>&1 | FileCheck -check-prefix=NOWARN %s +// NOWARN-NOT: warning