- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 656
Add DragonFlyBSD support for dmd #7463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Thanks for your pull request, @dkgroot! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up: 
 Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. | 
| Question Regarding Bootstrapping on DragonFlyBSD 
 But i am not sure any of these branches are 'still' open for Pull Requests / Updates ? Notes: 
 Can one of you guide me what would be preferred ? Should we fix dmd-cxx first and then rebase my changes on top of it / just go with v2.067.1 for dragonflybsd changes. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. First of all. Thanks a lot for your work. I start with first, quick review & tiny nit and answering your questions.
        
          
                test/d_do_test.d
              
                Outdated
          
        
      | (!testArgs.requiredArgs.empty ? " " : ""), | ||
| testArgs.permuteArgs); | ||
|  | ||
| version (DragonFlyBSD) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please add a comment that DragonFlyBSD is only x86_64 here.
| 
 Of course. As explained on the mailing list,  
 tl:dr: how you bootstrap  FYI: @WalterBright is pushing to convert the backend to D too (see e.g. #6907) and for this a couple of new features like  The long-term plan was to maintain  | 
| 
 
 I read the mailinglist and forum post (Referenced in the PR). 
 I tried doing this on Travis (See, which worked, but was to slow, so it timed out during unittesting (mostly because running qemu-system on top of travis is really slow and i had to create a dragonflybsd installation (from iso) during testing). The process could have been split up in several stages (By storing the intermediate results somewhere). For now i gave up on this one. 
 Ok once we conclude this PR for master I can push the PR for dragonflybsd support on v2.067.1. Seperating them might be a good idea, to keep focus. If you like me to push the PR right away, just let me know. 
 DragonFlyBSD uses the 'Ports' from FreeBSD and does provide binary packages as well. Once we have all the PR's committed,I will update the FreeBSD ports Makefile to use the latest git revision. When FreeBSD accepts the updates, the results will automatically get picked up on DragonFlyBSD. It's a bit of a stack to work through, but we will get there. 
 No problem. Now that everything is working/running I already know where attention is needed. 
 I do agree. The biggest problem i had was figuring out the porting process and figuring out which revision worked for me. My first attempt was using dmd-cxx, but it was not able to compile the current master. The funny thing i did find out was that i could use dmd-cxx to compile 2.068.2, and then use it to compile master. Something must have gone wrong in the dmd-cxx backporting process. I would have loved to fix dmd-cxx first, but when focussing on a port you cannot also fix the compiler at the same time (See the forum posts). When trying to fix dmd-cxx first, i ran into the -fPIC/hardening issue ubuntu. To much stuff at the same time. Ideas: 
 | 
        
          
                test/d_do_test.d
              
                Outdated
          
        
      | testArgs.permuteArgs); | ||
|  | ||
| // DragonFlyBSD is x86_64 only, instead of adding DISABLED to a lot of tests, just exclude them from running | ||
| version (DragonFlyBSD) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly braces on their own lines.
| 
 Hmm you could give CircleCi (2 vCPUs, 4GB) or Semaphore a try. They both are a lot faster. 
 CC @braddr (the person in charge of auto-tester). It might also be possible to add more machines to the Jenkins CI (CC @MartinNowak). 
 Agreed and based on your recent experience you are an excellent candidate to start such a page ;-) 
 Currently the following CIs test bootstraping: 
 CircleCi, DAutotTest and Jenkins use a more recent, but fixed, DMD version. Keeping  
 I can help with that (it's just adding  | 
| 
 I think, we should move this to a seperate PR when we get working on this. Thanks for the links though. 
 I was not expecting anything else :-) 
 
 Keeping dmd-cxx up to date is a good proposal, but as I said before, it needs an volunteer(s). 
 Once the dust settles on this (has only been a couple days) I will give it another shot. | 
