www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20925] New: pragma(inline) should emit code to the calling CU

https://issues.dlang.org/show_bug.cgi?id=20925

          Issue ID: 20925
           Summary: pragma(inline) should emit code to the calling CU +
                    appropriate linker flags
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

inline functions should be emit to the calling CU.

they should be assigned an appropriate link flag such that linker appropriately
handles duplicate symbols:
  inline = 'linkonce'          (like `inline` in C)
  private inline = 'internal'  (like `static inline` in C)

ie; LLVM enumerates the linker flags:
https://llvm.org/docs/LangRef.html#linkage-types

Specifically, this should work:
---------------------

lib.d
-----
module lib;
pragma(inline, true)
void inl() {}


test.d
------
import lib;

int main()
{
    inl();
    return 0;
}

---------------------

Expect:

 dmd test.d
No link error! Currently:
 error LNK2019: unresolved external symbol "void lib.inl()" (__D3lib3inlFZv)
referenced in function __Dmain
--
Jun 12 2020