August 19
Hello,

I'm trying to add support for DragonFlyBSD to dmd, but I'm running into an issue that I'm not sure how to move forward on..

I've compiled a version of ldc's ltsmaster branch (after adding support to druntime and phobos), and using it I'm able to compile dmd (after adding support to druntime and phobos in HEAD, rather than ltsmaster..), but the compiled dmd isn't able to link anything. It gets a bunch of errors of the form "error: TLS relocation against invalid instruction" (the complete log of the errors is at https://gist.github.com/driusan/6a04060c234806d3fbb2625759bd55a4)

From what I can tell, the symbols like _d_arrayappendcTX are supposed to be added from dmd, but for some reason aren't (I might be misreading the errors, though..)

Unrelatedly (or relatedly?) I'm not sure how the DMD backend uses the EX_* enums defined in cdefs.h or where the values come from, so it's not obvious what the right value is for DragonFly. The comment says it's the "Executable file format", but at least 8 of them just use elf/elf64 for their executable file format, so I don't see why they're different or if I should just shift over 1 bit and add a new EX_DRAGONFLY64.

(I tried sending a pull request with my runtime/phobos ldc changes but
was told I should send them upstream instead.. but I don't want to
send my runtime changes upstream until I'm sure that they work, and
I'm not as confident in these changes since the compiled dmd can't
link. I'm not sure if the trouble is in the backend or the runtime
since the problem seems to come from linking the runtime..)
- Dave
_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals
August 19
On Saturday, August 19, 2017 23:21:50 Dave MacFarlane via dmd-internals wrote:
> Hello,
>
> I'm trying to add support for DragonFlyBSD to dmd, but I'm running into an issue that I'm not sure how to move forward on..
>
> I've compiled a version of ldc's ltsmaster branch (after adding support to druntime and phobos), and using it I'm able to compile dmd (after adding support to druntime and phobos in HEAD, rather than ltsmaster..), but the compiled dmd isn't able to link anything. It gets a bunch of errors of the form "error: TLS relocation against invalid instruction" (the complete log of the errors is at https://gist.github.com/driusan/6a04060c234806d3fbb2625759bd55a4)
>
> From what I can tell, the symbols like _d_arrayappendcTX are supposed to be added from dmd, but for some reason aren't (I might be misreading the errors, though..)

Well, grepping druntime's source, it's in src/rt/lifetime.d. From my limited understanding of how dmd and druntime interact, I'd expect druntime to be the one generating the actual object code for it, whereas dmd just references it, but it's going to have to be linked in regardless, and normally druntime is part of the library file for Phobos when it's built, meaning that you'd probably have to have Phobos available, even if it's not being used by dmd at the moment. I really don't know how all of that works with cross-compiling, and dmd's switch to D makes all of this more complicated. We really need some sort of guide for it, but I don't know who'd write it. Fortunately, it's not an issue that's likely to come up all that often, but as you'd know better than I would, it's still going to be pretty painful to get a new platform going without it.

- Jonathan M Davis

_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals