www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Building DMD on OpenBSD

reply Anonymous <anonymous example.com> writes:
I did some googling (well, duckduckgoing) and found a few posts 
on this forum indicating that this could work. So I gave it a try 
and followed https://wiki.dlang.org/Building_under_Posix
The build failed because src/posix.mak in the dmd repo was trying 
to download 
http://downloads.dlang.org/releases/2.x/2.072.2/dmd.2.072.2.openbsd.tar.xz
which doesn&apos;t exist. What do I do now?

OTOH it&apos;s a good thing that the build failed. When I saw 
http:// instead of https:// in the console output I went to check 
what the makefile was doing and - wait for it - it was trying to 
download an executable from the internet and run it. I 
couldn&apos;t believe my eyes. I mean, you sure can use an 
unencrypted channel but then you need some kind of cryptographic 
signature to verify the downloaded file. I tried the above with 
2.074.1 (the latest stable) but the trunk version has this too.
Jul 16
next sibling parent reply Seb <seb wilzba.ch> writes:
On Sunday, 16 July 2017 at 19:00:32 UTC, Anonymous wrote:
 I did some googling (well, duckduckgoing) and found a few posts 
 on this forum indicating that this could work. So I gave it a 
 try and followed https://wiki.dlang.org/Building_under_Posix
 The build failed because src/posix.mak in the dmd repo was 
 trying to download 
 http://downloads.dlang.org/releases/2.x/2.072.2/dmd.2.072.2.openbsd.tar.xz
which doesn&apos;t exist. What do I do now?

 OTOH it&apos;s a good thing that the build failed. When I saw 
 http:// instead of https:// in the console output I went to 
 check what the makefile was doing and - wait for it - it was 
 trying to download an executable from the internet and run it. 
 I couldn&apos;t believe my eyes. I mean, you sure can use an 
 unencrypted channel but then you need some kind of 
 cryptographic signature to verify the downloaded file. I tried 
 the above with 2.074.1 (the latest stable) but the trunk 
 version has this too.
Auto-bootstrapping is __only__ used if no host compiler is found on the system. This should only happen on esoteric platforms (not intended as an offense) like yours. There are usually plenty of ways to get your host compiler safely: http://dlang.org/download.html The simplest one on a Posix system is: curl -fsS https://dlang.org/install.sh | bash -s dmd If you have GPG, it will verify the integrity of the downloaded archive. In any case, I submitted a PR to use SSL for AUTO_BOOSTRAP: https://github.com/dlang/dmd/pull/7000
Jul 16
parent reply Anonymous <anonymous example.com> writes:
On Sunday, 16 July 2017 at 19:47:20 UTC, Seb wrote:
 Auto-bootstrapping is __only__ used if no host compiler is 
 found on the system.
 This should only happen on esoteric platforms (not intended as 
 an offense) like yours.
So I should use digger then? I looked through its repo briefly and I can&apos;t really tell if I&apos;m gonna run into the same issue or not. I guess another option is to build GDC and then use it to build DMD.
 In any case, I submitted a PR to use SSL for AUTO_BOOSTRAP:

 https://github.com/dlang/dmd/pull/7000
Thanks.
Jul 16
parent reply Seb <seb wilzba.ch> writes:
On Sunday, 16 July 2017 at 21:05:53 UTC, Anonymous wrote:
 On Sunday, 16 July 2017 at 19:47:20 UTC, Seb wrote:
 Auto-bootstrapping is __only__ used if no host compiler is 
 found on the system.
 This should only happen on esoteric platforms (not intended as 
 an offense) like yours.
So I should use digger then? I looked through its repo briefly and I can&apos;t really tell if I&apos;m gonna run into the same issue or not. I guess another option is to build GDC and then use it to build DMD.
Yes digger could work, but it's written in D and you would need to build it on a different OS. How about simply building the bootstrap binary yourself then? I think 2.067 is the last version that's still written in C++: https://github.com/dlang/dmd/tree/2.067 PS: Do you manually insert the HTML codes? They are escaped.
Jul 16
parent reply Anonymous <anonymous example.com> writes:
On Sunday, 16 July 2017 at 21:37:12 UTC, Seb wrote:
 How about simply building the bootstrap binary yourself then?
 I think 2.067 is the last version that&apos;s still written in 
 C++:

 https://github.com/dlang/dmd/tree/2.067
Yep, that should work. I believe this should be put somewhere on the wiki because otherwise bootstrapping is hard to figure out.
 PS: Do you manually insert the HTML codes? They are escaped.
