Skip to content

Commit e7655ad

Browse files
authored
[Libomptarget] Remove unnecessary CMake definition of endiannness (#77205)
Summary: This is needed for some definition in `hsa.h` that requires this to be set for some architectures when it fails at autodetection. We only really build `libomptarget` with `gcc` and `clang` which already provide their own way of detecting this. Remove the unnecessary define and move it into the source.
1 parent daa4728 commit e7655ad

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ add_definitions(-DTARGET_NAME=AMDGPU)
3535
# requires changing the original plugins.
3636
add_definitions(-DDEBUG_PREFIX="TARGET AMDGPU RTL")
3737

38-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc64le)|(aarch64)$")
39-
add_definitions(-DLITTLEENDIAN_CPU=1)
40-
endif()
41-
42-
if(CMAKE_BUILD_TYPE MATCHES Debug)
43-
add_definitions(-DDEBUG)
44-
endif()
45-
4638
set(LIBOMPTARGET_DLOPEN_LIBHSA OFF)
4739
option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" ${LIBOMPTARGET_DLOPEN_LIBHSA})
4840

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
#include "llvm/Support/Program.h"
4444
#include "llvm/Support/raw_ostream.h"
4545

46+
#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__) || \
47+
!defined(__ORDER_BIG_ENDIAN__)
48+
#error "Missing preprocessor definitions for endianness detection."
49+
#endif
50+
51+
// The HSA headers require these definitions.
52+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
53+
#define LITTLEENDIAN_CPU
54+
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
55+
#define BIGENDIAN_CPU
56+
#endif
57+
4658
#if defined(__has_include)
4759
#if __has_include("hsa/hsa.h")
4860
#include "hsa/hsa.h"

0 commit comments

Comments
 (0)