[HIP] Handle -fhip-emit-reloctable
in the new driver (#151237)
Summary: Support for this was missing, here it pretty much overrides the normal bundling behavior and also requires a few errors to be emitted.
This commit is contained in:
parent
4fdf07fd46
commit
4562b557a6
@ -3606,7 +3606,7 @@ class OffloadingActionBuilder final {
|
||||
if (!CompileDeviceOnly) {
|
||||
C.getDriver().Diag(diag::err_opt_not_valid_without_opt)
|
||||
<< "-fhip-emit-relocatable"
|
||||
<< "--cuda-device-only";
|
||||
<< "--offload-device-only";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4774,6 +4774,21 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
|
||||
C.isOffloadingHostKind(Action::OFK_HIP) &&
|
||||
!Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false);
|
||||
|
||||
bool HIPRelocatableObj =
|
||||
C.isOffloadingHostKind(Action::OFK_HIP) &&
|
||||
Args.hasFlag(options::OPT_fhip_emit_relocatable,
|
||||
options::OPT_fno_hip_emit_relocatable, false);
|
||||
|
||||
if (!HIPNoRDC && HIPRelocatableObj)
|
||||
C.getDriver().Diag(diag::err_opt_not_valid_with_opt)
|
||||
<< "-fhip-emit-relocatable"
|
||||
<< "-fgpu-rdc";
|
||||
|
||||
if (!offloadDeviceOnly() && HIPRelocatableObj)
|
||||
C.getDriver().Diag(diag::err_opt_not_valid_without_opt)
|
||||
<< "-fhip-emit-relocatable"
|
||||
<< "--offload-device-only";
|
||||
|
||||
// For HIP non-rdc non-device-only compilation, create a linker wrapper
|
||||
// action for each host object to link, bundle and wrap device files in
|
||||
// it.
|
||||
@ -4894,7 +4909,7 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
|
||||
A->getOffloadingToolChain()->getTriple().isSPIRV();
|
||||
if ((A->getType() != types::TY_Object && !IsAMDGCNSPIRV &&
|
||||
A->getType() != types::TY_LTO_BC) ||
|
||||
!HIPNoRDC || !offloadDeviceOnly())
|
||||
HIPRelocatableObj || !HIPNoRDC || !offloadDeviceOnly())
|
||||
continue;
|
||||
ActionList LinkerInput = {A};
|
||||
A = C.MakeAction<LinkJobAction>(LinkerInput, types::TY_Image);
|
||||
|
@ -4,6 +4,12 @@
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOCRDC %s
|
||||
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver \
|
||||
// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
|
||||
// RUN: -c -fhip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOCRDC %s
|
||||
|
||||
// RELOCRDC: error: option '-fhip-emit-relocatable' cannot be specified with '-fgpu-rdc'
|
||||
|
||||
@ -13,5 +19,11 @@
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOCHOST %s
|
||||
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver \
|
||||
// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
|
||||
// RUN: -c -fhip-emit-relocatable -nogpuinc -nogpulib \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
|
||||
// RUN: %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOCHOST %s
|
||||
|
||||
// RELOCHOST: error: option '-fhip-emit-relocatable' cannot be specified without '--cuda-device-only'
|
||||
// RELOCHOST: error: option '-fhip-emit-relocatable' cannot be specified without '--offload-device-only'
|
||||
|
@ -275,10 +275,16 @@
|
||||
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases --no-offload-new-driver \
|
||||
// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
|
||||
// RUN: | FileCheck -check-prefixes=RELOC %s
|
||||
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases --offload-new-driver \
|
||||
// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
|
||||
// RUN: | FileCheck -check-prefixes=RELOC %s
|
||||
//
|
||||
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases --no-offload-new-driver \
|
||||
// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable -Wl,--disable-new-dtags \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOC %s
|
||||
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases --offload-new-driver \
|
||||
// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable -Wl,--disable-new-dtags \
|
||||
// RUN: 2>&1 | FileCheck -check-prefixes=RELOC %s
|
||||
//
|
||||
// RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
|
||||
// RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
|
||||
@ -286,7 +292,7 @@
|
||||
// RELOC-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
|
||||
// RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
|
||||
// RELOC-NOT: linker
|
||||
// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
|
||||
// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}
|
||||
// RELOC-NOT: host
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user