[llvm-bugs] [Bug 41861] New: Compilation errors when including iostream in OpenMP NVPTX offloading code
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 13 08:26:21 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41861
Bug ID: 41861
Summary: Compilation errors when including iostream in OpenMP
NVPTX offloading code
Product: OpenMP
Version: unspecified
Hardware: Other
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Clang Compiler Support
Assignee: unassignedclangbugs at nondot.org
Reporter: p.atkinson at bristol.ac.uk
CC: llvm-bugs at lists.llvm.org
The following code will fail to compile with Clang configured to use OpenMP
NVPTX offloading.
#include <cstdio>
#include <iostream>
int main()
{
#pragma omp target
{
printf("foo\n");
}
}
Compiler output:
~ $ clang++ test.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
-Xopenmp-target -march=sm_60
In file included from test.cpp:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:42:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/ios_base.h:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ext/atomicity.h:35:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/gthr.h:148:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/gthr-default.h:35:
In file included from /usr/include/pthread.h:24:
/usr/include/time.h:189:16: error: functions that differ only in their return
type cannot be overloaded
extern clock_t clock (void) __THROW;
~~~~~~~ ^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:1496:16:
note: previous definition is here
__DEVICE__ int clock() { return __nvvm_read_ptx_sreg_clock(); }
~~~ ^
In file included from test.cpp:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:42:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/ios_base.h:41:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/locale_classes.h:40:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/string:52:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/basic_string.h:2815:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ext/string_conversions.h:41:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
error: declaration conflicts with target of using declaration already in scope
abs(long __i) { return __builtin_labs(__i); }
^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
note: target of using declaration
__DEVICE__ long abs(long __n) { return ::labs(__n); }
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
note: using declaration
using ::abs;
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
error: declaration conflicts with target of using declaration already in scope
abs(long long __x) { return __builtin_llabs (__x); }
^
/lustre/home/br-patkinson/modules/x86_64/llvm/install/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
note: target of using declaration
__DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
note: using declaration
using ::abs;
^
3 errors generated.
It seems there's a declaration conflict between the C standard library headers
and the '__clang_cuda' headers.
When '#include <iostream>' is removed from the above example, the code compiles
and works fine.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190513/54974d21/attachment.html>
More information about the llvm-bugs
mailing list