<html>
<head>
<base href="http://bugzilla.gdcproject.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:johannespfau@gmail.com" title="Johannes Pfau <johannespfau@gmail.com>"> <span class="fn">Johannes Pfau</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Undefined reference to libcurl functions with small program (not explicitly using network)."
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=202">bug 202</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>johannespfau@gmail.com
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Undefined reference to libcurl functions with small program (not explicitly using network)."
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=202#c10">Comment # 10</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Undefined reference to libcurl functions with small program (not explicitly using network)."
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=202">bug 202</a>
from <span class="vcard"><a class="email" href="mailto:johannespfau@gmail.com" title="Johannes Pfau <johannespfau@gmail.com>"> <span class="fn">Johannes Pfau</span></a>
</span></b>
<pre>I think I've found the problem:
fail.d
------------------------------------------
int main()
{
import std.stdio;
import std.conv;
stdin.byLine();
char[] s;
to!int(s);
parse!int(s);
return 0;
}
------------------------------------------
ok.d
------------------------------------------
int main()
{
import std.stdio;
import std.conv;
stdin.byLine();
char[] s;
parse!int(s);
to!int(s);
return 0;
}
------------------------------------------
gdc fail.d // linker error
gdc ok.d // works
gdc fail.d -c -o fail.o
gdc fail.o // linker error
gdc ok.d -c -o ok.o
gdc ok.o // works
nm fail.o > fail.sym
nm ok.o > ok.sym
diff -u fail.sym ok.sym
- U _D3std5array15__T8popFrontTaZ8popFrontFNaNbNiNeKAaZv
+0000000000000000 W _D3std5array15__T8popFrontTaZ8popFrontFNaNbNiNeKAaZv
nm /usr/lib64/libgphobos2.a > sym.txt
_D3std5array15__T8popFrontTaZ8popFrontFNaNbNiNeKAaZv is in curl.o
So what happens is this: In some cases template instances are not emitted as
weak symbols, probably as the compiler correctly infers these templates are
already instantiated in some of the imported modules. The symbol is actually
defined in the curl.o object file though, so it will be linked into the
executable.
I'm not sure whether this actually is a DMD template bug where the compiler
should emit the template (as there is no
_D3std5array15__T8popFrontTaZ8popFrontFNaNbNiNeKAaZv in any other module). OTOH
maybe _D3std5array15__T8popFrontTaZ8popFrontFNaNbNiNeKAaZv should be emitted in
other modules as well (this should be a very common function), but packaging
into a static library merged the weak symbols and unfortunately chose the one
from curl.o?
As a workaround, -femit-templates should work.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>