Build Clang with CMake and Intel Compiler

Hello everyone,

keep failing to build Clang 3.4 with icpc, giving me 'Error: CFI
instruction used without previous .cfi_startproc' repeatedly. I tried
CMAKE_BUILD_TYPE=DEBUG and compiler flags -g and
-fno-asynchronous-unwind-tables, but it was no use. I am using icpc 14
(in GCC 4.8 compatibility mode) on Scientific Linux 6.4. I hope you can
help me out. LLVM without Clang succeeds to build.

On a related note, is there a canonical way to disable all the Sanitizers?

Best regards,
Marvin

[ 66%] Built target clang_rt.ubsan-x86_64
[ 66%] Built target clang_rt.ubsan-x86_64-symbols
[ 66%] Built target clang_rt.ubsan_cxx-x86_64
[ 66%] Built target clang_rt.ubsan_cxx-x86_64-symbols
[ 66%] Building CXX object
projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/rtl/tsan_interface_atomic.cc.o
icpc: command line warning #10006: ignoring unknown option '-funwind-tables'
icpc: command line warning #10006: ignoring unknown option '-Wno-gnu'
icpc: command line warning #10006: ignoring unknown option
'-Wframe-larger-than=512'
/tmpdir/ccsscratch/16720/icpcxWB4IQas_.s: Assembler messages:
/tmpdir/ccsscratch/16720/icpcxWB4IQas_.s:4098: Error: CFI instruction
used without previous .cfi_startproc
/tmpdir/ccsscratch/16720/icpcxWB4IQas_.s:4807: Error: CFI instruction
used without previous .cfi_startproc
...
/tmpdir/ccsscratch/16720/icpcxWB4IQas_.s:45623: Error: CFI instruction
used without previous .cfi_startproc
/tmpdir/ccsscratch/16720/icpcxWB4IQas_.s:45623: Error: CFI instruction
used without previous .cfi_startproc
make[2]: ***
[projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/rtl/tsan_interface_atomic.cc.o]
Error 1
make[1]: ***
[projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/all]
Error 2
make: *** [all] Error 2

This error reports comes from building tsan (ThreadSanitizer) run-time.
First: do you need it?
Second: try to hack compiler-rt/lib/sanitizer_common/sanitizer_asm.h
to disable CFI directives.

Apparently icpc is not fully gcc-compatible it it barks on -funwind-tables

–kcc

This error reports comes from building tsan (ThreadSanitizer) run-time.
First: do you need it?

I do not need it, but I am not too familiar with the clang build
process. How do I disable it? Would commenting out the
'add_compiler_rt_static_runtime' and 'add_compiler_rt_static_runtime' in
the CMakeLists be sufficient?

Second: try to hack compiler-rt/lib/sanitizer_common/sanitizer_asm.h
to disable CFI directives.

Apparently, sanitizer_asm.h was added in trunk after 3.4 to solve
exactly the problem I am having right now. However, I am bound to 3.4
because I want to use Intel's OpenMP extensions eventually. I think
disabling the problematic sanitizers is the way to go for me now.

Thank you
Marvin

> This error reports comes from building tsan (ThreadSanitizer) run-time.
> First: do you need it?

I do not need it, but I am not too familiar with the clang build
process. How do I disable it? Would commenting out the
'add_compiler_rt_static_runtime' and 'add_compiler_rt_static_runtime' in
the CMakeLists be sufficient?

Do you need compiler-rt at all? If no, just don't check it out.

> Second: try to hack compiler-rt/lib/sanitizer_common/sanitizer_asm.h
> to disable CFI directives.

Apparently, sanitizer_asm.h was added in trunk after 3.4 to solve
exactly the problem I am having right now. However, I am bound to 3.4
because I want to use Intel's OpenMP extensions eventually. I think
disabling the problematic sanitizers is the way to go for me now.

Ah, so trunk does not trouble you.
Then just comment out the cfi directives in your variant of 3.4 whenever
you find them (couple of places in compiler-rt/lib/sanitizer_common and
compiler-rt/lib/tsan)

Do you need compiler-rt at all? If no, just don't check it out.

I mistakenly assumed compiler-rt to be mandatory, it builds perfectly
fine without it. Thanks for your help!

From: "Marvin Damschen" <marvin.damschen@gullz.de>
To: "Kostya Serebryany" <kcc@google.com>
Cc: "Clang Developer's Mailing List" <cfe-dev@cs.uiuc.edu>
Sent: Wednesday, March 19, 2014 9:47:14 AM
Subject: Re: [cfe-dev] Build Clang with CMake and Intel Compiler

> This error reports comes from building tsan (ThreadSanitizer)
> run-time.
> First: do you need it?

I do not need it, but I am not too familiar with the clang build
process. How do I disable it? Would commenting out the
'add_compiler_rt_static_runtime' and 'add_compiler_rt_static_runtime'
in
the CMakeLists be sufficient?

> Second: try to hack
> compiler-rt/lib/sanitizer_common/sanitizer_asm.h
> to disable CFI directives.

Apparently, sanitizer_asm.h was added in trunk after 3.4 to solve
exactly the problem I am having right now. However, I am bound to 3.4
because I want to use Intel's OpenMP extensions eventually.

This is not true. With Intel's assistance, I maintain a trunk-rebased version of the patchset: https://github.com/clang-omp/clang_trunk -- it sometimes lags the "release" branch in terms of features, but if you need something specific, please let me know and I'll get it done. This branch is what I use to make our internal release candidates.

-Hal