Skip to content

Commit cfd1816

Browse files
committed
Revert "[Libomptarget] Use freestanding stdint.h header for DeviceRTL"
This patch breaks the handling of `printf` in the OpenMP library. Usiing `-ffreestanding` prevents clang from emitting LLVM builtins, which we use for OpenMP printing support. Shelve this until we have functioning `printf` in the GPU `libc` and we can remove that code. This reverts commit a92eaa3.
1 parent 40a51e1 commit cfd1816

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

openmp/libomptarget/DeviceRTL/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ list(TRANSFORM LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL PREPEND "-I")
121121
# Set flags for LLVM Bitcode compilation.
122122
set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
123123
${clang_opt_flags} --offload-device-only
124-
-nocudalib -nogpulib -nogpuinc -ffreestanding
124+
-nocudalib -nogpulib -nostdinc
125125
-fopenmp -fopenmp-cuda-mode
126126
-Wno-unknown-cuda-version
127127
-I${include_directory}

openmp/libomptarget/DeviceRTL/include/Types.h

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

15-
#include <stdint.h>
16-
17-
using size_t = decltype(sizeof(char));
18-
1915
// Tell the compiler that we do not have any "call-like" inline assembly in the
2016
// device rutime. That means we cannot have inline assembly which will call
2117
// another function but only inline assembly that performs some operation or
@@ -25,6 +21,31 @@ using size_t = decltype(sizeof(char));
2521
// TODO: Find a good place for this
2622
#pragma omp assumes ext_no_call_asm
2723

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+
///}
2849

2950
enum omp_proc_bind_t {
3051
omp_proc_bind_false = 0,

0 commit comments

Comments
 (0)