[PATCH] D109108: [flang] Use CMake to determine endianness.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 3 13:46:32 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG84e1258febe1: [flang] Use CMake to determine endianness. (authored by Meinersbur).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109108/new/

https://reviews.llvm.org/D109108

Files:
  flang/CMakeLists.txt
  flang/include/flang/Evaluate/common.h
  flang/runtime/environment.h


Index: flang/runtime/environment.h
===================================================================
--- flang/runtime/environment.h
+++ flang/runtime/environment.h
@@ -14,9 +14,9 @@
 
 namespace Fortran::runtime {
 
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if FLANG_BIG_ENDIAN
 constexpr bool isHostLittleEndian{false};
-#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#elif FLANG_LITTLE_ENDIAN
 constexpr bool isHostLittleEndian{true};
 #else
 #error host endianness is not known
Index: flang/include/flang/Evaluate/common.h
===================================================================
--- flang/include/flang/Evaluate/common.h
+++ flang/include/flang/Evaluate/common.h
@@ -133,9 +133,9 @@
 
 static constexpr Rounding defaultRounding;
 
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if FLANG_BIG_ENDIAN
 constexpr bool isHostLittleEndian{false};
-#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#elif FLANG_LITTLE_ENDIAN
 constexpr bool isHostLittleEndian{true};
 #else
 #error host endianness is not known
Index: flang/CMakeLists.txt
===================================================================
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -295,6 +295,14 @@
   add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}")
 endif()
 
+include(TestBigEndian)
+test_big_endian(IS_BIGENDIAN)
+if (IS_BIGENDIAN)
+  add_compile_definitions(FLANG_BIG_ENDIAN=1)
+else ()
+  add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
+endif ()
+
 # Configure Flang's Version.inc file.
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/include/flang/Version.inc.in


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109108.370669.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210903/8a6634fb/attachment.bin>


More information about the llvm-commits mailing list