| Nice work. As for bootstrapping, the problem is that there's currently no strategy on how dmd wants to handle that for new platforms. ldc, on the other hand, puts out regular releases of its C++ ltsmaster branch, based on the dmd 2.068.2 frontend, which is continually tested on CI, so it's easy to do there. If I were you, I'd focus on getting ldc ported first, then you could use your ldc package to build the latest dmd easily. There is little value in porting the last C++ dmd, especially given the confusion about how dmd currently wants to deal with such ports. Ideally, I'd like to see the dmd-cxx frontend updated as far as Iain got it, and then we could work to make sure it's a viable branch on all existing platforms, that could be used to bootstrap new x64 platforms. But ldc ltsmaster is already here and it works. | 
| @joakim-noah | 
| I understand that you already have it working, I'm only talking about with respect to getting stuff merged in the official D git repos and adding D packages to DragonFly ports, which you presumably would like to create without a bunch of local patches. There is currently nowhere to merge changes to a C++ dmd, but there is for ldc, the ltsmaster branch. In terms of getting these pulls merged into the master branch, there's no problem. | 
| @joakim-noah | 
| ldc has forked the 2.068.2 branches of druntime/phobos as ldc-ltsmaster. You may have a few merge conflicts, particularly if you are merging from a later release tag, but likely not many. | 
| @joakim-noah Not to bad i would say. There is something something funky with std/math.d, causing multiple unittests to fail, but have not been able to figure out what is causing this one yet :-) | 
| Look to all be math-related, my guess is that DragonFly has the same  | 
| @joakim-noah Will have to copy these math changes to the druntime PR :-) BTW: We are getting a little offtopic here, regarding LDC. Can we maybe move this LDC related topid somewhere else ? | 
| If you plan on submitting a pull, you can start with a WIP patch against the ldc-ltsmaster branch of druntime here. There's also a forum for LDC, if you just want to discuss further. | 
| else | ||
| { | ||
| private enum targetOS = TarggetOS.all; | ||
| private enum targetOS = TargetOS.all; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spelling fix is unrelated to this PR
| Option("m32", | ||
| "generate 32 bit code" | ||
| "generate 32 bit code", | ||
| (TargetOS.all & ~TargetOS.dragonFlyBSD) // available on all OS'es except DragonFly, which does not support 32-bit binaries | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this was an intended use ?
Not sure if it merits an explanation / comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's how it was intended to be used.
BTW -m32 is also mostly defunct on ArchLinux too as they dropped native support for 32-bit too, but I'm not sure whether it makes sense to complicate the code with such subtleties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using -m32 with dmd on dragonfly currently does fail (not implemented -> assertion failure). I guess this is not the same on archlinux. They might just lack the 32-bit libraries to compile against.
I can remove it if you want (Or wait for another reviewer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can still compile gcc-multilib yourself from the AUR (arch user repository).
I don't mind this being used like you did as I said before, that was intended ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK issue closed
| macOS = 4, | ||
| freeBSD = 8, | ||
| solaris = 16, | ||
| dragonFlyBSD = 32, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These questions/comments are not really related to this PR specifically:
What about the other OS's like NetBSD / OpenBSD etc ?
Would adding posix make sense ?
Do we really need yet another spelling / enum for the target OS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the problem is that dlang.org needs to be able to set the target OS and the current TARGET_ are constants. I'm not really happy with this approach.
@ZombineDev wanted to do a more general revamp and introduce target triples. In any case, I think currently there are only differences between Windows and Posix, so it might make sense to just use those two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilzbach : I did not see the original PR, or i would have made these comments there.
The scattered nature and their repetition of these OS specific definitions is what throws me off a little to be honest. From a porting perspective it would be nice to see all OS specific stuff in one single file / directory, but that has been discussed before (over and over/ad nausea-um), so dropping that.
Except i just added one more 'exception' in line 215 (see above) so now there is three :-)
f76294e    to
    b7d5e1e      
    Compare
  
    b7d5e1e    to
    011ba5b      
    Compare
  
    | Hi guys, would it help if this PR were be split by file, so that it would make a little more progress ? | 
| No, that would make things worse. It just needs to be reviewed, I'll do it. | 
| @joakim-noah Ok thanks for letting me know. I just noticed the speed with which the musl PR's went through. Good that I asked before splitting it 😃 | 
011ba5b    to
    1f160ea      
    Compare
  
    | Rebased to include latest changes. Builds cleanly on DFly: dmd_dragonfly_ci | 
1f160ea    to
    254dda3      
    Compare
  
    386bb18    to
    4a269fc      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Four small nits, otherwise fine.
        
          
                src/dmd/argtypes.d
              
                Outdated
          
        
      | } | ||
| } | ||
| else if (!global.params.is64bit && global.params.isFreeBSD && t.sym.fields.dim == 1 && | ||
| else if (!global.params.is64bit && (global.params.isFreeBSD || global.params.isDragonFlyBSD) && t.sym.fields.dim == 1 && | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't even support 32-bit, why bother with this?
        
          
                src/dmd/backend/cdef.h
              
                Outdated
          
        
      |  | ||
| /* DragonFlyBSD Version | ||
| * ------------- | ||
| * There are two main issues: hosting the compiler on OpenBSD, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong BSD. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Also fixed a faulty reference to "TARGET_OPENBSD" in the OpenBSD entry above (in a seperate commit).
        
          
                src/dmd/backend/os.c
              
                Outdated
          
        
      | #include <string.h> | ||
|  | ||
| #if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun | ||
| #if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __DragonFly__ || __DragonFly__ || __sun | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex failure? Two more below.
| } | ||
| version (DragonFlyBSD) | ||
| { | ||
| browse("http://dlang.org/dmd-dragonflybsd.html"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't exist, would rather you removed the nonexistent OpenBSD link above, as we don't put out official releases for these platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Also remarked out the openbsd entry (in a separate commit)
| @joakim-noah Corrected as per your request/review. Thanks ! | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
e7f4233    to
    81e8633      
    Compare
  
    | DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic | ||
|  | ||
| [Environment64] | ||
| DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib64 -L--export-dynamic | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux (and other 64-bit OSes, IIRC) we add -fPIC by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZombineDev I would add -fPIC, even though it is only actually required on (most) Linux versions, the PR already got merged though.
FYI: checked the other platforms' ini-files and they also do not have -fPIC added by default.
| Nice work, @dkgroot! Congratulations for getting through all the necessary steps! | 
| Thanks everyone for your reviews, hints and time ! | 
Bootstrapped via v2.067.1: See
All tests / unittests were completed successfully both on Linux as well as DragonFlyBSD after the port. (This was prior to rebasing, where 37d37a6 is currently failing)
Note: This port only supports 64-bit, because DragonFlyBSD is currently x86_64 only (i386 support removed a while back). This is also the reason why the dmd option '-m32' is being suppressed when the target is dragonflybsd.
Links: