Hi ports --

Attached is an update to the latest LDC. With this, I would also like to
make the build process a lot easier.

LDC does not need to be built with itself; it can be built with DMD or
GDC as well. I would like to make LDC have a BDEP on DMD. Now that DMD
has an LTS bootstrap it should be always have a package available. Also,
Phobos, the D standard library, is always built and shipped as a static
library, so DMD won't be an LDEP or RDEP, just a BDEP.

This has the instant benefit of enabling LDC on i386, which I have
tested alongside amd64 and does work. This also has the benefit of
making LDC much easier to update. Should be as easy as cranking version
number, updating patches, and updating plist.

Other platforms may need a bootstrap or use GDC to build LDC, but I will
tackle those on an as-needed basis.

I tried making an LTS bootstrap of LDC but there are linker errors for
multiple symbols of the same name. And I think this new strategy is good
enough.

OK?

~Brian
Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/ldc/Makefile,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile
--- Makefile    9 Mar 2024 15:18:28 -0000       1.13
+++ Makefile    24 May 2024 00:52:45 -0000
@@ -1,15 +1,14 @@
-BROKEN=                needs new bootstrap
+# A bootstrap may be needed for !amd64, !i386 archs.
+# Can try GDC to bootstrap as well.
+ONLY_FOR_ARCHS =       amd64 i386
 
-# You must create a bootstrap for each supported arch.
-# Can use GDC to create said bootstrap compiler.
-ONLY_FOR_ARCHS =       amd64
+# No BT CFI yet.
+USE_NOBTCFI =  Yes
 
-V =            1.35.0
+V =            1.38.0
 COMMENT =      LLVM D Compiler
 DISTFILES =    ldc-${V}-src.tar.gz
-DISTFILES.boot= ldc-${V}-bootstrap.tar.gz
 PKGNAME =      ldc-${V}
-REVISION =     0
 CATEGORIES =   lang
 
 HOMEPAGE =     https://wiki.dlang.org/LDC
@@ -23,7 +22,6 @@ PERMIT_PACKAGE =      Yes
 WANTLIB += ${COMPILER_LIBCXX} c execinfo m z
 
 SITES =                
https://github.com/ldc-developers/ldc/releases/download/v${V}/
-SITES.boot =   https://github.com/ibara/ldc/releases/download/bootstrap-${V}/
 
 # C++14
 COMPILER =     base-clang ports-gcc
@@ -34,29 +32,18 @@ MODCLANG_COMPILER_LINKS =   No
 MODCLANG_RUNDEP =              No
 MODCLANG_VERSION =             16
 
+BUILD_DEPENDS =        lang/dmd
+
 # COMPILE_D_MODULES_SEPARATELY=ON lets ldc compile with sane memory limits.
 CONFIGURE_ARGS =       -DCOMPILE_D_MODULES_SEPARATELY=ON \
                        -DLDC_DYNAMIC_COMPILE=OFF \
                        -DLDC_WITH_LLD=OFF \
                        
-DLLVM_CONFIG="${LOCALBASE}/bin/llvm-config-${MODCLANG_VERSION}"
 
-# Use a bootstrap compiler, similar to DMD.
-CONFIGURE_ENV =        
DMD="${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}/ldmd2" \
-               LD_LIBRARY_PATH="${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}"
-
-MAKE_ENV +=    LD_LIBRARY_PATH="${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}"
+# Use DMD as the bootstrap compiler.
+CONFIGURE_ENV =        DMD="${LOCALBASE}/bin/dmd"
 
 WRKDIST        =       ${WRKDIR}/ldc-${V}-src
-
-# I put a vanilla ldc2.conf in the bootstrap tarball.
-# This fixes it up for the specifics for each arch.
-post-patch:
-       sed -i 's#/usr/local/include/d#${WRKDIR}/ldc-${V}-bootstrap/d#g' \
-               ${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}/ldc2.conf
-       sed -i 
's#"/usr/local/lib",#"/usr/local/lib","${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}",#g'
 \
