OK, so I think I found a bug, but I have no idea how to "reproduce" it.
It seems to be dependent on environment.
Here is an annotated (using # for comments) session to show you the
weirdness. All versions are 2.067, and I did use dmd -v to make sure
rogue dmd.conf or library files are not playing any role, and that the
files I compare below are being used. Please help figure this out :)
# This shows where dmd runs from when I use the command 'dmd'.
# this was installed using the dmg from dlang.org for 2.067
Stevens-MacBook-Pro:teststatic steves$ type dmd
dmd is hashed (/usr/bin/dmd)
# inside ~/Downloads/dmd2 is an unzipped copy of dmd 2.067. Note
# the binaries and libraries are identical (no output from cmp)
Stevens-MacBook-Pro:teststatic steves$ cmp /usr/bin/dmd
~/Downloads/dmd2/osx/bin/dmd
Stevens-MacBook-Pro:teststatic steves$ cmp
/usr/share/dmd/lib/libphobos2.a ~/Downloads/dmd2/osx/lib/libphobos2.a
# Now, checking concurrency.d text, also identical
Stevens-MacBook-Pro:teststatic steves$ diff
/usr/share/dmd/src/phobos/std/concurrency.d
~/Downloads/dmd2/src/phobos/std/concurrency.d
# and finally checking core.thread text, also identical
Stevens-MacBook-Pro:teststatic steves$ diff
/usr/share/dmd/src/druntime/import/core/thread.d
~/Downloads/dmd2/src/druntime/import/core/thread.d
# here is the program being compiled (I was testing something for a
# forum post)
Stevens-MacBook-Pro:teststatic steves$ cat mod1.d
module mod1;
import std.concurrency;
import std.stdio;
__gshared static int foo;
void main()
{
auto tid = spawn((Tid o){foo = 5; o.send(true);}, thisTid);
receiveOnly!bool();
writeln(foo);
}
# fails with /usr/bin/dmd
Stevens-MacBook-Pro:teststatic steves$ dmd mod1.d
Undefined symbols for architecture x86_64:
"_D4core6thread6Thread5startMFZv", referenced from:
_D3std11concurrency61__T6_spawnTPFS3std11concurrency3TidZvTS3std11concurrency3TidZ6_spawnFbPFS3std11concurrency3TidZvS3std11concurrency3TidZS3std11concurrency3Tid
in mod1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
--- errorlevel 1
# so let's take a look at the symbol in mod1.o, see how it's
# specified. Looks like it was the same one identified as
# not being present
Stevens-MacBook-Pro:teststatic steves$ nm mod1.o | grep core6thread6Thread5
U _D4core6thread6Thread5startMFZv
# works with identical compiler installed at ~/Donwloads/dmd2
Stevens-MacBook-Pro:teststatic steves$ ~/Downloads/dmd2/osx/bin/dmd mod1.d
# Same symbol? Nope! Note the difference seems to be in the parameter
# mangling.
Stevens-MacBook-Pro:teststatic steves$ nm mod1.o | grep core6thread6Thread5
U _D4core6thread6Thread5startMFNbZC4core6thread6Thread
So am I going crazy? Or is dmd doing things differently depending on
where its environment is? Any compiler gurus out there understand why
the symbol is different?
I don't want to file a bug with this, because it seems dependent on
installation location, would possibly not be reproducible.
-Steve