nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.22k stars 1.46k forks source link

fixes #9940; genericAssign does not take care of the importC variables in refc [backport] #23761

Closed ringabout closed 2 days ago

ringabout commented 2 days ago

fixes #9940

ringabout commented 2 days ago
  type
    Atomic*[T] {.importcpp: "std::atomic", completeStruct.} = object
      ## An atomic object with underlying type `T`.
      raw: T

std/atomics uses a non-existent field for importc types. It has caused troubles for ORC. After this PR, it won't work for refc with C++ backend as well.

ref https://github.com/nim-lang/Nim/issues/12726

type Atomic*[T]{.importcpp: "std::atomic", size:sizeof(T).} = object

It would be great to have this instead. Otherwise contrived fields really hurt the interoperability with c/cpp backends. std/atomics is broken for ORC with cpp backend already.

Araq commented 2 days ago

Yeah we need to fix Atomic[T] indeed, it's nuts.

github-actions[bot] commented 2 days ago

Thanks for your hard work on this PR! The lines below are statistics of the Nim compiler built from 828cd58d8a0376a5b7a6ad58d73d66617b37629a

Hint: mm: orc; opt: speed; options: -d:release 179022 lines; 8.513s; 664.703MiB peakmem