While trying to take advantage of the Eigen's OpenMP feature in my program, I encounter a crash of the compiler.
Below is my software configuration:
• Eigen: from the development branch, because my program heavily uses the call operator with std::vector<int> arguments for slicing.
• Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
The -fopenmp flag is passed to the compiler through the -Xclang -fopenmp option, which works fine as long as no Eigen header is included.
When I include an Eigen header, say #include <Eigen/Core>, I get a compiler crash, which is not really explicit (given a the bottom of my message). No need to add any Eigen-related code except the include directive to make the compiler crash.
Note that it does not crash (and works fine when doing some basic GEMM products) using the last stable release of Eigen (3.3.7). That's why I'm filing this bug to the Eigen team, instead (for the moment) of the LLVM/Clang team.
Below is the bug description. It references some files, that I can join but basically correspond to the preprocessed sources.
Thank's in advance,
clang: error: unable to execute command: Illegal instruction: 4
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/t0/j2js0fb94qq4n_zt7qyljvtm0000gn/T/main-e29e5c.cpp
clang: note: diagnostic msg: /var/folders/t0/j2js0fb94qq4n_zt7qyljvtm0000gn/T/main-e29e5c.sh
clang: note: diagnostic msg: /var/folders/t0/j2js0fb94qq4n_zt7qyljvtm0000gn/T/main-e29e5c.crash
clang: note: diagnostic msg:
This does look like a clang/xcode issue, so you should also report it to the clang/llvm team. Still, if we want to work-around this, it would be nice if you could bisect to the first Eigen version which causes the issue. Also, does it fail with an otherwise empty .cpp file (except the `#include` and maybe an empty main function)? -- If so, use that to make a report at the LLVM bugtracker.
And please cross-reference to that bug-report (and maybe back as well).
Unfortunately, it seems that, since I don't have a paid developer account, I can't submit bug reports.
There is a more general feeback assisant, but it does not include developer applications, like the compiler or Xcode itself.
Regarding the Eigen side of the problem, I think I have located the changeset that causes the compiler crash.
The crash appears at changeset 31995b2 by Gael Guennebaud on 2017-01-19, with message 'Add support for fixed-value in symbolic expression, c++11 only for now' (https://bitbucket.org/eigen/eigen/commits/31995b21892185c8f48a80767111af58f2a1924e).
In file Eigen/src/Core/util/IndexedViewHelper.h, commenting line 63 suffices to workaround the compiler crash. But I don't know if it leads to problems other than the use of the 'end' flag.
In the latest version of the code, it is (to me) a bit more tricky to workaround this crash because of the evolutions of the code in two years (I not familiar with the internals of Eigen).
I hope these precisions will help.
Feel free to ask me to do some tests if necessary.
I just realize that the crash is connected to the '-std=gnu++14' option for LLVM/Clang.
Switching to 'gnu++11' works fine.
So, still based on changeset 31995b2, and still at line 63 of file Eigen/src/Core/util/IndexedViewHelper.h, replacing end(last+fix<1>()) by the gnu++11 version (defined in Eigen/src/Core/util/IntegralConstant.h): end(last+Eigen::internal::fix_t<1>()) compiles without crash.