[all-commits] [llvm/llvm-project] 84e125: [flang] Use CMake to determine endianness.

Michael Kruse via All-commits all-commits at lists.llvm.org
Fri Sep 3 13:46:31 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84e1258febe1f179e5d4e1914be7b727d2296336
      https://github.com/llvm/llvm-project/commit/84e1258febe1f179e5d4e1914be7b727d2296336
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-09-03 (Fri, 03 Sep 2021)

  Changed paths:
    M flang/CMakeLists.txt
    M flang/include/flang/Evaluate/common.h
    M flang/runtime/environment.h

  Log Message:
  -----------
  [flang] Use CMake to determine endianness.

The preprocessor definitions __BYTE_ORDER__, __ORDER_BIG_ENDIAN__, and
__ORDER_LITTLE_ENDIAN__ are gcc extensions (also supported by clang),
but msvc (and others) do not define them. As a result __BYTE_ORDER__
and __ORDER_BIG_ENDIAN__ both evaluate to 0 by the prepreprocessor,
and __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__, the first `#if` condition
to 1, hence assuming the wrong byte order for x86(_64).

This patch instead uses CMake's TestBigEndian module to determine
target architecture's endianness at configure-time.

Note this also uses the same mechanism for the runtime. If compiling
flang as a cross-compiler, the runtime for the compile-target must be
built separately (Flang does not support the LLVM_ENABLE_RUNTIMES
mechanism yet).

Fixes llvm.org/PR51597

Reviewed By: ijan1, Leporacanthicus

Differential Revision: https://reviews.llvm.org/D109108




More information about the All-commits mailing list