<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 - wrong sizeof(long double) in 32-bit PowerPC NetBSD, OpenBSD"
href="https://bugs.llvm.org/show_bug.cgi?id=40553">40553</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wrong sizeof(long double) in 32-bit PowerPC NetBSD, OpenBSD
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>OpenBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kernigh@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21414" name="attach_21414" title="sizeof(long double) == 8 in 32-bit PowerPC NetBSD, OpenBSD">attachment 21414</a> <a href="attachment.cgi?id=21414&action=edit" title="sizeof(long double) == 8 in 32-bit PowerPC NetBSD, OpenBSD">[details]</a></span>
sizeof(long double) == 8 in 32-bit PowerPC NetBSD, OpenBSD
clang and gcc are using incompatible formats for long double in my big-endian
32-bit PowerPC machine, a PowerBook G4 running OpenBSD/macppc. clang 6 and 7
have sizeof(long double) == 16, but gcc has sizeof(long double) == 8. This
causes a linker error when a program built with clang tries to pass a long
double to a C++ library built with gcc.
NetBSD might have the same problem. I have qemu running NetBSD/macppc, and its
gcc has sizeof(long double) == 8. I have not tried to target NetBSD with
clang.
clang now uses sizeof(long double) == 8 on FreeBSD; I propose to do the same on
NetBSD and OpenBSD. The attached patch is for llvm-project.git master. I am
now using almost the same patch in clang 7.0.1, where the line to check for
FreeBSD was different, but you can apply the attached patch by hand.
This is a simple example of the problem:
$ cat szld.cc
#include <iostream>
void f(long double ld) {
std::cout << "sizeof(ld) = " << sizeof(ld) << std::endl;
}
int main() { f(0.0L); }
$ gcc -o szld-gcc szld.cc
$ clang -o szld-clang szld.cc
$ ./szld-gcc
sizeof(ld) = 8
$ ./szld-clang
sizeof(ld) = 16
$ nm -C szld-gcc | grep 'f('
00000798 T f(long double)
$ nm -C szld-clang | grep 'f('
000005a8 T f(__float128)
My OpenBSD/macppc machine has gcc 4.2.1 using libstdc++, gcc 8.2.0 installed as
egcc using libestdc++, and clang 7.0.1 using the same libestdc++ as gcc 8.2.0.
The linker is GNU ld 2.17. I got a linker error because KDE's kdiagram, built
with clang, wanted to call something(__float128), but libestdc++, built with
gcc, defined something(long double).
My patch seems to work in clang 7.0.1 (built from devel/llvm in OpenBSD's ports
tree in about 36 hours by my PowerBook G4), but I'm less sure about git master.
I can't run git master on my best machine (OpenBSD/amd64, 2 cores, 4G RAM). I
used <a href="https://clang.llvm.org/get_started.html">https://clang.llvm.org/get_started.html</a> but learned the hard way that 4G
RAM is too small to build clang with debug info. I was able to build git
master this way:
exec cmake \
-DCMAKE_DISABLE_FIND_PACKAGE_Backtrace=ON \
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=ON \
-DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=PowerPC \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DCMAKE_BUILD_TYPE=MinSizeRel -G Ninja ../llvm
ninja -j2 clang
But I can't run it:
pehcehwahn$ bin/clang-9
ksh: bin/clang-9: Cannot allocate memory
I now have a 142M bin/clang-9 linked to a 108M lib/libLLVM-9svn.so, but clang-9
might be too big, and I don't know how to make it smaller.</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>