I noticed them added after a redirect to the captcha page (I&apos;m using tor).
Jul 16
parent reply Joakim <dlang joakim.fea.st> writes:
On Sunday, 16 July 2017 at 22:40:18 UTC, Anonymous wrote:
 On Sunday, 16 July 2017 at 21:37:12 UTC, Seb wrote:
 How about simply building the bootstrap binary yourself then?
 I think 2.067 is the last version that&apos;s still written in 
 C++:

 https://github.com/dlang/dmd/tree/2.067
Yep, that should work. I believe this should be put somewhere on the wiki because otherwise bootstrapping is hard to figure out.
The wiki does explain that you need a bootstrap compiler, it tells you what will be done. Unfortunately, it doesn't explain that the auto-bootstrap will not work for OpenBSD, because we don't put out builds for that OS. The only BSD we regularly put out builds for is FreeBSD. I will update the wiki page to say that. As for bootstrapping, it appears that we have not documented it anywhere on the wiki, I'll add some info on that. The last dmd we released that was written in C++ was 2.067, for which you can still check out the branch. You'd have to build that bootstrap compiler 2.067 first, then worry about the latest dmd. Since we don't regularly build for OpenBSD, it's possible that support has slipped behind. Usually, it's as easy as adding OpenBSD to a couple more #ifdefs, but sometimes you need to adapt the dmd source also for a rarely used platform like OpenBSD.
Jul 17
parent reply Anonymous <anonymous example.com> writes:
On Monday, 17 July 2017 at 09:58:42 UTC, Joakim wrote:
 The last dmd we released that was written in C++ was 2.067, for 
 which you can still check out the branch.  You&apos;d have to 
 build that bootstrap compiler 2.067 first, then worry about the 
 latest dmd.

 Since we don&apos;t regularly build for OpenBSD, it&apos;s 
 possible that support has slipped behind.  Usually, it&apos;s 
 as easy as adding OpenBSD to a couple more #ifdefs, but 
 sometimes you need to adapt the dmd source also for a rarely 
 used platform like OpenBSD.
I managed to build the bootstrap dmd without any trouble. Btw the wiki page doesn&apos;t mention that the dependency is *GNU* Make which is typically installed as gmake on BSDs. Then I tried building the new dmd and got (in dmd/src): CC=c++ dmd -of../generated/openbsd/release/64/idgen ddmd/idgen.d Error: cannot find source code for runtime library file &apos;object.d&apos; dmd might not be correctly installed. Run &apos;dmd -man&apos; for installation instructions. config file: /etc/dmd.conf Specify path to file &apos;object.d&apos; with -I switch gmake[1]: *** [posix.mak:437: ../generated/openbsd/release/64/idgen] Error 1 Now I&apos;m trying to figure out the /etc/dmd.conf business. I found ini/freebsd/bin64/dmd.conf in the 2.067 dmd folder so I guess I&apos;ll start from there. Thanks for the help so far.
Jul 17
parent reply Joakim <dlang joakim.fea.st> writes:
On Monday, 17 July 2017 at 16:45:28 UTC, Anonymous wrote:
 On Monday, 17 July 2017 at 09:58:42 UTC, Joakim wrote:
 The last dmd we released that was written in C++ was 2.067, 
 for which you can still check out the branch.  You&apos;d have 
 to build that bootstrap compiler 2.067 first, then worry about 
 the latest dmd.

 Since we don&apos;t regularly build for OpenBSD, it&apos;s 
 possible that support has slipped behind.  Usually, it&apos;s 
 as easy as adding OpenBSD to a couple more #ifdefs, but 
 sometimes you need to adapt the dmd source also for a rarely 
 used platform like OpenBSD.
