Skip to content

Commit ea463c1

Browse files
committed
Remove old method for passing C libraries.
1 parent 69811ec commit ea463c1

File tree

3 files changed

+7
-65
lines changed

3 files changed

+7
-65
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9111,6 +9111,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
91119111
A->claim();
91129112
}
91139113

9114+
// If we disable the GPU C library support it needs to be forwarded to the
9115+
// link job.
9116+
if (!Args.hasFlag(options::OPT_gpulibc, options::OPT_nogpulibc, true))
9117+
CmdArgs.push_back("--device-linker=-nolibc");
9118+
91149119
// Add the linker arguments to be forwarded by the wrapper.
91159120
CmdArgs.push_back(Args.MakeArgString(Twine("--linker-path=") +
91169121
LinkCommand->getExecutable()));

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,42 +1161,6 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
11611161
}
11621162
}
11631163

1164-
/// Adds the '-lcgpu' and '-lmgpu' libraries to the compilation to include the
1165-
/// LLVM C library for GPUs.
1166-
static void addOpenMPDeviceLibC(const Compilation &C, const ArgList &Args,
1167-
ArgStringList &CmdArgs) {
1168-
if (Args.hasArg(options::OPT_nogpulib) || Args.hasArg(options::OPT_nolibc))
1169-
return;
1170-
1171-
// Check the resource directory for the LLVM libc GPU declarations. If it's
1172-
// found we can assume that LLVM was built with support for the GPU libc.
1173-
SmallString<256> LibCDecls(C.getDriver().ResourceDir);
1174-
llvm::sys::path::append(LibCDecls, "include", "llvm_libc_wrappers",
1175-
"llvm-libc-decls");
1176-
bool HasLibC = llvm::sys::fs::exists(LibCDecls) &&
1177-
llvm::sys::fs::is_directory(LibCDecls);
1178-
if (!Args.hasFlag(options::OPT_gpulibc, options::OPT_nogpulibc, HasLibC))
1179-
return;
1180-
1181-
SmallVector<const ToolChain *> ToolChains;
1182-
auto TCRange = C.getOffloadToolChains(Action::OFK_OpenMP);
1183-
for (auto TI = TCRange.first, TE = TCRange.second; TI != TE; ++TI)
1184-
ToolChains.push_back(TI->second);
1185-
1186-
if (llvm::any_of(ToolChains, [](const ToolChain *TC) {
1187-
return TC->getTriple().isAMDGPU();
1188-
})) {
1189-
CmdArgs.push_back("-lcgpu-amdgpu");
1190-
CmdArgs.push_back("-lmgpu-amdgpu");
1191-
}
1192-
if (llvm::any_of(ToolChains, [](const ToolChain *TC) {
1193-
return TC->getTriple().isNVPTX();
1194-
})) {
1195-
CmdArgs.push_back("-lcgpu-nvptx");
1196-
CmdArgs.push_back("-lmgpu-nvptx");
1197-
}
1198-
}
1199-
12001164
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
12011165
const ArgList &Args,
12021166
ArgStringList &CmdArgs) {
@@ -1269,9 +1233,6 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
12691233
if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
12701234
CmdArgs.push_back("-lomptarget.devicertl");
12711235

1272-
if (IsOffloadingHost)
1273-
addOpenMPDeviceLibC(C, Args, CmdArgs);
1274-
12751236
addArchSpecificRPath(TC, Args, CmdArgs);
12761237

12771238
addOpenMPRuntimeLibraryPath(TC, Args, CmdArgs);

clang/test/Driver/openmp-offload-gpu.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -372,33 +372,9 @@
372372
// XARCH-DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3"
373373
// XARCH-DEVICE-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3"
374374

375-
//
376-
// Check that `-gpulibc` includes the LLVM C libraries for the GPU.
377-
//
378-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
379-
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
380-
// RUN: --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
381-
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
382-
// RUN: --rocm-path=%S/Inputs/rocm \
383-
// RUN: --offload-arch=sm_52,gfx803 -gpulibc -nogpuinc %s 2>&1 \
384-
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
385-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
386-
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
387-
// RUN: --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
388-
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
389-
// RUN: --rocm-path=%S/Inputs/rocm \
390-
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 \
391-
// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 \
392-
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -gpulibc -nogpuinc %s 2>&1 \
393-
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
394-
// LIBC-GPU-DAG: "-lcgpu-amdgpu"
395-
// LIBC-GPU-DAG: "-lmgpu-amdgpu"
396-
// LIBC-GPU-DAG: "-lcgpu-nvptx"
397-
// LIBC-GPU-DAG: "-lmgpu-nvptx"
398-
399375
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
400376
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
401377
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
402378
// RUN: --offload-arch=sm_52 -nogpulibc -nogpuinc %s 2>&1 \
403-
// RUN: | FileCheck --check-prefix=NO-LIBC-GPU %s
404-
// NO-LIBC-GPU-NOT: -lmgpu{{.*}}-lcgpu
379+
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
380+
// LIBC-GPU: clang-linker-wrapper{{.*}}"--device-linker=-nolibc"

0 commit comments

Comments
 (0)