From 78e29ea83d0ca2a50be3d981e0c1c6b176e69222 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sun, 28 Apr 2024 20:17:46 +0100 Subject: [PATCH 1/2] [GHA] remove explicit setting of xcode version Fixes #1411 --- .github/workflows/build-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 7d1e65357..8c0cb93cb 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -162,9 +162,6 @@ jobs: CXX=${CXX}-${{ matrix.compiler_version }} fi if test 'XX${{ matrix.os }}' = 'XXmacOS-latest'; then - # need to force XCode version for the moment due to a linker bug - # see https://github.com/UCL/STIR/issues/1103 - echo DEVELOPER_DIR="/Applications/Xcode_14.1.app/Contents/Developer" >> $GITHUB_ENV if test 'XX${{ matrix.compiler }}' = 'XXclang'; then brew install llvm@${{ matrix.compiler_version }} if test XX${HOMEBREW_PREFIX} = XX; then From 5ccb4409cc14230953bb8d50cb2ceb7bed7250e7 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Tue, 30 Apr 2024 22:24:40 +0100 Subject: [PATCH 2/2] update Byte Order compile-time checks previous version failed on macos-14-arm64. We have a very fragile list of checks. Presumably, CMake does a lot better, so use CMAKE_CXX_BYTE_ORDER in ByteOrderDefine (via config.h) --- documentation/release_6.1.htm | 5 +++++ src/CMakeLists.txt | 12 ++++++++++++ src/cmake/STIRConfig.h.in | 4 ++++ src/include/stir/ByteOrderDefine.h | 12 ++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/documentation/release_6.1.htm b/documentation/release_6.1.htm index 562fa25c9..1bb9ab02d 100644 --- a/documentation/release_6.1.htm +++ b/documentation/release_6.1.htm @@ -70,6 +70,11 @@

Bug fixes

  • The Relative Difference Prior gave incorrect results, probably since switching to C++-14 in version 6.0, although we are not sure. See PR #1410 and associated issue #1409.
  • +
  • + Our checks for determining system byte-order were out-of-date and in particular did not work on MacOS 14 on ARM. + We now use CMake's CMAKE_CXX_BYTE_ORDER (available since CMake 3.20). + See PR #1412. +
  • Known problems

    diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4101bf85d..7a731c2e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,18 @@ else() set(STIR_USE_BOOST_SHARED_PTR ON) endif() +# Byte order +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + # Use CMake to find byte order of target system. + # We create some variables that are then used in config.h.in + if (CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN") + set(BIG_ENDIAN_BYTE_ORDER_FROM_CMAKE TRUE) + message(STATUS "CMake detected a big_endian system") + elseif (CMAKE_CXX_BYTE_ORDER STREQUAL "LITTLE_ENDIAN") + set(LITTLE_ENDIAN_BYTE_ORDER_FROM_CMAKE TRUE) + message(STATUS "CMake detected a little_endian system") + endif() +endif() #### Create stir/config.h diff --git a/src/cmake/STIRConfig.h.in b/src/cmake/STIRConfig.h.in index 515f021e5..ecb62fa4a 100644 --- a/src/cmake/STIRConfig.h.in +++ b/src/cmake/STIRConfig.h.in @@ -52,6 +52,10 @@ namespace stir { #include "boost/config.hpp" +// 2 variables set via CMake +#cmakedefine BIG_ENDIAN_BYTE_ORDER_FROM_CMAKE +#cmakedefine LITTLE_ENDIAN_BYTE_ORDER_FROM_CMAKE + #cmakedefine HAVE_ECAT #ifdef HAVE_ECAT #define HAVE_LLN_MATRIX diff --git a/src/include/stir/ByteOrderDefine.h b/src/include/stir/ByteOrderDefine.h index de909de3b..456502afa 100644 --- a/src/include/stir/ByteOrderDefine.h +++ b/src/include/stir/ByteOrderDefine.h @@ -23,10 +23,14 @@ START_NAMESPACE_STIR // currently checked by asserts() -#if !defined(__alpha) && (!defined(_WIN32) || defined(_M_PPC) || defined(_M_MPPC)) && !defined(__i386__) && !defined(__i486__) \ - && !defined(__i586__) && !defined(__i686__) && !defined(__i786__) && !defined(__i886__) && !defined(__k6__) \ - && !defined(__athlon__) && !defined(__x86_64__) && !defined(__k6__) \ - || (defined(__MSL__) && !defined(__LITTLE_ENDIAN)) +// partially from https://stackoverflow.com/a/27054190 +#if defined(BIG_ENDIAN_BYTE_ORDER_FROM_CMAKE) /* variable set via CMake in stir/config.h */ \ + || (!defined(LITTLE_ENDIAN_BYTE_ORDER_FROM_CMAKE) /* variable set via CMake in stir/config.h */ \ + && ((!defined(__alpha) && (!defined(_WIN32) || defined(_M_PPC) || defined(_M_MPPC)) && !defined(__i386__) \ + && !defined(__i486__) && !defined(__i586__) && !defined(__i686__) && !defined(__i786__) && !defined(__i886__) \ + && !defined(__k6__) && !defined(__athlon__) && !defined(__x86_64__) && !defined(__k6__)) \ + || (defined(__MSL__) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) \ + || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) /* gcc */) || defined(__BIG_ENDIAN__))) # define STIRIsNativeByteOrderBigEndian 1 # define STIRIsNativeByteOrderLittleEndian 0 #else