[Openmp-commits] [PATCH] D145963: [Libomptarget] Use freestanding stdint.h header for DeviceRTL

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 13 10:22:31 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, ye-luo.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

The `stdint.h` header provides the standard types. Previously we used
`-nostdinc` and defined these ourselves. This patch switches to a
freestanding version which should work properly. Without
`-ffreestanding` the `stdint.h` header will include other libraries. But
in a freestanding environment it should work given the primitives.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145963

Files:
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/include/Types.h


Index: openmp/libomptarget/DeviceRTL/include/Types.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Types.h
+++ openmp/libomptarget/DeviceRTL/include/Types.h
@@ -12,6 +12,10 @@
 #ifndef OMPTARGET_TYPES_H
 #define OMPTARGET_TYPES_H
 
+#include <stdint.h>
+
+using size_t = decltype(sizeof(char));
+
 // Tell the compiler that we do not have any "call-like" inline assembly in the
 // device rutime. That means we cannot have inline assembly which will call
 // another function but only inline assembly that performs some operation or
@@ -21,31 +25,6 @@
 // TODO: Find a good place for this
 #pragma omp assumes ext_no_call_asm
 
-/// Base type declarations for freestanding mode
-///
-///{
-using int8_t = char;
-using uint8_t = unsigned char;
-using int16_t = short;
-using uint16_t = unsigned short;
-using int32_t = int;
-using uint32_t = unsigned int;
-using int64_t = long;
-using uint64_t = unsigned long;
-using size_t = decltype(sizeof(char));
-// TODO: Properly implement this
-using intptr_t = int64_t;
-using uintptr_t = uint64_t;
-
-static_assert(sizeof(int8_t) == 1, "type size mismatch");
-static_assert(sizeof(uint8_t) == 1, "type size mismatch");
-static_assert(sizeof(int16_t) == 2, "type size mismatch");
-static_assert(sizeof(uint16_t) == 2, "type size mismatch");
-static_assert(sizeof(int32_t) == 4, "type size mismatch");
-static_assert(sizeof(uint32_t) == 4, "type size mismatch");
-static_assert(sizeof(int64_t) == 8, "type size mismatch");
-static_assert(sizeof(uint64_t) == 8, "type size mismatch");
-///}
 
 enum omp_proc_bind_t {
   omp_proc_bind_false = 0,
Index: openmp/libomptarget/DeviceRTL/CMakeLists.txt
===================================================================
--- openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -121,7 +121,7 @@
 # Set flags for LLVM Bitcode compilation.
 set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
               ${clang_opt_flags} --offload-device-only
-             -nocudalib -nogpulib -nostdinc
+             -nocudalib -nogpulib -nogpuinc -ffreestanding
              -fopenmp -fopenmp-cuda-mode
              -Wno-unknown-cuda-version
              -I${include_directory}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145963.504742.patch
Type: text/x-patch
Size: 2272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230313/953c817a/attachment.bin>


More information about the Openmp-commits mailing list