[Openmp-commits] [PATCH] D97413: [OpenMP] Fix clang-cl build error regarding TSX intrinsics

Hans Wennborg via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 25 02:17:20 PST 2021


hans added a comment.

I tried this, and it didn't fix the build error for me.

In the CMake log I see this:

  -- Performing Test LIBOMP_HAVE_MRTM_FLAG
  -- Performing Test LIBOMP_HAVE_MRTM_FLAG - Success
  [..]
  -- Performing Test LIBOMP_HAVE_RTM_INTRINSICS
  -- Performing Test LIBOMP_HAVE_RTM_INTRINSICS - Failed

And in CMakeError.log:

  Performing C++ SOURCE FILE Test LIBOMP_HAVE_RTM_INTRINSICS failed with the following output:
  Change Dir: C:/src/llvm.monorepo/build.32selfhost/CMakeFiles/CMakeTmp
  
  Run Build Command(s):C:/src/depot_tools/ninja.exe cmTC_fb778 && [1/2] Building CXX object CMakeFiles\cmTC_fb778.dir\src.cxx.obj
  FAILED: CMakeFiles/cmTC_fb778.dir/src.cxx.obj 
  c:\src\llvm.monorepo\build.32\bin\clang-cl.exe  /nologo -TP -DATTRIBUTE_RTM -DATTRIBUTE_WAITPKG -DIMMINTRIN_H  /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /Brepro /bigobj /W4  -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion /Gw -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -DLIBOMP_HAVE_RTM_INTRINSICS  -Werror=unguarded-availability-new /MTd /Zi /Ob0 /Od /RTC1   -std:c++14 /showIncludes /FoCMakeFiles\cmTC_fb778.dir\src.cxx.obj /FdCMakeFiles\cmTC_fb778.dir\ -c src.cxx
  src.cxx(12,16): error: use of undeclared identifier '_xbegin'
          return _xbegin();
                 ^
  1 error generated.
  ninja: build stopped: subcommand failed.
  
  
  Source file was:
  // check for attribute rtm and rtm intrinsics
        #ifdef IMMINTRIN_H
        #include <immintrin.h>
        #endif
        #ifdef INTRIN_H
        #include <intrin.h>
        #endif
        #ifdef ATTRIBUTE_RTM
        __attribute__((target("rtm")))
        #endif
        static inline int __kmp_xbegin() {
          return _xbegin();
        }
        int main() { int a = __kmp_xbegin(); return a; }

It seems the `-mrtm` flag was never passed to clang-cl.

But if I change the patch to do

  set(CMAKE_REQUIRED_FLAGS)
  libomp_append(CMAKE_REQUIRED_FLAGS -mrtm LIBOMP_HAVE_MRTM_FLAG)

It works.

I'm not familiar with libomp's cmake stuff, but maybe libomp_append doesn't work if the variable is previously not defined?
My tweak should maybe not be taken as-is, since it would overwrite CMAKE_REQUIRED_FLAGS if it was non-empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97413



More information about the Openmp-commits mailing list