WIP: Port dmd and druntime to GNU/Hurd#22829
Conversation
|
Thanks for your pull request and interest in making D better, @yelninei! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#22829" |
|
The error from the circleci is I guess this is expected, is there a way to regenerate the header? |
|
Re: regenerating the headers, if you read a few more lines down in that error message, you will see this:
Which refers to https://github.com/dlang/dmd/tree/master/compiler/src#cxx-headers-test |
I thought dmd triplet (tuples?) matched ldc. Historically, I guess gnu/hurd would be |
| /** | ||
| * D header file for GNU Hurd | ||
| * | ||
| * Copyright: Copyright Martin Nowak 2012. |
There was a problem hiding this comment.
Wrong year, wrong copyright. :-)
If unsure, please use:
Copyright: Copyright (c) 2026 D Language Foundation
| * | ||
| * Copyright: Copyright Martin Nowak 2012. | ||
| * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) | ||
| * Authors: Martin Nowak |
There was a problem hiding this comment.
I assume Martin didn't author this module.
There was a problem hiding this comment.
The file is a copy paste of the linux version with s/linux/hurd/
Is that enough to void the original copyright as it is clearly a derivative?
There was a problem hiding this comment.
I'm not qualified to say. In isolation, I don't consider the file big enough to warrant any copyright claim.
Rather, the body of work as a whole (this PR) ought to be considered as authored by the contributor.
| @@ -0,0 +1,25 @@ | |||
| module core.sys.hurd.unistd; | |||
There was a problem hiding this comment.
Some modules are missing comment headings/notices entirely. Others have inconsistent styles.
As these are newly introduced sources, I'd err towards not repeating previous bad habits, and pick one format, and use it consistently throughout all new files.
| } | ||
| else version (Hurd) | ||
| { | ||
| // What is needed here? |
There was a problem hiding this comment.
Any part of ioctls.h or ioctl-types.h that would be needed to interact with ioctl().
| version (CRuntime_Glibc) | ||
| { | ||
| version (linux) | ||
| { |
There was a problem hiding this comment.
It looks like the outer CRuntime_Glibc is unneeded here. Just version (linux) { } else version (Hurd) { } else ... ?
There was a problem hiding this comment.
Not sure, that would shadow the musl, uclibc and bionic versions on linux which are not 1:1 copies of the glibc one
| version (CRuntime_Glibc) | ||
| { | ||
| version (linux) |
There was a problem hiding this comment.
Likewise, maybe just remove the CRuntime_Glibc guard.
|
I ran detab everywhere, cleaned up a lot of things manually and then also ran dfix for the alias conversion (separate commit to make it easier to backport to earlier versions) some things remain (especially where i need guard off linux code as that would also need to be reindented) |
|
EDIT: Adding the This was not great to debug. |
I wrote that code, and it was not great debugging (proprietary) solaris either. :-) Is Hurd's fork implemented in glibc? |
yes, see glibc/sysdeps/mach/hurd/_Fork.c the main issue was that things like |
|
One thing for gdc how do these files map to dmd or are these gdc specific?
|
|
I fixed the importc_compare test (so far on the 32bit version only , still need to double check on the 64bit versiob) and made a bit of a messs of the linux/glibc version. I am not sure about some of the additional types and opague structures that get delcared, should these get moved to a central place even if they are only used at one place? Sadly some pthread tests still crash |
|
BTW, there's an i386 and x86_64 Debian GNU/Hurd machine that recently got added to cfarm. I can do some extra testing, or debug the more painful stuff, but it may some weeks before I get round to it. |
Those are gdc-specific, as context switching itself is done using external asm implementations. Whereas in dmd, they use their dialect of inline asm (see version |
cool :) my current bootstrap path is a bit painful. gdc-11 compiles (for i686) but without support in phobos/druntime it cant compile a later one All the changes from https://bugzilla-archive.dlang.org/bugs/22689/ help a lot with decoupling Support for x86_64-gnu is only officially available since gcc-14 (though a backport of the minimal support from 5f8950b403f6351f125d8281d2e7430a43e7d125 is enough to compile gdc) I have some patches for gdc-11 and gdc-14 that I currently use to get to dmd, but I have not kept them up to date as maintaining multiple variants of the same changes while it is still quite unstable is a bit to much work for me right now.
My main problem is that the crash only seems to happen in the druntime/phobos unittest setting and I am failing to reproduce it when compiling/running the module with unittest flags normally (also gdb does not like something with the unittest druntime and ceases to be useful, but this also happens on linux so idk). |
More than happy to commit them to a development branch under |
|
Fixed |
If you want to take a look they are here: https://codeberg.org/Yelninei/dmd/src/branch/version-1.112/patches Mostly the druntime change with minor gdc specific adjustments and then connecting things in configure and Makefile and regenerating them |
Hi,
As announced on https://forum.dlang.org/thread/[email protected] here is my WIP PR for porting druntime and dmd to GNU Hurd.
To be able to build also #22787 is needed.
Things that I know are still a bit of a mess:
version(linux)whereCRuntime_Glibcis used to mean linux + glibc.I am currently quite happy with the dmd part as all tests pass on 32bit and 64bit except
For the runtime some tests still crash in pthread_join, I am not entirely sure why as the same test outside of libdruntime_ut works fine.
On x86_64 the test runner gets killed after a while with the gc suspend signal, I dont know yet why the runtime does not handle it.
I am not erntirely sure about the format for the dmd triplet as it differs from both the gnu config and llvm triplet.
I have asked people on the bug-hurd mailing list for help as well
https://lists.gnu.org/archive/html/bug-hurd/2026-03/msg00274.html
https://lists.gnu.org/archive/html/bug-hurd/2026-03/msg00275.html
There are some more things needed to bring this back into gdc,