Bug 99691 - OpenBSD support for GDC
Summary: OpenBSD support for GDC
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: d (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Iain Buclaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-21 03:34 UTC by Brian Callahan
Modified: 2021-04-19 17:28 UTC (History)
1 user (show)

See Also:
Host:
Target: *-*-openbsd*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
OpenBSD support for GDC (5.01 KB, patch)
2021-03-21 03:34 UTC, Brian Callahan
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Callahan 2021-03-21 03:34:20 UTC
Created attachment 50441 [details]
OpenBSD support for GDC

Hello --

Provided here is a patch demonstrating OpenBSD support for GDC.

Some important notes and helps needed:

* Iain, you'll notice that my druntime is different from the DMD druntime diff you saw on GitHub. I will do my best to sync the two, which will mean replacing what I've done for DMD with what I've done here for GDC, to make all lives easier.

* I cannot get a shared libgphobos to work on OpenBSD. I get random crashes that I have not yet been able to track down. I do not know how to disable --enable-shared in libphobos's configure.ac without disabling it for all of gcc, which is not desirable. If that's a patch I have to carry until I can get a working shared libgphobos, that's fine.

* I suspect libphobos will work on more than just x86_64 and i386 but as I've only been able to test on x86_64, I kept libphobos to just those 2 archs. I will submit further diffs for more platforms as I'm able to test.

* The port is otherwise fairly straightforward and I am using this in production.

Thanks! Happy to work with you to get this in.
Comment 1 Iain Buclaw 2021-03-21 07:20:54 UTC
Thanks, I have an OpenBSD VM with a WIP port as well, so I'll compare the two - I don't recall any problems with shared libraries, though the host system demands that PIC/PIE is forced for all built compilers/generator programs.
Comment 2 Brian Callahan 2021-03-21 18:38:53 UTC
(In reply to Iain Buclaw from comment #1)
> Thanks, I have an OpenBSD VM with a WIP port as well, so I'll compare the
> two - I don't recall any problems with shared libraries, though the host
> system demands that PIC/PIE is forced for all built compilers/generator
> programs.

Yes, I do the same with PIC/PIE.
Thanks.
Comment 3 GCC Commits 2021-03-26 15:15:36 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:8ab1d637440532d9698daae84cc81a43d36b4aa8

commit r11-7845-g8ab1d637440532d9698daae84cc81a43d36b4aa8
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 21 11:00:29 2021 +0100

    d: Add openbsd support for D compiler [PR99691]
    
    gcc/ChangeLog:
    
            PR d/99691
            * config.gcc (*-*-openbsd*): Add openbsd-d.o.
            * config/t-openbsd: Add openbsd-d.o.
            * config/openbsd-d.c: New file.
Comment 4 GCC Commits 2021-04-19 17:28:51 UTC
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:d86e60855f05a0e493f8362c12bfd40d5432d337

commit r11-8246-gd86e60855f05a0e493f8362c12bfd40d5432d337
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Apr 19 14:23:00 2021 +0200

    libphobos: Add section support code for OpenBSD (PR99691)
    
    libphobos/ChangeLog:
    
            PR d/99691
            * configure: Regenerate.
            * libdruntime/config/common/threadasm.S: Add __OpenBSD__.
            * libdruntime/gcc/backtrace.d: Import core.sys.openbsd.dlfcn on
            OpenBSD platforms.
            * libdruntime/gcc/sections/elf.d (SharedElf): Define on OpenBSD.
            (linkMapForHandle): Implement for OpenBSD.
            (exeLinkMap): Remove.
            (getDependencies): Adjust dlpi_addr on OpenBSD.
            (handleForName): Implement for OpenBSD.
            (IterateManually): Define on OpenBSD.
            * libdruntime/gcc/sections/package.d (SectionsElf): Define on OpenBSD.
            * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_ATOMIC): Test for
            enable_libatomic.
            (DRUNTIME_LIBRARIES_BACKTRACE): Test for enable_libbacktrace.