tools icon indicating copy to clipboard operation
tools copied to clipboard

RDMD: -g switch produces linker error

Open dlang-bugzilla-migration opened this issue 3 years ago • 0 comments

Transferred from: https://issues.dlang.org/show_bug.cgi?id=15533

User golovanov_alexey reported (2016-Jan-09 09:34:01):

Created attachment 1572

reduced test case (see moduleB import)

From forum: http://forum.dlang.org/thread/[email protected]

OS: Windows 7 (32 bit) DMD: 2.069.2 and 2.070.0-b1 RDMD: build 20160103

Problem: import inside function produced linker error then -g switch used. Test files in attach:

moduleA.d test\moduleB.d test\moduleC.d

module moduleA;

public void funcA () {
  import test.moduleB: funcB;
  return;
}

void main(string[] args) {
  return;
}
module test.moduleB;

//import test.moduleC: funcC;  //this works

public void funcB () {
  import test.moduleC: funcC;  //linker error
  funcC();

  return;
}
module test.moduleC;

public void funcC () {
  return;
}
C:\dmd2\windows\bin\rdmd.exe moduleA.d
//no errors, moduleA.exe created


C:\dmd2\windows\bin\rdmd.exe -g moduleA.d
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\Users\user\AppData\Local\Temp\.rdmd\rdmd-moduleA.d-D3D7676836384146D1D9D907CF20EC26\objs\moduleA.exe.obj(moduleA.exe)
 Error 42: Symbol Undefined _D4test7moduleC5funcCFZv
--- errorlevel 1

Problem disappear, then i move import in test.moduleB to global level:

module test.moduleB;

import test.moduleC: funcC;  //this works

public void funcB () {
  //import test.moduleC: funcC;  //linker error
  funcC();

  return;
}

User golovanov_alexey responded (2016-Jan-16 09:34:43):

RDMD in both cases produces same rdmd.deps file in corresponding work dir. And those rdmd.deps not contains any mention of moduleC.

Command dmd -deps=moduleA.deps moduleA.d produces moduleA.deps file, which not contains any mention of moduleC too.

Is this DMD bug instead of RDMD ?

User golovanov_alexey responded (2016-Jan-16 16:57:47):

It seems this is old DMD bug "https://issues.dlang.org/show_bug.cgi?id=7016 - local import does not create -deps dependency"

User golovanov_alexey responded (2017-May-20 10:36:09):

No. Issue 7016 fixed, but this 15533 sill exists.

DMD32 D Compiler v2.075.0-master-f546675. Reduced test case.

C:\dmd2\windows\bin\rdmd.exe moduleA.d
//no errors, moduleA.exe created


C:\dmd2\windows\bin\rdmd.exe -g moduleA.d
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\Users\gav\AppData\Local\Temp\.rdmd\rdmd-moduleA.d-8C1729D9769E4E70D93C65D738058ED2\objs\moduleA.exe.obj(moduleA.exe)

 Error 42: Symbol Undefined _D4test7moduleC5funcCFZv
Error: linker exited with status 1

Reproduced locally (OSX), the code works with dmd -i but not with rdmd.