Your message dated Mon, 19 Feb 2024 19:00:11 +0000
with message-id <[email protected]>
and subject line Bug#1021584: fixed in ldc 1:1.36.0-1
has caused the Debian Bug report #1021584,
regarding ldc: add support for riscv64
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1021584: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021584
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: ldc
Version: 1:1.30.0-1
Severity: wishlist
Tags: ftbf,  patch
User: [email protected]
Usertags: riscv64
X-Debbugs-Cc: [email protected]

Dear Maintainer,

Now ldc does not support riscv64 either upstream or Debian. Fortunately,
The Arch linux has porting the riscv64 support[0] for ldc. And I try to
build ldc on Debian riscv64 arch with their patch. Despite the twists
and turns of the process, in the end the build was successfully. I also
got the support from upstream[1].

The patch attached is to add support for riscv64 on Debian. I have
tested it on my riscv machines.

The mirror issue in the patch here is I have to disable check D_COMPILER_FLAGS
from CMake. I am not sure if this is the inappropriate 
DADDITIONAL_DEFAULT_LDC_SWITCHES flag I added in the d/rules. Anyway, it
works.

The next version of ldc from upstream will have better support for
riscv64 as upstream said. I think this is good start to add support riscv64 
build about D language packages if apply the change on Debian.

Please let me know if there is any issues. 


[0]: 
https://github.com/felixonmars/archriscv-packages/blob/master/ldc/riscv64.patch
[1]: https://github.com/ldc-developers/ldc/issues/4046
-- 
Regards,
--
  Bo YU

diff -Nru ldc-1.30.0/debian/control ldc-1.30.0/debian/control
--- ldc-1.30.0/debian/control   2022-08-13 00:42:49.000000000 +0800
+++ ldc-1.30.0/debian/control   2022-08-13 02:28:55.000000000 +0800
@@ -26,7 +26,7 @@
 Vcs-Browser: https://salsa.debian.org/d-team/ldc
 
 Package: ldc
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf i386 riscv64
 Provides: d-compiler,
           d-v2-compiler
 Depends: libphobos2-ldc-shared-dev (= ${binary:Version}),
@@ -41,7 +41,7 @@
 
 Package: libphobos2-ldc-shared100
 Section: libs
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf i386 riscv64
 Multi-Arch: same
 Depends: ${misc:Depends},
          ${shlibs:Depends}
@@ -56,7 +56,7 @@
 
 Package: libphobos2-ldc-shared-dev
 Section: libdevel
-Architecture: amd64 arm64 armhf i386
+Architecture: amd64 arm64 armhf i386 riscv64
 Depends: libphobos2-ldc-shared100 (= ${binary:Version}),
          ${misc:Depends},
          ${shlibs:Depends}
