Skip to content

Commit

Permalink
Revert "[libc] Add support for creating wrapper headers for offloadin…
Browse files Browse the repository at this point in the history
…g in clang"

This reverts commit a4a2637.

This was causing some problems with the CPU build and CUDA buildbot.
Revert until I can figure out what those issues are and fix them. I
believe it is just some CMake.
  • Loading branch information
jhuber6 committed Jul 6, 2023
1 parent a8df21f commit 6ca6cdb
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 417 deletions.
19 changes: 6 additions & 13 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,30 +1181,23 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,

// If we are compiling for a GPU target we want to override the system headers
// with ones created by the 'libc' project if present.
// FIXME: We need to find a way to make these headers compatible with the
// host environment so they can be included from offloading languages. For now
// these are only active when targeting the GPU with cross-compilation.
if (!Args.hasArg(options::OPT_nostdinc) &&
!Args.hasArg(options::OPT_nogpuinc) &&
!Args.hasArg(options::OPT_nobuiltininc) &&
C.getActiveOffloadKinds() == Action::OFK_None &&
(getToolChain().getTriple().isNVPTX() ||
getToolChain().getTriple().isAMDGCN())) {

// Without an offloading language we will include these headers directly.
// Offloading languages will instead only use the declarations stored in
// the resource directory at clang/lib/Headers/llvm_libc_wrappers.
if (C.getActiveOffloadKinds() == Action::OFK_None) {
// Add include/gpu-none-libc/* to our system include path. This lets us use
// GPU-specific system headers first.
SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
llvm::sys::path::append(P, "include");
llvm::sys::path::append(P, "gpu-none-llvm");
CmdArgs.push_back("-c-isystem");
CmdArgs.push_back(Args.MakeArgString(P));
} else if (C.getActiveOffloadKinds() == Action::OFK_OpenMP) {
// TODO: CUDA / HIP include their own headers for some common functions
// implemented here. We'll need to clean those up so they do not conflict.
SmallString<128> P(D.ResourceDir);
llvm::sys::path::append(P, "include");
llvm::sys::path::append(P, "llvm_libc_wrappers");
CmdArgs.push_back("-internal-isystem");
CmdArgs.push_back(Args.MakeArgString(P));
}
}

// If we are offloading to a target via OpenMP we need to include the
Expand Down
24 changes: 1 addition & 23 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@ set(openmp_wrapper_files
openmp_wrappers/new
)

set(llvm_libc_wrapper_files
llvm_libc_wrappers/stdio.h
llvm_libc_wrappers/stdlib.h
llvm_libc_wrappers/string.h
llvm_libc_wrappers/ctype.h
llvm_libc_wrappers/inttypes.h
)

include(GetClangResourceDir)
get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
set(out_files)
Expand Down Expand Up @@ -341,8 +333,7 @@ endfunction(clang_generate_header)

# Copy header files from the source directory to the build directory
foreach( f ${files} ${cuda_wrapper_files} ${cuda_wrapper_bits_files}
${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files}
${llvm_libc_wrapper_files})
${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files})
copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
endforeach( f )

Expand Down Expand Up @@ -436,7 +427,6 @@ add_dependencies("clang-resource-headers"
"x86-resource-headers"
"opencl-resource-headers"
"openmp-resource-headers"
"llvm-libc-resource-headers"
"windows-resource-headers"
"utility-resource-headers")

Expand All @@ -463,7 +453,6 @@ add_header_target("x86-resource-headers" "${x86_files}")
# Other header groupings
add_header_target("hlsl-resource-headers" ${hlsl_files})
add_header_target("opencl-resource-headers" ${opencl_files})
add_header_target("llvm-libc-resource-headers" ${llvm_libc_wrapper_files})
add_header_target("openmp-resource-headers" ${openmp_wrapper_files})
add_header_target("windows-resource-headers" ${windows_only_files})
add_header_target("utility-resource-headers" ${utility_files})
Expand Down Expand Up @@ -492,11 +481,6 @@ install(
DESTINATION ${header_install_dir}/ppc_wrappers
COMPONENT clang-resource-headers)

install(
FILES ${llvm_libc_wrapper_files}
DESTINATION ${header_install_dir}/llvm_libc_wrappers
COMPONENT clang-resource-headers)

install(
FILES ${openmp_wrapper_files}
DESTINATION ${header_install_dir}/openmp_wrappers
Expand Down Expand Up @@ -652,12 +636,6 @@ install(
EXCLUDE_FROM_ALL
COMPONENT openmp-resource-headers)

install(
FILES ${openmp_wrapper_files}
DESTINATION ${header_install_dir}/openmp_wrappers
EXCLUDE_FROM_ALL
COMPONENT openmp-resource-headers)

install(
FILES ${utility_files}
DESTINATION ${header_install_dir}
Expand Down
85 changes: 0 additions & 85 deletions clang/lib/Headers/llvm_libc_wrappers/ctype.h

This file was deleted.

34 changes: 0 additions & 34 deletions clang/lib/Headers/llvm_libc_wrappers/inttypes.h

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions clang/lib/Headers/llvm_libc_wrappers/stdio.h

This file was deleted.

42 changes: 0 additions & 42 deletions clang/lib/Headers/llvm_libc_wrappers/stdlib.h

This file was deleted.

48 changes: 0 additions & 48 deletions clang/lib/Headers/llvm_libc_wrappers/string.h

This file was deleted.

8 changes: 0 additions & 8 deletions clang/test/Driver/gpu-libc-headers.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// REQUIRES: nvptx-registered-target
// REQUIRES: amdgpu-registered-target

// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --sysroot=./ \
// RUN: -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa --offload-arch=gfx908 \
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --sysroot=./ \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70 \
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"

// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
// RUN: -nogpuinc %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS-DISABLED
// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
Expand Down
Loading

0 comments on commit 6ca6cdb

Please sign in to comment.