I managed to build the bootstrap dmd without any trouble. Btw the wiki page doesn&apos;t mention that the dependency is *GNU* Make which is typically installed as gmake on BSDs. Then I tried building the new dmd and got (in dmd/src): CC=c++ dmd -of../generated/openbsd/release/64/idgen ddmd/idgen.d Error: cannot find source code for runtime library file &apos;object.d&apos; dmd might not be correctly installed. Run &apos;dmd -man&apos; for installation instructions. config file: /etc/dmd.conf Specify path to file &apos;object.d&apos; with -I switch gmake[1]: *** [posix.mak:437: ../generated/openbsd/release/64/idgen] Error 1 Now I&apos;m trying to figure out the /etc/dmd.conf business. I found ini/freebsd/bin64/dmd.conf in the 2.067 dmd folder so I guess I&apos;ll start from there. Thanks for the help so far.
Unfortunately, dmd has not kept porters in mind and hasn't kept the C++ version updated, or kept a workflow that enables easy bootstrapping: http://forum.dlang.org/thread/xgtbpcvbikxlilanrzqa forum.dlang.org You will have to build druntime and phobos for 2.067 also and collect it all in a different location, which you could invoke to bootstrap a new dmd. You may run into issues related to D/C++ integration when building the latest dmd, as that hasn't been tested on OpenBSD, only FreeBSD. Why do you want the latest dmd on OpenBSD? I ask because it will likely require some work, though likely not a lot.
Jul 17
parent reply Anonymous <anonymous example.com> writes:
On Monday, 17 July 2017 at 17:18:23 UTC, Joakim wrote:
 Unfortunately, dmd has not kept porters in mind and hasn&apos;t 
 kept the C++ version updated, or kept a workflow that enables 
 easy bootstrapping:

 http://forum.dlang.org/thread/xgtbpcvbikxlilanrzqa forum.dlang.org

 You will have to build druntime and phobos for 2.067 also and 
 collect it all in a different location, which you could invoke 
 to bootstrap a new dmd.  You may run into issues related to 
 D/C++ integration when building the latest dmd, as that 
 hasn&apos;t been tested on OpenBSD, only FreeBSD.

 Why do you want the latest dmd on OpenBSD?  I ask because it 
 will likely require some work, though likely not a lot.
I&apos;ve already tried building 2.067 druntime by mistake and run into problems. Most are resolvable by just adding TARGET_OPENBSD next to TARGET_FREEBSD. But yeah, it&apos;s gonna take some work. I want it because I&apos;m using OpenBSD as my main OS and I have a project that I want to port to D. Btw I should&apos;ve built the `install` target (got confused by the wiki). Now I get: cp: ../ini/openbsd/bin64/dmd.conf: No such file or directory which is more understandable.
Jul 17
parent reply Joakim <dlang joakim.fea.st> writes:
On Monday, 17 July 2017 at 18:42:39 UTC, Anonymous wrote:
 On Monday, 17 July 2017 at 17:18:23 UTC, Joakim wrote:
 Unfortunately, dmd has not kept porters in mind and 
 hasn&apos;t kept the C++ version updated, or kept a workflow 
 that enables easy bootstrapping:

 http://forum.dlang.org/thread/xgtbpcvbikxlilanrzqa forum.dlang.org

 You will have to build druntime and phobos for 2.067 also and 
 collect it all in a different location, which you could invoke 
 to bootstrap a new dmd.  You may run into issues related to 
 D/C++ integration when building the latest dmd, as that 
 hasn&apos;t been tested on OpenBSD, only FreeBSD.

 Why do you want the latest dmd on OpenBSD?  I ask because it 
 will likely require some work, though likely not a lot.
I&apos;ve already tried building 2.067 druntime by mistake and run into problems. Most are resolvable by just adding TARGET_OPENBSD next to TARGET_FREEBSD. But yeah, it&apos;s gonna take some work. I want it because I&apos;m using OpenBSD as my main OS and I have a project that I want to port to D. Btw I should&apos;ve built the `install` target (got confused by the wiki). Now I get: cp: ../ini/openbsd/bin64/dmd.conf: No such file or directory which is more understandable.
Alright, there was a contributor who recently got ldc working on NetBSD, take a look at his PRs as a guide for what you'll likely have to do: https://github.com/dlang/dmd/pulls?q=is%3Apr+author%3AnrTQgc https://github.com/dlang/druntime/pulls?q=is%3Apr+author%3AnrTQgc https://github.com/dlang/phobos/pulls?q=is%3Apr+author%3AnrTQgc OpenBSD PRs welcome! :) In the meantime, you can see that I've raised this bootstrap issue internally and hopefully we can make it easier for future porters.
Jul 17
parent reply Kai Nacke <kai redstar.de> writes:
On Monday, 17 July 2017 at 18:58:40 UTC, Joakim wrote:
 On Monday, 17 July 2017 at 18:42:39 UTC, Anonymous wrote:
 On Monday, 17 July 2017 at 17:18:23 UTC, Joakim wrote:
 Unfortunately, dmd has not kept porters in mind and 
 hasn&apos;t kept the C++ version updated, or kept a workflow 
 that enables easy bootstrapping:

 http://forum.dlang.org/thread/xgtbpcvbikxlilanrzqa forum.dlang.org

 You will have to build druntime and phobos for 2.067 also and 
 collect it all in a different location, which you could 
 invoke to bootstrap a new dmd.  You may run into issues 
 related to D/C++ integration when building the latest dmd, as 
 that hasn&apos;t been tested on OpenBSD, only FreeBSD.

 Why do you want the latest dmd on OpenBSD?  I ask because it 
 will likely require some work, though likely not a lot.
