[Openmp-commits] [PATCH] D98565: [libomptarget][amdgcn] Drop use of inttypes.h, moving closer to freestanding

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Mar 12 15:47:31 PST 2021


JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, tianshilei1992, grokos, ronlieb.
Herald added a subscriber: jvesely.
JonChesterfield requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

[libomptarget][amdgcn] Drop use of inttypes.h, moving closer to freestanding

The glibc headers are a periodic source of problems compiling the devicertl.
This patch resolves the following error run into while building llvm on a slightly
different linux system.

In file included from .../lib/clang/13.0.0/include/inttypes.h:21:
In file included from /usr/include/inttypes.h:25:
/usr/include/features.h:461:12: fatal error: 'sys/cdefs.h' file not found

include <sys/cdefs.h>
=====================

  ^~~~~~~~~~~~~

As a second patch, removing assert.h from shuffle will let amdgcn build as
-ffreestanding, at which point only the headers that clang itself provides are
used and interactions with the host glibc are eliminated. Doing the same for
nvptx is complicated by printf handling but also seems worthwhile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98565

Files:
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/include/target/shuffle.h


Index: openmp/libomptarget/deviceRTLs/common/include/target/shuffle.h
===================================================================
--- openmp/libomptarget/deviceRTLs/common/include/target/shuffle.h
+++ openmp/libomptarget/deviceRTLs/common/include/target/shuffle.h
@@ -16,7 +16,7 @@
 #define LIBOMPTARGET_DEVICERTL_SHUFFLE_H
 
 #include <assert.h>
-#include <inttypes.h>
+#include <stdint.h>
 
 #pragma omp declare target
 
Index: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -18,10 +18,13 @@
 
 #include "amdgcn_interface.h"
 
-#include <inttypes.h>
 #include <stddef.h>
 #include <stdint.h>
 
+// subset of inttypes.h
+#define PRId64 "ld"
+#define PRIu64 "lu"
+
 #define DEVICE
 #define INLINE inline DEVICE
 #define NOINLINE __attribute__((noinline)) DEVICE


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98565.330391.patch
Type: text/x-patch
Size: 970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210312/b9db269c/attachment.bin>


More information about the Openmp-commits mailing list