Installing GDC on macOS via Homebrew


210515

They added official gdc support to macOS on gcc11. Now official gcc package installs gdc.

original

From GCC 9, GDC (D frontend) is available on GCC. However, it is not stable on macOS and a little tweak is required.

  • gcc/config.gcc, gcc/config/darwin-d.c, gcc/config/t-darwin

    • We need to tell gcc that D configuration is ready.
  • gcc/d/modules.cc

    • Section name needs to be segment,section format.
    • As libphobos/libdruntime/gcc/sections/osx.d mentions it, we selected __DATA,__minfodata.
  • libphobos/configure

    • We disabled shared library.
    • Otherwise core/thread.d fails to compile.
    • By the way I have not heard of mach-dylib built with D.
  • libphobos/libdruntime/config/x86/switchcontext.S

  • libphobos/libdruntime/gcc/drtstuff.c

    • start_minfo / stop_minfo needs to be compiled also on mach.
    • As these two needs to be executable, we selected __TEXT,minfo.
  • libphobos/libdruntime/gcc/sections/osx.d

    • We disabled libgphobos.dylib / libgdruntime.dylib warning.
      • Please note that libgphobos.a / libgdruntime.a are not affected but the compile option would be complex because -static would not work on macOS.
    • Also we add temporal d_dso_registry.