<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - compile-time segfault with C code when using `-g`"
href="https://bugs.llvm.org/show_bug.cgi?id=47618">47618</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>compile-time segfault with C code when using `-g`
</td>
</tr>
<tr>
<th>Product</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Clang Compiler Support
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bertoni@anl.gov
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hello,
I see a compile-time segfault if I compile a simple C OpenMP offload code with
`-g` (see reproducer below). It will compile and run properly without `-g`, and
it will also compile and run properly if it's renamed as a C++ file (test.cpp)
and compiled with clang++. This is a minor issue, since it has so many
workarounds.
# Steps to reproduce:
```
$ cat test.c
#include "stdio.h"
int main()
{
int n = 0;
#pragma omp target map(from:n)
n = 9;
printf( "Expected: 9, Got: %d\n", n);
return 0;
}
$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -g test.c
clang-12: error: unable to execute command: Segmentation fault
clang-12: error: ptxas command failed due to signal (use -v to see invocation)
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
66bcb14312a08b5d7e1197d23d748b2e23c4d852)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
clang-12: note: diagnostic msg: Error generating preprocessed source(s).
```
It works fine without `-g`, so looks like it has something to do with that:
```
$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda test.c
(base) [bertoni@gpu00 tmp]$ ./a.out
Expected: 9, Got: 9
```
# Compiler version:
All the versions I tried fail:
```
$ clang -v
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
66bcb14312a08b5d7e1197d23d748b2e23c4d852)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
Found candidate GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Selected GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /soft/compilers/cuda/cuda-10.0.130, version 10.0
```
also
```
$ clang -v
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
6313f5561945930e9a5ec63cb187605ce741bb61)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-latest/bin
Found candidate GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Selected GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /soft/compilers/cuda/cuda-10.0.130, version 10.0
```
# Platform:
x86 + Nvidia V100
Thanks,
Colleen</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>