-               ${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}/ldc2.conf
-       chmod 644 ${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}/lib*.so* # XXX
-       cp /usr/lib/libc.so.98.* ${WRKDIR}/ldc-${V}-bootstrap/${MACHINE_ARCH}/ 
# XXX
 
 # Same trick as with flang:
 #   Replace the shared LLVM.so library with the static libraries.
Index: distinfo
===================================================================
RCS file: /cvs/ports/lang/ldc/distinfo,v
retrieving revision 1.6
diff -u -p -r1.6 distinfo
--- distinfo    14 Dec 2023 15:31:31 -0000      1.6
+++ distinfo    24 May 2024 00:52:45 -0000
@@ -1,4 +1,2 @@
-SHA256 (ldc-1.35.0-bootstrap.tar.gz) = 
8IbnqIzaBxRP2vOWAl3c3sTvyTVv9NxMuJD24CVF1i8=
-SHA256 (ldc-1.35.0-src.tar.gz) = bilpk3BsdsCT5gkTmqCz+HBDVfoPN1b2dY141EIm36A=
-SIZE (ldc-1.35.0-bootstrap.tar.gz) = 49813924
-SIZE (ldc-1.35.0-src.tar.gz) = 8241960
+SHA256 (ldc-1.38.0-src.tar.gz) = ymI47+Ai40zTB2dB+KBwxqN3GWNRxhlJpIpIyZN5844=
+SIZE (ldc-1.38.0-src.tar.gz) = 8691096
Index: patches/patch-driver_cl_options_instrumentation_cpp
===================================================================
RCS file: patches/patch-driver_cl_options_instrumentation_cpp
diff -N patches/patch-driver_cl_options_instrumentation_cpp
--- patches/patch-driver_cl_options_instrumentation_cpp 14 Aug 2023 22:35:35 
-0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-Default to -fcf-protection=branch
-May need to be tweaked if ldc grows !amd64 packages...
-
-Index: driver/cl_options_instrumentation.cpp
---- driver/cl_options_instrumentation.cpp.orig
-+++ driver/cl_options_instrumentation.cpp
-@@ -95,7 +95,7 @@ cl::opt<CFProtectionType> fCFProtection(
-                clEnumValN(CFProtectionType::Full, "",
-                           "") // default to "full" if no argument specified
-                ),
--    cl::init(CFProtectionType::None));
-+    cl::init(CFProtectionType::Branch));
- 
- void initializeInstrumentationOptionsFromCmdline(const llvm::Triple &triple) {
-   if (ASTPGOInstrGenFile.getNumOccurrences() > 0) {
Index: patches/patch-driver_linker-gcc_cpp
===================================================================
RCS file: /cvs/ports/lang/ldc/patches/patch-driver_linker-gcc_cpp,v
retrieving revision 1.4
diff -u -p -r1.4 patch-driver_linker-gcc_cpp
--- patches/patch-driver_linker-gcc_cpp 8 Dec 2023 05:14:12 -0000       1.4
+++ patches/patch-driver_linker-gcc_cpp 24 May 2024 00:52:45 -0000
@@ -4,7 +4,7 @@ Need -lexecinfo for Backtrace symbols.
 Index: driver/linker-gcc.cpp
 --- driver/linker-gcc.cpp.orig
 +++ driver/linker-gcc.cpp
-@@ -424,7 +424,6 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Tr
+@@ -436,7 +436,6 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Tr
      break;
    case llvm::Triple::Solaris:
    case llvm::Triple::NetBSD:
@@ -12,7 +12,7 @@ Index: driver/linker-gcc.cpp
    case llvm::Triple::DragonFly:
      args.push_back("-lstdc++");
      break;
-@@ -434,6 +433,7 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Tr
+@@ -446,6 +445,7 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Tr
    case llvm::Triple::WatchOS:
    case llvm::Triple::TvOS:
    case llvm::Triple::FreeBSD:
@@ -20,7 +20,20 @@ Index: driver/linker-gcc.cpp
      args.push_back("-lc++");
      break;
    default:
-@@ -675,11 +675,14 @@ void ArgsBuilder::addDefaultPlatformLibs() {
+@@ -542,6 +542,12 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
+     args.push_back("-static");
+   }
+ 
++  // No BT CFI
++  if (triple.getOS() == llvm::Triple::OpenBSD) {
++    args.push_back("-Wl,--no-execute-only");
++    args.push_back("-Wl,-z,nobtcfi");
++  }
++
+   args.push_back("-o");
+   args.push_back(std::string(outputPath));
+ 
+@@ -687,11 +693,14 @@ void ArgsBuilder::addDefaultPlatformLibs() {
      args.push_back("-lrt");
      args.push_back("-ldl");
    // fallthrough
Index: patches/patch-driver_targetmachine_cpp
===================================================================
RCS file: /cvs/ports/lang/ldc/patches/patch-driver_targetmachine_cpp,v
retrieving revision 1.5
diff -u -p -r1.5 patch-driver_targetmachine_cpp
--- patches/patch-driver_targetmachine_cpp      8 Dec 2023 05:14:12 -0000       
1.5
+++ patches/patch-driver_targetmachine_cpp      24 May 2024 00:52:45 -0000
@@ -3,9 +3,9 @@ Taken from ports LLVM.
 Index: driver/targetmachine.cpp
 --- driver/targetmachine.cpp.orig
 +++ driver/targetmachine.cpp
-@@ -540,6 +540,8 @@ createTargetMachine(const std::string targetTriple, co
-       // these OSes.
-       // On Android, PIC is default as well.
+@@ -579,6 +579,8 @@ createTargetMachine(const std::string targetTriple, co
+       // We default to PIC code to avoid linking issues on FreeBSD, especially
+       // on aarch64.
        relocModel = llvm::Reloc::PIC_;
 +    } else if (triple.isOSOpenBSD()) {
 +      relocModel = llvm::Reloc::PIC_;
Index: patches/patch-gen_ctfloat_cpp
===================================================================
RCS file: patches/patch-gen_ctfloat_cpp
diff -N patches/patch-gen_ctfloat_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gen_ctfloat_cpp       24 May 2024 00:52:45 -0000
@@ -0,0 +1,14 @@
+Mismatched parameter, only matters on 32-bit.
+
+Index: gen/ctfloat.cpp
+--- gen/ctfloat.cpp.orig
++++ gen/ctfloat.cpp
+@@ -125,7 +125,7 @@ bool CTFloat::isFloat64LiteralOutOfRange(const char *l
+ 
+ 
////////////////////////////////////////////////////////////////////////////////
+ 
+-int CTFloat::sprint(char *str, size_t str_buf_length, char fmt, real_t x) {
++int CTFloat::sprint(char *str, d_size_t str_buf_length, char fmt, real_t x) {
+   assert(fmt == 'g' || fmt == 'a' || fmt == 'A');
+   const bool uppercase = fmt == 'A';
+ 
Index: patches/patch-runtime_CMakeLists_txt
===================================================================
RCS file: /cvs/ports/lang/ldc/patches/patch-runtime_CMakeLists_txt,v
retrieving revision 1.5
diff -u -p -r1.5 patch-runtime_CMakeLists_txt
--- patches/patch-runtime_CMakeLists_txt        8 Dec 2023 05:14:12 -0000       
1.5
+++ patches/patch-runtime_CMakeLists_txt        24 May 2024 00:52:45 -0000
@@ -13,7 +13,7 @@ Index: runtime/CMakeLists.txt
  set(D_EXTRA_FLAGS         ""                                  CACHE STRING 
"Runtime extra D compiler flags, separated by ';'")
  set(D_FLAGS_DEBUG         -g;-link-defaultlib-debug;-d-debug  CACHE STRING 
"Runtime D compiler flags (debug libraries), separated by ';'")
  set(D_FLAGS_RELEASE       -O3;-release;-femit-local-var-lifetime  CACHE 
STRING "Runtime D compiler flags (release libraries), separated by ';'")
-@@ -587,7 +587,7 @@ function(set_common_library_properties target name out
+@@ -588,7 +588,7 @@ function(set_common_library_properties target name out
      # linker default on Ubuntu 16.10 and above. As we might be building on an
      # older system (e.g. binary packages), we need to make sure the C parts 
are
      # built as PIC as well.
Index: patches/patch-runtime_druntime_src_rt_sections_elf_shared_d
===================================================================
RCS file: 
/cvs/ports/lang/ldc/patches/patch-runtime_druntime_src_rt_sections_elf_shared_d,v
retrieving revision 1.3
diff -u -p -r1.3 patch-runtime_druntime_src_rt_sections_elf_shared_d
--- patches/patch-runtime_druntime_src_rt_sections_elf_shared_d 12 Feb 2023 
22:57:55 -0000      1.3
+++ patches/patch-runtime_druntime_src_rt_sections_elf_shared_d 24 May 2024 
00:52:45 -0000
@@ -7,9 +7,9 @@ Index: runtime/druntime/src/rt/sections_
  else version (NetBSD) enum SharedELF = true;
 +else version (OpenBSD) enum SharedELF = true;
  else version (DragonFlyBSD) enum SharedELF = true;
+ else version (CRuntime_Bionic) enum SharedELF = true;
  else version (CRuntime_UClibc) enum SharedELF = true;
- else enum SharedELF = false;
-@@ -78,6 +79,12 @@ else version (NetBSD)
+@@ -79,6 +80,12 @@ else version (NetBSD)
      import core.sys.netbsd.sys.elf;
      import core.sys.netbsd.sys.link_elf;
  }
@@ -22,7 +22,7 @@ Index: runtime/druntime/src/rt/sections_
  else version (DragonFlyBSD)
  {
      import core.sys.dragonflybsd.dlfcn;
-@@ -217,6 +224,7 @@ __gshared bool _isRuntimeInitialized;
+@@ -219,6 +226,7 @@ __gshared bool _isRuntimeInitialized;
  version (FreeBSD) private __gshared void* dummy_ref;
  version (DragonFlyBSD) private __gshared void* dummy_ref;
  version (NetBSD) private __gshared void* dummy_ref;
@@ -30,7 +30,7 @@ Index: runtime/druntime/src/rt/sections_
  
  /****
   * Gets called on program startup just before GC is initialized.
-@@ -228,6 +236,7 @@ void initSections() nothrow @nogc
+@@ -230,6 +238,7 @@ void initSections() nothrow @nogc
      version (FreeBSD) dummy_ref = &_d_dso_registry;
      version (DragonFlyBSD) dummy_ref = &_d_dso_registry;
      version (NetBSD) dummy_ref = &_d_dso_registry;
@@ -38,7 +38,7 @@ Index: runtime/druntime/src/rt/sections_
  }
  
  
-@@ -402,6 +411,7 @@ else (private)
+@@ -404,6 +413,7 @@ else (private)
  version (FreeBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
  version (DragonFlyBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
  version (NetBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
@@ -46,7 +46,7 @@ Index: runtime/druntime/src/rt/sections_
  
  version (Shared)
  {
-@@ -938,6 +948,8 @@ version (Shared)
+@@ -940,6 +950,8 @@ version (Shared)
                      enum relocate = true;
                  else version (NetBSD)
                      enum relocate = true;
@@ -55,7 +55,7 @@ Index: runtime/druntime/src/rt/sections_
                  else version (DragonFlyBSD)
                      enum relocate = true;
                  else
-@@ -1153,18 +1165,18 @@ version (LDC)
+@@ -1177,12 +1189,12 @@ version (LDC)
      version (PPC)
      {
          extern(C) void* __tls_get_addr_opt(tls_index* ti) nothrow @nogc;
@@ -68,6 +68,11 @@ Index: runtime/druntime/src/rt/sections_
 -        alias __tls_get_addr = __tls_get_addr_opt;
 +        alias __emutls_get_address = __tls_get_addr_opt;
      }
+     else version (Android_X86) // extra underscore
+     {
+@@ -1190,10 +1202,10 @@ version (LDC)
+         alias __tls_get_addr = ___tls_get_addr;
+     }
      else
 -        extern(C) void* __tls_get_addr(tls_index* ti) nothrow @nogc;
 +        extern(C) void* __emutls_get_address(tls_index* ti) nothrow @nogc;
@@ -78,7 +83,16 @@ Index: runtime/druntime/src/rt/sections_
  
  /* The dynamic thread vector (DTV) pointers may point 0x8000 past the start of
   * each TLS block. This is at least true for PowerPC and Mips platforms.
-@@ -1251,7 +1263,7 @@ void[] getTLSRange(size_t mod, size_t sz, size_t align
+@@ -1261,7 +1273,7 @@ void[] getTLSRange(size_t mod, size_t sz, size_t align
+             if (mod != 0)
+             {
+                 auto ti = tls_index(mod, 0);
+-                reference = __tls_get_addr(&ti);
++                reference = __emutls_get_address(&ti);
+             }
+ 
+             if (reference != start)
+@@ -1282,7 +1294,7 @@ void[] getTLSRange(size_t mod, size_t sz, size_t align
  
          // base offset
          auto ti = tls_index(mod, 0);
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/lang/ldc/pkg/PLIST,v
retrieving revision 1.5
diff -u -p -r1.5 PLIST
--- pkg/PLIST   8 Dec 2023 05:14:12 -0000       1.5
+++ pkg/PLIST   24 May 2024 00:52:45 -0000
@@ -1,6 +1,7 @@
 @bin bin/ldc-build-plugin
 @bin bin/ldc-build-runtime
 @bin bin/ldc-profdata
+@bin bin/ldc-profgen
 @bin bin/ldc-prune-cache
 @bin bin/ldc2
 @bin bin/ldmd2
@@ -73,6 +74,7 @@ include/d/core/internal/gc/proxy.d
 include/d/core/internal/hash.d
 include/d/core/internal/lifetime.d
 include/d/core/internal/moving.d
+include/d/core/internal/newaa.d
 include/d/core/internal/parseoptions.d
 include/d/core/internal/postblit.d
 include/d/core/internal/qsort.d
@@ -87,6 +89,7 @@ include/d/core/internal/util/math.d
 include/d/core/internal/vararg/
 include/d/core/internal/vararg/aarch64.d
 include/d/core/internal/vararg/sysv_x64.d
+include/d/core/interpolation.d
 include/d/core/lifetime.d
 include/d/core/math.d
 include/d/core/memory.d
@@ -106,6 +109,7 @@ include/d/core/stdc/locale.d
 include/d/core/stdc/math.d
 include/d/core/stdc/signal.d
 include/d/core/stdc/stdarg.d
+include/d/core/stdc/stdatomic.d
 include/d/core/stdc/stddef.d
 include/d/core/stdc/stdint.d
 include/d/core/stdc/stdio.d
@@ -203,6 +207,10 @@ include/d/core/sys/freebsd/config.d
 include/d/core/sys/freebsd/dlfcn.d
 include/d/core/sys/freebsd/err.d
 include/d/core/sys/freebsd/execinfo.d
+include/d/core/sys/freebsd/ifaddrs.d
+include/d/core/sys/freebsd/net/
+include/d/core/sys/freebsd/net/if_.d
+include/d/core/sys/freebsd/net/if_dl.d
 include/d/core/sys/freebsd/netinet/
 include/d/core/sys/freebsd/netinet/in_.d
 include/d/core/sys/freebsd/pthread_np.d
@@ -220,7 +228,9 @@ include/d/core/sys/freebsd/sys/event.d
 include/d/core/sys/freebsd/sys/link_elf.d
 include/d/core/sys/freebsd/sys/mman.d
 include/d/core/sys/freebsd/sys/mount.d
+include/d/core/sys/freebsd/sys/socket.d
 include/d/core/sys/freebsd/sys/sysctl.d
+include/d/core/sys/freebsd/sys/types.d
 include/d/core/sys/freebsd/time.d
 include/d/core/sys/freebsd/unistd.d
 include/d/core/sys/linux/
@@ -238,6 +248,9 @@ include/d/core/sys/linux/input.d
 include/d/core/sys/linux/input_event_codes.d
 include/d/core/sys/linux/io_uring.d
 include/d/core/sys/linux/link.d
+include/d/core/sys/linux/linux/
+include/d/core/sys/linux/linux/if_arp.d
+include/d/core/sys/linux/linux/if_packet.d
 include/d/core/sys/linux/netinet/
 include/d/core/sys/linux/netinet/in_.d
 include/d/core/sys/linux/netinet/tcp.d

Reply via email to