I&apos;ve already tried building 2.067 druntime by mistake and run into problems. Most are resolvable by just adding TARGET_OPENBSD next to TARGET_FREEBSD. But yeah, it&apos;s gonna take some work. I want it because I&apos;m using OpenBSD as my main OS and I have a project that I want to port to D. Btw I should&apos;ve built the `install` target (got confused by the wiki). Now I get: cp: ../ini/openbsd/bin64/dmd.conf: No such file or directory which is more understandable.
Alright, there was a contributor who recently got ldc working on NetBSD, take a look at his PRs as a guide for what you'll likely have to do: https://github.com/dlang/dmd/pulls?q=is%3Apr+author%3AnrTQgc https://github.com/dlang/druntime/pulls?q=is%3Apr+author%3AnrTQgc https://github.com/dlang/phobos/pulls?q=is%3Apr+author%3AnrTQgc OpenBSD PRs welcome! :) In the meantime, you can see that I've raised this bootstrap issue internally and hopefully we can make it easier for future porters.
:-) In master there is already some OpenBSD support. Some time ago I worked on druntime support but I still need to finish this. Mostly there is nothing magic here - just translating the header files. The only non-obvious work is required for the module/shared library stuff (in rt.sections). If there is an OpenBSD expert around who can help here it would be nice. Regards, Kai
Jul 17
parent Anonymous <anonymous example.com> writes:
On Tuesday, 18 July 2017 at 05:11:30 UTC, Kai Nacke wrote:
 In master there is already some OpenBSD support. Some time ago 
 I worked on druntime support but I still need to finish this. 
 Mostly there is nothing magic here - just translating the 
 header files. The only non-obvious work is required for the 
 module/shared library stuff (in rt.sections). If there is an 
 OpenBSD expert around who can help here it would be nice.
Maybe talk to OpenBSD porters on their mailing list. I&apos;ll put my stuff on github as soon as I can.
Jul 18
prev sibling parent Jonathan M Davis via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Sunday, July 16, 2017 19:00:32 Anonymous via Digitalmars-d wrote:
 I did some googling (well, duckduckgoing) and found a few posts
 on this forum indicating that this could work. So I gave it a try
 and followed https://wiki.dlang.org/Building_under_Posix
 The build failed because src/posix.mak in the dmd repo was trying
 to download
 http://downloads.dlang.org/releases/2.x/2.072.2/dmd.2.072.2.openbsd.tar.xz
 which doesn&apos;t exist. What do I do now?

 OTOH it&apos;s a good thing that the build failed. When I saw
 http:// instead of https:// in the console output I went to check
 what the makefile was doing and - wait for it - it was trying to
 download an executable from the internet and run it. I
 couldn&apos;t believe my eyes. I mean, you sure can use an
 unencrypted channel but then you need some kind of cryptographic
 signature to verify the downloaded file. I tried the above with
 2.074.1 (the latest stable) but the trunk version has this too.
I'm pretty sure that druntime would need to be updated before you'd get much of anywhere with OpenBSD. dmd _might_ work as-is, depending on what's missing in druntime, but all of the various bindings would need to be updated. grepping druntime, it does look like there are a number of version blocks checking OpenBSD, but nowhere near as many as FreeBSD or linux. So, to have the same level of functionality, I'd expect that more places would need to be doing else version(OpenBSD) and doing the right thing for OpenBSD, but I don't know how many would be required to get off the ground so to speak. Clearly, someone put in some time and effort towards getting OpenBSD working, but I have no idea how close they got. Most of the missing bindings would probably be pretty close to what's in the FreeBSD version blocks though. Most of the time, the tedium with getting the system bindings set up for a new POSIX system is going over each section and making sure that when it's created, the bindings match the new system. They're generally _very_ close but slightly different - which is why they aren't just put under version(Posix) and left at that. - Jonathan M Davis
Jul 17