Skip to content

Commit c3ac3fe

Browse files
authored
[OpenMP] Fix redefining stdint.h types (#108607)
Summary: We can include `stdint.h` just fine as long as we don't allow it to find system headers, passing `-nostdlibinc` and `-nogpuinc` suppresses these extra paths so we will just use the clang resource headers for `stdint.h` and `stddef.h`.
1 parent 39f2d2f commit c3ac3fe

File tree

5 files changed

+9
-54
lines changed

5 files changed

+9
-54
lines changed

offload/DeviceRTL/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
125125
# Set flags for LLVM Bitcode compilation.
126126
set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
127127
${clang_opt_flags} --offload-device-only
128-
-nocudalib -nogpulib -nostdinc
128+
-nocudalib -nogpulib -nogpuinc -nostdlibinc
129129
-fopenmp -fopenmp-cuda-mode
130130
-Wno-unknown-cuda-version
131131
-DOMPTARGET_DEVICE_RUNTIME
@@ -270,7 +270,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
270270
-fopenmp --offload-arch=${target_cpu} -fopenmp-cuda-mode
271271
-mllvm -openmp-opt-disable
272272
-foffload-lto -fvisibility=hidden --offload-device-only
273-
-nocudalib -nogpulib -nostdinc -Wno-unknown-cuda-version
273+
-nocudalib -nogpulib -nogpuinc -nostdlibinc -Wno-unknown-cuda-version
274274
)
275275
target_compile_definitions(${ide_target_name} PRIVATE SHARED_SCRATCHPAD_SIZE=512)
276276
target_include_directories(${ide_target_name} PRIVATE

offload/DeviceRTL/include/DeviceTypes.h

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#ifndef OMPTARGET_TYPES_H
1313
#define OMPTARGET_TYPES_H
1414

15+
#include <stddef.h>
16+
#include <stdint.h>
17+
1518
// Tell the compiler that we do not have any "call-like" inline assembly in the
1619
// device rutime. That means we cannot have inline assembly which will call
1720
// another function but only inline assembly that performs some operation or
@@ -21,32 +24,6 @@
2124
// TODO: Find a good place for this
2225
#pragma omp assumes ext_no_call_asm
2326

24-
/// Base type declarations for freestanding mode
25-
///
26-
///{
27-
using int8_t = char;
28-
using uint8_t = unsigned char;
29-
using int16_t = short;
30-
using uint16_t = unsigned short;
31-
using int32_t = int;
32-
using uint32_t = unsigned int;
33-
using int64_t = long;
34-
using uint64_t = unsigned long;
35-
using size_t = decltype(sizeof(char));
36-
// TODO: Properly implement this
37-
using intptr_t = int64_t;
38-
using uintptr_t = uint64_t;
39-
40-
static_assert(sizeof(int8_t) == 1, "type size mismatch");
41-
static_assert(sizeof(uint8_t) == 1, "type size mismatch");
42-
static_assert(sizeof(int16_t) == 2, "type size mismatch");
43-
static_assert(sizeof(uint16_t) == 2, "type size mismatch");
44-
static_assert(sizeof(int32_t) == 4, "type size mismatch");
45-
static_assert(sizeof(uint32_t) == 4, "type size mismatch");
46-
static_assert(sizeof(int64_t) == 8, "type size mismatch");
47-
static_assert(sizeof(uint64_t) == 8, "type size mismatch");
48-
///}
49-
5027
enum omp_proc_bind_t {
5128
omp_proc_bind_false = 0,
5229
omp_proc_bind_true = 1,

offload/include/Shared/Environment.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
#ifndef OMPTARGET_SHARED_ENVIRONMENT_H
1414
#define OMPTARGET_SHARED_ENVIRONMENT_H
1515

16+
#include <stdint.h>
17+
1618
#ifdef OMPTARGET_DEVICE_RUNTIME
17-
#include "Types.h"
19+
#include "DeviceTypes.h"
1820
#else
1921
#include "SourceInfo.h"
2022

21-
#include <cstdint>
22-
2323
using IdentTy = ident_t;
2424
#endif
2525

offload/include/Shared/Types.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

offload/include/Shared/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef OMPTARGET_SHARED_UTILS_H
1515
#define OMPTARGET_SHARED_UTILS_H
1616

17-
#include "Types.h"
17+
#include <stdint.h>
1818

1919
namespace utils {
2020

0 commit comments

Comments
 (0)