diff -Nru ldc-1.30.0/debian/patches/04_support-riscv64.patch 
ldc-1.30.0/debian/patches/04_support-riscv64.patch
--- ldc-1.30.0/debian/patches/04_support-riscv64.patch  1970-01-01 
07:30:00.000000000 +0730
+++ ldc-1.30.0/debian/patches/04_support-riscv64.patch  2022-08-13 
02:28:55.000000000 +0800
@@ -0,0 +1,578 @@
+refer to:
+https://patch-diff.githubusercontent.com/raw/ldc-developers/ldc/pull/4007.patch
+https://patch-diff.githubusercontent.com/raw/ldc-developers/druntime/pull/204.patch
+https://github.com/ldc-developers/phobos/pull/71.patch
+
+Help from:
+https://github.com/ldc-developers/ldc/issues/4046
+
+--- a/driver/tool.cpp
++++ b/driver/tool.cpp
+@@ -120,6 +120,11 @@
+     }
+     return;
+ 
++  case Triple::riscv64:
++      args.push_back("-march=rv64gc");
++      args.push_back("-mabi=lp64d");
++    return;
++
+   default:
+     break;
+   }
+--- /dev/null
++++ b/gen/abi-riscv64.cpp
+@@ -0,0 +1,234 @@
++//===-- gen/abi-riscv64.cpp - RISCV64 ABI description -----------*- C++ 
-*-===//
++//
++//                         LDC – the LLVM D compiler
++//
++// This file is distributed under the BSD-style LDC license. See the LICENSE
++// file for details.
++//
++//===----------------------------------------------------------------------===//
++
++#include "gen/abi.h"
++#include "gen/abi-generic.h"
++#include "gen/abi-riscv64.h"
++#include "gen/dvalue.h"
++#include "gen/irstate.h"
++#include "gen/llvmhelpers.h"
++#include "gen/tollvm.h"
++
++namespace {
++struct Integer2Rewrite : BaseBitcastABIRewrite {
++  LLType *type(Type *t) override {
++    return LLStructType::get(gIR->context(),
++                             {DtoType(Type::tint64), DtoType(Type::tint64)});
++  }
++};
++
++struct FlattenedFields {
++  struct FlattenedField {
++    Type *ty = nullptr;
++    unsigned offset = 0;
++  };
++  FlattenedField fields[2];
++  int length = 0; // use -1 to represent "no need to rewrite" condition
++};
++
++FlattenedFields visitStructFields(Type *ty, unsigned baseOffset) {
++  // recursively visit a POD struct to flatten it
++  // FIXME: may cause low performance
++  // dmd may cache argtypes in some other architectures as a TypeTuple, but we
++  // need to additionally store field offsets to realign later
++  FlattenedFields result;
++  if (auto ts = ty->toBasetype()->isTypeStruct()) {
++    for (auto fi : ts->sym->fields) {
++      auto sub = visitStructFields(fi->type, baseOffset + fi->offset);
++      if (sub.length == -1 || result.length + sub.length > 2) {
++        result.length = -1;
++        return result;
++      }
++      for (unsigned i = 0; i < (unsigned)sub.length; ++i) {
++        result.fields[result.length++] = sub.fields[i];
++      }
++    }
++    return result;
++  }
++  switch (ty->toBasetype()->ty) {
++  case TY::Tcomplex32: // treat it as {float32, float32}
++    result.fields[0].ty = Type::tfloat32->pointerTo();
++    result.fields[1].ty = Type::tfloat32->pointerTo();
++    result.fields[0].offset = baseOffset;
++    result.fields[1].offset = baseOffset + 4;
++    result.length = 2;
++    break;
++  case TY::Tcomplex64: // treat it as {float64, float64}
++    result.fields[0].ty = Type::tfloat64->pointerTo();
++    result.fields[1].ty = Type::tfloat64->pointerTo();
++    result.fields[0].offset = baseOffset;
++    result.fields[1].offset = baseOffset + 8;
++    result.length = 2;
++    break;
++  default:
++    if (ty->toBasetype()->size() > 8) {
++      // field larger than XLEN and FLEN
++      result.length = -1;
++      break;
++    }
++    result.fields[0].ty = ty->toBasetype();
++    result.fields[0].offset = baseOffset;
++    result.length = 1;
++    break;
++  }
++  return result;
++}
++
++bool requireHardfloatRewrite(Type *ty) {
++  if (!ty->toBasetype()->isTypeStruct())
++    return false;
++  auto result = visitStructFields(ty, 0);
++  if (result.length <= 0)
++    return false;
++  if (result.length == 1)
++    return result.fields[0].ty->isfloating();
++  return result.fields[0].ty->isfloating() || 
result.fields[1].ty->isfloating();
++}
++
++struct HardfloatRewrite : ABIRewrite {
++  LLValue *put(DValue *dv, bool, bool) override {
++    // realign fields
++    // FIXME: no need to alloc an extra buffer in many conditions
++    const auto flat = visitStructFields(dv->type, 0);
++    LLType *asType = type(dv->type, flat);
++    const unsigned alignment = getABITypeAlign(asType);
++    assert(dv->isLVal());
++    LLValue *address = DtoLVal(dv);
++    LLValue *buffer =
++        DtoRawAlloca(asType, alignment, ".HardfloatRewrite_arg_storage");
++    for (unsigned i = 0; i < (unsigned)flat.length; ++i) {
++      DtoMemCpy(
++          DtoGEP(buffer, 0, i),
++          DtoGEP1(DtoBitCast(address, getVoidPtrType()), 
flat.fields[i].offset),
++          DtoConstSize_t(flat.fields[i].ty->size()));
++    }
++    return DtoLoad(buffer, ".HardfloatRewrite_arg");
++  }
++  LLValue *getLVal(Type *dty, LLValue *v) override {
++    // inverse operation of method "put"
++    const auto flat = visitStructFields(dty, 0);
++    LLType *asType = type(dty, flat);
++    const unsigned alignment = DtoAlignment(dty);
++    LLValue *buffer = DtoAllocaDump(v, asType, getABITypeAlign(asType),
++                                    ".HardfloatRewrite_param");
++    LLValue *ret = DtoRawAlloca(DtoType(dty), alignment,
++                                ".HardfloatRewrite_param_storage");
++    for (unsigned i = 0; i < (unsigned)flat.length; ++i) {
++      DtoMemCpy(
++          DtoGEP1(DtoBitCast(ret, getVoidPtrType()), flat.fields[i].offset),
++          DtoGEP(buffer, 0, i), DtoConstSize_t(flat.fields[i].ty->size()));
++    }
++    return ret;
++  }
++  LLType *type(Type *ty, const FlattenedFields &flat) {
++    if (flat.length == 1) {
++      return LLStructType::get(gIR->context(), {DtoType(flat.fields[0].ty)},
++                               false);
++    }
++    assert(flat.length == 2);
++    LLType *t[2];
++    for (unsigned i = 0; i < 2; ++i) {
++      t[i] = flat.fields[i].ty->isfloating()
++                 ? DtoType(flat.fields[i].ty)
++                 : LLIntegerType::get(gIR->context(),
++                                      flat.fields[i].ty->size() * 8);
++    }
++    return LLStructType::get(gIR->context(), {t[0], t[1]}, false);
++  }
++  LLType *type(Type *ty) override { return type(ty, visitStructFields(ty, 
0)); }
++};
++} // anonymous namespace
++
++struct RISCV64TargetABI : TargetABI {
++private:
++  HardfloatRewrite hardfloatRewrite;
++  IndirectByvalRewrite indirectByvalRewrite;
++  Integer2Rewrite integer2Rewrite;
++  IntegerRewrite integerRewrite;
++
++public:
++  Type *vaListType() override {
++    // va_list is void*
++    return Type::tvoid->pointerTo();
++  }
++  bool returnInArg(TypeFunction *tf, bool) override {
++    if (tf->isref()) {
++      return false;
++    }
++    Type *rt = tf->next->toBasetype();
++    if (!rt->size())
++      return false;
++    if (!isPOD(rt))
++      return true;
++    return rt->size() > 16;
++  }
++  bool passByVal(TypeFunction *, Type *t) override {
++    if (!t->size())
++      return false;
++    if (t->toBasetype()->ty == TY::Tcomplex80) {
++      // rewrite it later to bypass the RVal problem
++      return false;
++    }
++    return t->size() > 16;
++  }
++  void rewriteFunctionType(IrFuncTy &fty) override {
++    if (!fty.ret->byref) {
++      if (!skipReturnValueRewrite(fty)) {
++        if (!fty.ret->byref && isPOD(fty.ret->type) &&
++            requireHardfloatRewrite(fty.ret->type)) {
++          // rewrite here because we should not apply this to variadic 
arguments
++          hardfloatRewrite.applyTo(*fty.ret);
++        } else {
++          rewriteArgument(fty, *fty.ret);
++        }
++      }
++    }
++
++    for (auto arg : fty.args) {
++      if (!arg->byref && isPOD(arg->type) &&
++          requireHardfloatRewrite(arg->type)) {
++        // rewrite here because we should not apply this to variadic arguments
++        hardfloatRewrite.applyTo(*arg);
++      } else {
++        rewriteArgument(fty, *arg);
++      }
++    }
++  }
++
++  void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override {
++    if (arg.byref) {
++      return;
++    }
++
++    Type *ty = arg.type->toBasetype();
++    if (ty->ty == TY::Tcomplex80) {
++      // {real, real} should be passed in memory
++      indirectByvalRewrite.applyTo(arg);
++      return;
++    }
++
++    if (!isPOD(arg.type)) {
++      // non-PODs should be passed in memory
++      indirectByvalRewrite.applyTo(arg);
++      return;
++    }
++
++    if (isAggregate(ty) && ty->size() && ty->size() <= 16) {
++      if (ty->size() > 8 && DtoAlignment(ty) < 16) {
++        // pass the aggregate as {int64, int64} to avoid wrong alignment
++        integer2Rewrite.applyToIfNotObsolete(arg);
++      } else {
++        integerRewrite.applyToIfNotObsolete(arg);
++      }
++    }
++  }
++};
++
++// The public getter for abi.cpp
++TargetABI *getRISCV64TargetABI() { return new RISCV64TargetABI(); }
+--- /dev/null
++++ b/gen/abi-riscv64.h
+@@ -0,0 +1,18 @@
++//===-- gen/abi-riscv64.h - RISCV64 ABI description ------------*- C++ 
-*-===//
++//
++//                         LDC – the LLVM D compiler
++//
++// This file is distributed under the BSD-style LDC license. See the LICENSE
++// file for details.
++//
++//===----------------------------------------------------------------------===//
++//
++// The ABI implementation used for RISCV64 targets.
++//
++//===----------------------------------------------------------------------===//
++
++#pragma once
++
++struct TargetABI;
++
++TargetABI *getRISCV64TargetABI();
+--- a/gen/abi.cpp
++++ b/gen/abi.cpp
+@@ -17,6 +17,7 @@
+ #include "gen/abi-arm.h"
+ #include "gen/abi-generic.h"
+ #include "gen/abi-mips64.h"
++#include "gen/abi-riscv64.h"
+ #include "gen/abi-ppc.h"
+ #include "gen/abi-ppc64le.h"
+ #include "gen/abi-win64.h"
+@@ -275,6 +276,8 @@
+   case llvm::Triple::mips64:
+   case llvm::Triple::mips64el:
+     return getMIPS64TargetABI(global.params.targetTriple->isArch64Bit());
++  case llvm::Triple::riscv64:
++    return getRISCV64TargetABI();
+   case llvm::Triple::ppc:
+   case llvm::Triple::ppc64:
+     return getPPCTargetABI(global.params.targetTriple->isArch64Bit());
+--- a/runtime/druntime/src/core/stdc/stdarg.d
++++ b/runtime/druntime/src/core/stdc/stdarg.d
+@@ -47,6 +47,8 @@
+ version (MIPS64)  version = MIPS_Any;
+ version (PPC)     version = PPC_Any;
+ version (PPC64)   version = PPC_Any;
++version (RISCV32) version = RISCV_Any;
++version (RISCV64) version = RISCV_Any;
+ 
+ version (GNU)
+ {
+@@ -130,6 +132,12 @@
+ {
+     alias va_list = core.internal.vararg.aarch64.va_list;
+ }
++else version (RISCV_Any)
++{
++    // The va_list type is void*, according to RISCV Calling Convention
++    // 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc
++    alias va_list = void*;
++}
+ else
+ {
+     alias va_list = char*; // incl. unknown platforms
+@@ -259,6 +267,19 @@
+         ap += T.sizeof.alignUp;
+         return *p;
+     }
++    else version (RISCV_Any)
++    {
++        static if (T.sizeof > (size_t.sizeof << 1))
++            auto p = *cast(T**) ap;
++        else
++        {
++            static if (T.alignof == (size_t.sizeof << 1))
++                ap = ap.alignUp!(size_t.sizeof << 1);
++            auto p = cast(T*) ap;
++        }
++        ap += T.sizeof.alignUp;
++        return *p;
++    }
+     else
+         static assert(0, "Unsupported platform");
+ }
+--- a/runtime/druntime/src/core/sys/linux/elf.d
++++ b/runtime/druntime/src/core/sys/linux/elf.d
+@@ -2531,3 +2531,66 @@
+ enum R_TILEGX_GNU_VTENTRY =    129;
+ 
+ enum R_TILEGX_NUM =            130;
++
++enum EF_RISCV_RVC =              0x0001;
++enum EF_RISCV_FLOAT_ABI =        0x0006;
++enum EF_RISCV_FLOAT_ABI_SOFT =   0x0000;
++enum EF_RISCV_FLOAT_ABI_SINGLE = 0x0002;
++enum EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004;
++enum EF_RISCV_FLOAT_ABI_QUAD =   0x0006;
++enum R_RISCV_NONE =            0;
++enum R_RISCV_32 =              1;
++enum R_RISCV_64 =              2;
++enum R_RISCV_RELATIVE =        3;
++enum R_RISCV_COPY =            4;
++enum R_RISCV_JUMP_SLOT =       5;
++enum R_RISCV_TLS_DTPMOD32 =    6;
++enum R_RISCV_TLS_DTPMOD64 =    7;
++enum R_RISCV_TLS_DTPREL32 =    8;
++enum R_RISCV_TLS_DTPREL64 =    9;
++enum R_RISCV_TLS_TPREL32 =     10;
++enum R_RISCV_TLS_TPREL64 =     11;
++enum R_RISCV_BRANCH =          16;
++enum R_RISCV_JAL =             17;
++enum R_RISCV_CALL =            18;
++enum R_RISCV_CALL_PLT =        19;
++enum R_RISCV_GOT_HI20 =        20;
++enum R_RISCV_TLS_GOT_HI20 =    21;
++enum R_RISCV_TLS_GD_HI20 =     22;
++enum R_RISCV_PCREL_HI20 =      23;
++enum R_RISCV_PCREL_LO12_I =    24;
++enum R_RISCV_PCREL_LO12_S =    25;
++enum R_RISCV_HI20 =            26;
++enum R_RISCV_LO12_I =          27;
++enum R_RISCV_LO12_S =          28;
++enum R_RISCV_TPREL_HI20 =      29;
++enum R_RISCV_TPREL_LO12_I =    30;
++enum R_RISCV_TPREL_LO12_S =    31;
++enum R_RISCV_TPREL_ADD =       32;
++enum R_RISCV_ADD8 =            33;
++enum R_RISCV_ADD16 =           34;
++enum R_RISCV_ADD32 =           35;
++enum R_RISCV_ADD64 =           36;
++enum R_RISCV_SUB8 =            37;
++enum R_RISCV_SUB16 =           38;
++enum R_RISCV_SUB32 =           39;
++enum R_RISCV_SUB64 =           40;
++enum R_RISCV_GNU_VTINHERIT =   41;
++enum R_RISCV_GNU_VTENTRY =     42;
++enum R_RISCV_ALIGN =           43;
++enum R_RISCV_RVC_BRANCH =      44;
++enum R_RISCV_RVC_JUMP =        45;
++enum R_RISCV_RVC_LUI =         46;
++enum R_RISCV_GPREL_I =         47;
++enum R_RISCV_GPREL_S =         48;
++enum R_RISCV_TPREL_I =         49;
++enum R_RISCV_TPREL_S =         50;
++enum R_RISCV_RELAX =           51;
++enum R_RISCV_SUB6 =            52;
++enum R_RISCV_SET6 =            53;
++enum R_RISCV_SET8 =            54;
++enum R_RISCV_SET16 =           55;
++enum R_RISCV_SET32 =           56;
++enum R_RISCV_32_PCREL =        57;
++enum R_RISCV_IRELATIVE =       58;
++enum R_RISCV_NUM =             59;
+--- a/runtime/druntime/src/core/sys/posix/fcntl.d
++++ b/runtime/druntime/src/core/sys/posix/fcntl.d
+@@ -123,6 +123,12 @@
+     enum F_SETLK        = 6;
+     enum F_SETLKW       = 7;
+   }
++  else version (RISCV64)
++  {
++    enum F_GETLK        = 5;
++    enum F_SETLK        = 6;
++    enum F_SETLKW       = 7;
++  }
+   else version (SystemZ)
+   {
+     static assert(off_t.sizeof == 8);
+--- a/runtime/druntime/src/core/thread/osthread.d
++++ b/runtime/druntime/src/core/thread/osthread.d
+@@ -37,6 +37,9 @@
+     version (PPC)   version = PPC_Any;
+     version (PPC64) version = PPC_Any;
+ 
++    version (RISCV32) version = RISCV_Any;
++    version (RISCV64) version = RISCV_Any;
++
+     version (SupportSanitizers)
+     {
+         import ldc.sanitizers_optionally_linked;
+@@ -1568,6 +1571,27 @@
+             asm pure nothrow @nogc { (store ~ " $29, %0") : "=m" (sp); }
+             asm pure nothrow @nogc { ".set at"; }
+         }
++        else version (RISCV_Any)
++        {
++            version (RISCV32)      enum store = "sw";
++            else version (RISCV64) enum store = "sd";
++            else static assert(0);
++
++            // Callee-save registers, according to RISCV Calling Convention
++            // 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc
++            size_t[24] regs = void;
++            static foreach (i; 0 .. 12)
++            {{
++                enum int j = i;
++                asm pure nothrow @nogc { (store ~ " s"~j.stringof~", %0") : 
"=m" (regs[i]); }
++            }}
++            static foreach (i; 0 .. 12)
++            {{
++                enum int j = i;
++                asm pure nothrow @nogc { ("f" ~ store ~ " fs"~j.stringof~", 
%0") : "=m" (regs[i + 12]); }
++            }}
++            asm pure nothrow @nogc { (store ~ " sp, %0") : "=m" (sp); }
++        }
+         else
+         {
+             static assert(false, "Architecture not supported.");
+--- a/runtime/druntime/src/core/vararg.d
++++ b/runtime/druntime/src/core/vararg.d
+@@ -28,6 +28,8 @@
+ version (MIPS64)  version = MIPS_Any;
+ version (PPC)     version = PPC_Any;
+ version (PPC64)   version = PPC_Any;
++version (RISCV32) version = RISCV_Any;
++version (RISCV64) version = RISCV_Any;
+ 
+ version (ARM_Any)
+ {
+@@ -136,6 +138,21 @@
+         ap += tsize.alignUp;
+         parmn[0..tsize] = p[0..tsize];
+     }
++    else version (RISCV_Any)
++    {
++        const tsize = ti.tsize;
++        void* p;
++        if (tsize > (size_t.sizeof << 1))
++            p = *cast(void**) ap;
++        else
++        {
++            if (tsize == (size_t.sizeof << 1))
++                ap = ap.alignUp!(size_t.sizeof << 1);
++            p = cast(void*) ap;
++        }
++        ap += tsize.alignUp;
++        parmn[0..tsize] = p[0..tsize];
++    }
+     else
+         static assert(0, "Unsupported platform");
+ }
+--- a/runtime/druntime/src/rt/dwarfeh.d
++++ b/runtime/druntime/src/rt/dwarfeh.d
+@@ -84,6 +84,16 @@
+     enum eh_exception_regno = 4;
+     enum eh_selector_regno = 5;
+ }
++else version (RISCV64)
++{
++    enum eh_exception_regno = 10;
++    enum eh_selector_regno = 11;
++}
++else version (RISCV32)
++{
++    enum eh_exception_regno = 10;
++    enum eh_selector_regno = 11;
++}
+ else
+ {
+     static assert(0, "Unknown EH register numbers for this architecture");
+--- a/driver/targetmachine.cpp
++++ b/driver/targetmachine.cpp
+@@ -102,6 +102,8 @@
+     return "elfv1";
+   case llvm::Triple::ppc64le:
+     return "elfv2";
++  case llvm::Triple::riscv64:
++    return "lp64d";
+   default:
+     return "";
+   }
+@@ -418,6 +420,10 @@
+     features.push_back("+cx16");
+   }
+ 
++  if (triple.getArch() == llvm::Triple::riscv64 && !hasFeature("d")) {
++    features.push_back("+d");
++  }
++
+   // Handle cases where LLVM picks wrong default relocModel
+   if (!relocModel.hasValue()) {
+     if (triple.isOSDarwin()) {
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -123,6 +123,9 @@
+             set(C_SYSTEM_LIBS m c)
+         elseif("${TARGET_SYSTEM}" MATCHES "Linux")
+             set(C_SYSTEM_LIBS m pthread rt dl z)
++                if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "riscv64")
++                    set(C_SYSTEM_LIBS atomic)
++                endif()
+         else()
+             set(C_SYSTEM_LIBS m pthread z)
+         endif()
+@@ -348,8 +351,8 @@
+     )
+   endfunction()
+ 
+-  set(target_arch "AArch64;AMDGPU;ARM;Mips;NVPTX;PowerPC;SystemZ;X86")
+-  set(target_name "aarch64;amdgcn;arm;mips;nvvm;ppc;s390;x86")
++  set(target_arch "AArch64;AMDGPU;ARM;Mips;NVPTX;PowerPC;RISCV;SystemZ;X86")
++  set(target_name "aarch64;amdgcn;arm;mips;nvvm;ppc;riscv64;s390;x86")
+ 
+   foreach(target ${LLVM_TARGETS_TO_BUILD})
+     list(FIND target_arch ${target} idx)
+--- a/cmake/Modules/ExtractDMDSystemLinker.cmake
++++ b/cmake/Modules/ExtractDMDSystemLinker.cmake
+@@ -39,7 +39,10 @@
+ )
+ 
+ if(NOT "${result_code}" STREQUAL "0")
+-    message(FATAL_ERROR "Failed to link empty D program using '${D_COMPILER} 
${D_COMPILER_FLAGS} ${DFLAGS_BASE}':\n${stderr}")
++    elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "riscv64")
++        message("on riscv64 arch, not check the cmake result_code")
++    else()
++        message(FATAL_ERROR "Failed to link empty D program using 
'${D_COMPILER} ${D_COMPILER_FLAGS} ${DFLAGS_BASE}':\n${stderr}")
+ endif()
+ 
+ if("${D_COMPILER_ID}" STREQUAL "GDMD")
diff -Nru ldc-1.30.0/debian/patches/series ldc-1.30.0/debian/patches/series
--- ldc-1.30.0/debian/patches/series    2022-08-13 00:44:23.000000000 +0800
+++ ldc-1.30.0/debian/patches/series    2022-08-13 02:28:55.000000000 +0800
@@ -1,3 +1,4 @@
 01_no-zlib-embed.patch
 02_ldc_include_path.diff
 03_ldc-no-default-rpath.patch
+04_support-riscv64.patch
diff -Nru ldc-1.30.0/debian/rules ldc-1.30.0/debian/rules
--- ldc-1.30.0/debian/rules     2022-08-13 00:36:13.000000000 +0800
+++ ldc-1.30.0/debian/rules     2022-08-13 02:28:55.000000000 +0800
@@ -7,9 +7,19 @@
 CFLAGS += $(CPPFLAGS)
 CXXFLAGS += $(CPPFLAGS)
 
+# Link with libatomic on riscv64 to get access to the __atomic_* functions
+ifeq ($(DEB_HOST_ARCH),riscv64)
+        export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic 
-Wl,--as-needed
+endif
+
+
 LDC_BUILD_FLAGS = 
-DINCLUDE_INSTALL_DIR='/usr/lib/ldc/${DEB_HOST_MULTIARCH}/include/d' \
-               -DLDC_DYNAMIC_COMPILE=OFF
-BOOTSTRAP_LDC_FLAGS = -DD_COMPILER=/usr/bin/gdmd -DBUILD_SHARED_LIBS=ON
+               -DLDC_DYNAMIC_COMPILE=OFF 
-DC_SYSTEM_LIBS='atomic;m;pthread;rt;dl;z'
+        
-DADDITIONAL_DEFAULT_LDC_SWITCHES='"-platformlib=atomic,rt,dl,pthread,m"'
+
+BOOTSTRAP_LDC_FLAGS = -DD_COMPILER=/usr/bin/gdmd -DBUILD_SHARED_LIBS=ON \
+               -DC_SYSTEM_LIBS='atomic;m;pthread;rt;dl;z'
+        
-DADDITIONAL_DEFAULT_LDC_SWITCHES='"-platformlib=atomic,rt,dl,pthread,m"'
 
 ifeq ($(DEB_HOST_ARCH),armhf)
 LDC_BUILD_FLAGS += -DD_COMPILER_FLAGS=-mattr=-neon

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: ldc
Source-Version: 1:1.36.0-1
Done: Matthias Klumpp <[email protected]>

We believe that the bug you reported is fixed in the latest version of
ldc, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Matthias Klumpp <[email protected]> (supplier of updated ldc package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sun, 18 Feb 2024 20:24:16 +0100
Source: ldc
Binary: ldc ldc-dbgsym libphobos2-ldc-shared-dev 
libphobos2-ldc-shared-dev-dbgsym libphobos2-ldc-shared106 
libphobos2-ldc-shared106-dbgsym
Architecture: source amd64
Version: 1:1.36.0-1
Distribution: unstable
Urgency: medium
Maintainer: Debian D Language Group <[email protected]>
Changed-By: Matthias Klumpp <[email protected]>
Description:
 ldc        - LLVM D Compiler
 libphobos2-ldc-shared-dev - LLVM D Compiler - Standard and runtime libraries, 
imports
 libphobos2-ldc-shared106 - LLVM D Compiler - Standard and runtime libraries
Closes: 1021584 1056110 1064166
Changes:
 ldc (1:1.36.0-1) unstable; urgency=medium
 .
   * New upstream version: 1.36.0
     - Supports LLVM 17 (Closes: #1056110)
   * Add Pass-NDEBUG-through-LDC_CXXFLAGS.patch
     - Fixes linker failure for LDC tools with current LLVM
   * Build on riscv64 (thanks to Bo YU, Closes: #1021584)
   * LDC should already work fine with 64-bit time on 32-bit
     architectures, just to be on the safe side though, enforce
     time64,lfs on 32-bit architectures for C code as well (Closes: #1064166)
   * Update d/copyright
   * Update dh version to 13
   * Update build-deps to switch away from transitional packages
Checksums-Sha1:
 95cb440ced123dbfb4f037d1404b7284084d7cf5 2377 ldc_1.36.0-1.dsc
 76b3bfa447c2f7385e2266541467eaf5d39f60c4 8670692 ldc_1.36.0.orig.tar.gz
 5da7b6deffa8633cb5dda8992d31beccfb507d1b 20428 ldc_1.36.0-1.debian.tar.xz
 35dbb96c03eb3d62544eaccd561510af1705adff 52687300 ldc-dbgsym_1.36.0-1_amd64.deb
 7cad3fa8ab3c3aa8ceeb06f051e6050a75100c3c 10333 ldc_1.36.0-1_amd64.buildinfo
 299607e8bb6a6576c9996db4ef5dcc42f0f29989 4100704 ldc_1.36.0-1_amd64.deb
 56b99923b738efe9b4fafcb206f886c7aaf4c167 1706840 
libphobos2-ldc-shared-dev-dbgsym_1.36.0-1_amd64.deb
 91d53209dbb1cebac38b88409d0ec7e90b3cc779 6486952 
libphobos2-ldc-shared-dev_1.36.0-1_amd64.deb
 eb14009d37fbea5f3cb35184bf87e48e970a6e41 312788 
libphobos2-ldc-shared106-dbgsym_1.36.0-1_amd64.deb
 73cd738ae6d651b5d06214642970a98957ec3c08 1278324 
libphobos2-ldc-shared106_1.36.0-1_amd64.deb
Checksums-Sha256:
 427e34db7bba6347e2a00c322c028ff1aa2ea5effd36a2c522d76f18d67900f0 2377 
ldc_1.36.0-1.dsc
 2a72e4d8bd61afe24d100cdd468d1e1fe5bbf75e62f88d4e8a8af674988ae98b 8670692 
ldc_1.36.0.orig.tar.gz
 41b3c52a4e96f2df14579fc0e293b79ab7c4c94262731f1de7167bcd5d1275eb 20428 
ldc_1.36.0-1.debian.tar.xz
 22a1637750b22d5b1fcc21337013bb1eb53c602af9c3edd451c24472dbd3dd4f 52687300 
ldc-dbgsym_1.36.0-1_amd64.deb
 4686051d637399ac377b16159048861a2c8bef83e7a348be3f4d699df5ca383b 10333 
ldc_1.36.0-1_amd64.buildinfo
 4f650913572b5f536980d5e329bb5c4adfe612ac2e17a85b0428a52f39e16ae2 4100704 
ldc_1.36.0-1_amd64.deb
 7cd1cba9d98ab3f48909cac2b220cad1c0d2088c957f284f350c4757fb730de7 1706840 
libphobos2-ldc-shared-dev-dbgsym_1.36.0-1_amd64.deb
 36821d7d079c5341e78d33a3d1693b45cef9629d16a8f0c9f0710857dc3b7503 6486952 
libphobos2-ldc-shared-dev_1.36.0-1_amd64.deb
 30b99696ae17bcc489cfad752cfedc0293bfe655cdc22ba64b085d4fa98eb1bd 312788 
libphobos2-ldc-shared106-dbgsym_1.36.0-1_amd64.deb
 023bc06d991c0b1628033a0565ca04228a2dd251e96a509df85bd583f8abc9af 1278324 
libphobos2-ldc-shared106_1.36.0-1_amd64.deb
Files:
 353dfab4f8f3680c9369074092b9e0e2 2377 devel optional ldc_1.36.0-1.dsc
 ebd89f5f002aefe4025549252eb83c1f 8670692 devel optional ldc_1.36.0.orig.tar.gz
 147ff5e8a6c646ce35c87181fd510162 20428 devel optional 
ldc_1.36.0-1.debian.tar.xz
 7c399fcf75a7e253a3b825213cbed4a7 52687300 debug optional 
ldc-dbgsym_1.36.0-1_amd64.deb
 369b48e5fae32c369ea2410ca498bcd7 10333 devel optional 
ldc_1.36.0-1_amd64.buildinfo
 311b0b857dc65048e76a697dd8af7c42 4100704 devel optional ldc_1.36.0-1_amd64.deb
 0d614786a8c257a0b6e8bb0f6eb41356 1706840 debug optional 
libphobos2-ldc-shared-dev-dbgsym_1.36.0-1_amd64.deb
 8ac10aeb9ace89b972260dbdae721522 6486952 libdevel optional 
libphobos2-ldc-shared-dev_1.36.0-1_amd64.deb
 d77e1f2513101437bd8aad5ea0c63973 312788 debug optional 
libphobos2-ldc-shared106-dbgsym_1.36.0-1_amd64.deb
 7b29555ee543b2b380d476c3ecc8ba68 1278324 libs optional 
libphobos2-ldc-shared106_1.36.0-1_amd64.deb

-----BEGIN PGP SIGNATURE-----

iQJDBAEBCAAtFiEE0zo/DKFrCsxRpgc4SUyKX79N7OsFAmXSdc4PHG1ha0BkZWJp
YW4ub3JnAAoJEElMil+/TezrOfYP/3Lk6d5UlvcbyuVaWUjw6GPW4oqSWq/6YppB
dDHTB0Shu+2JDpJOvTkAERDXM7LHd8vvpyUvPOWHZbpViTP5gkVlePQnm9QQNwnW
qyVKOavIzFUkx4pZ35v0O6y0Yg9mki7jCVhZ+Grk3Fw97mTgrQoc5luRvIXM9xGf
7EsIDoFyzhclwn+GysKFwE55tUUpJCQZkAjZmvr5DhDsO2VtB/qpeGnf9YR8MErA
877v73OpNg+EL4xyCIggQYmUJBnk68SAIK978O+Z+drlB4qI3dTLKM5F9InqLjzN
325kXniyRldeHjIF8R0fiDpp4u+08iuwkjnDf5waIdTDEyvTbLiBsDc5yhs0gLMf
jUl0yK4jH84CETPVDTE9y+eA1Vg0tQDlQo4a9wfsG1WJUB+aLSweA4E8ggjYdTFE
3G7rXZGaWX0MRlBytp/PPidL74diKjj7kkcGYXWMBf7W91Npkmt/GpMXdBuObbGy
wk9IBncew9n8jE0aMy3cJeUPHDav/JqfXu0qyP2SUZ5kKaY4XfAOvBObKaYKQc3q
G92bEQ0+vera6iXrzEschcTsoPEkAAJpY+SqO1h5p/oucDWSbUB84TspB/STm8zK
FvQeUtKP7OBNi+gS2q/CAtCnWe4i1vv0dvIfEXCVqaJFRd9oZvl68y0yPIijinzr
hxHEKguT
=s1a4
-----END PGP SIGNATURE-----

Attachment: pgpnTnVK3w45l.pgp
Description: PGP signature


--- End Message ---

Reply via email to