segmentation fault compiling program with OpenMP pragmas

Hi,

I have installed llvm-trunk to use OpenMP target pragmas. Unfortunately, I get
a segmentation fault compiling a small program.

loki introduction 722 clang -v clang version 5.0.0 (trunk 308176) (llvm/trunk 308177)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/llvm-trunk/bin
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Selected GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 8.0

loki introduction 723 clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda dot_prod_accelerator_OpenMP.c -lomptarget
clang-5.0: error: cannot find libdevice for . Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice.
#0 0x00007f6e7b1a11ea llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/llvm-trunk/lib64/libLLVMSupport.so.5+0xfc1ea)
#1 0x00007f6e7b19f32e llvm::sys::RunSignalHandlers() (/usr/local/llvm-trunk/lib64/libLLVMSupport.so.5+0xfa32e)
#2 0x00007f6e7b19f468 SignalHandler(int) (/usr/local/llvm-trunk/lib64/libLLVMSupport.so.5+0xfa468)
#3 0x00007f6e7e2d1b10 __restore_rt (/lib64/libpthread.so.0+0x10b10)
#4 0x00007f6e7d5b8dd0 clang::driver::tools::NVPTX::Linker::ConstructJob(clang::driver::Compilation&, clang::driver::JobAction const&, clang::driver::InputInfo const&, llvm::SmallVector<clang::driver::InputInfo, 4u> const&, llvm::opt::ArgList const&, char const*) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0xc5dd0)
#5 0x00007f6e7d5591ac clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::map<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, clang::driver::InputInfo, std::less<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x661ac)
#6 0x00007f6e7d55ab69 clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::map<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, clang::driver::InputInfo, std::less<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x67b69)
#7 0x00007f6e7d55c9b2 void llvm::function_ref<void (clang::driver::Action*, clang::driver::ToolChain const*, char const*)>::callback_fn<clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::map<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, clang::driver::InputInfo, std::less<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const::{lambda(clang::driver::Action*, clang::driver::ToolChain const*, char const*)#2}>(long, clang::driver::Action*, clang::driver::ToolChain const*, char const*) (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x699b2)
#8 0x00007f6e7d53e97c clang::driver::OffloadAction::doOnEachDeviceDependence(llvm::function_ref<void (clang::driver::Action*, clang::driver::ToolChain const*, char const*)> const&) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x4b97c)
#9 0x00007f6e7d5584e9 clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::map<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, clang::driver::InputInfo, std::less<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x654e9)
#10 0x00007f6e7d55ab69 clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::map<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, clang::driver::InputInfo, std::less<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::pair<std::pair<clang::driver::Action const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x67b69)
#11 0x00007f6e7d55b7fb clang::driver::Driver::BuildJobs(clang::driver::Compilation&) const (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x687fb)
#12 0x00007f6e7d55c7a9 clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>) (/usr/local/llvm-trunk/lib64/libclangDriver.so.5+0x697a9)
#13 0x000000000040e733 (clang+0x40e733)
#14 0x00007f6e78e456e5 __libc_start_main /usr/src/debug/glibc-2.22/csu/libc-start.c:323:0
#15 0x0000000000410759 (clang+0x410759)
Stack dump:
0. Program arguments: clang -m64 -O2 -g -Weverything -Wno-unused-command-line-argument -DLinux -Dx86_64 -I/usr/local/valgrind-3.12.0/include -I/usr/local/intel/opencl-1.2-sdk-6.3.0.1904/include -I/usr/local/include -I/usr/include -I/usr/local/cuda-8.0/include -I/usr/local/hwloc-1.11.5/include -I/home/fd1026/Linux/x86_64/include -L/home/fd1026/Linux/x86_64/lib64 -L/usr/local/valgrind-3.12.0/lib -L/usr/local/jdk1.8.0_66/jre/lib/amd64 -L/usr/local/intel/opencl-1.2-sdk-6.3.0.1904/lib64 -L/usr/local/llvm-trunk/lib64 -L/usr/local/pgi/linux86-64/16.10/lib -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/compiler/lib/intel64 -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/compiler/lib/intel64_lin -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/mpi/intel64/lib -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/mpi/mic/lib -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/ipp/lib/intel64 -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/compiler/lib/intel64_lin -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/mkl/lib/intel64_lin -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/tbb/lib/intel64/gcc4.7 -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/tbb/lib/intel64/gcc4.7 -L/usr/local/intel_xe_2018_beta/debugger_2018//libipt/intel64/lib -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/daal/lib/intel64_lin -L/usr/local/intel_xe_2018_beta/compilers_and_libraries_2018.0.082/linux/daal/../tbb/lib/intel64_lin/gcc4.4 -L/usr/local/gcc-7.1.0/lib64 -L/usr/local/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0 -L/usr/local/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0 -L/usr/local/lib64 -L/usr/X11R6/lib64 -L/lib64 -L/usr/lib64 -L/usr/lib64/tls -L/usr/local/lib -L/usr/X11R6/lib -L/lib -L/usr/lib -L/usr/lib/tls -L/usr/local/gcc-7.1.0/lib -L/usr/local/gcc-7.1.0/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/32 -L/usr/local/gcc-7.1.0/lib/gcc/x86_64-pc-linux-gnu/7.1.0/32 -L/usr/local/cuda-8.0/lib64 -L/usr/local/hwloc-1.11.5/lib -L/usr/local/swipl-7.2.3/lib/x86_64-linux -L/home/fd1026/Linux/x86_64/lib -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda dot_prod_accelerator_OpenMP.c -lomptarget
1. Compilation construction
2. Building compilation jobs
3. Building compilation jobs
4. Building compilation jobs
Segmentation fault (core dumped)
loki introduction 724

My program works with gcc-7.1.0.

loki introduction 727 gcc -fopenmp dot_prod_accelerator_OpenMP.c
loki introduction 728 setenv OMP_DEFAULT_DEVICE 0
loki introduction 729 /usr/bin/time -p a.out
Number of processors: 24
Number of devices: 1
Default device: 0
sum = 6.000000e+08
real 4.80
user 0.00
sys 0.00
loki introduction 730 setenv OMP_DEFAULT_DEVICE 1
loki introduction 731 /usr/bin/time -p a.out
Number of processors: 24
Number of devices: 1
Default device: 1
sum = 6.000000e+08
real 0.43
user 0.00
sys 0.00
loki introduction 732

I would be grateful if somebody can fix the problem. Please let me know
if you need anything else. Thank you very much for any help in advance.

Kind regards

Siegmar

dot_prod_accelerator_OpenMP.c (1.04 KB)

[+Doru]

Can you please file a bug report (at )?

Thanks again,

Hal