diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 6461a756cc9b..373e14652878 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -864,6 +864,10 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) { } } + // AMDGPU-specific defaults for PIC. + if (Triple.getArch() == llvm::Triple::amdgcn) + PIC = true; + // The last argument relating to either PIC or PIE wins, and no // other argument is used. If the last argument is any flavor of the // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE diff --git a/clang/test/Driver/amdgcn-toolchain-pic.cl b/clang/test/Driver/amdgcn-toolchain-pic.cl new file mode 100644 index 000000000000..870f1f31327b --- /dev/null +++ b/clang/test/Driver/amdgcn-toolchain-pic.cl @@ -0,0 +1,7 @@ +// RUN: %clang -### -target amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck %s + +// CHECK: clang{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"