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

          Issue ID: 18729
           Summary: dmd -run executes in different environment
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: johnnymar...@gmail.com

I ran into a problem where I was running a D program via dmd -run that itself
invoked DMD. The resulting program was invoking the compiler with -m64, but the
original dmd -run did not use -m64. This caused a problem because the first
invocation of the compiler set the LINKCMD environment variable to the OPTLINK
executable, which caused the second invocation to use the OPTLINK executable
but it treated it like the MSVC linker because it was running in 64-bit mode. 
You can reproduce this scenario on windows inside the dlang/tools repo by
running this:

dmd -run rdmd.d -m64 rdmd.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
OPTLINK : Warning 9: Unknown Option : OUT
OPTLINK : Warning 9: Unknown Option : LIBPATH
OPTLINK : Warning 9: Unknown Option : LIBPATH
OPTLINK : Warning 9: Unknown Option : LIBPATH
C:\Users\Jonathan\AppData\Local\Temp\.rdmd\rdmd-rdmd.d-C379EA2E17BAC309A238EECC3E638589\objs\rdmd.exe.obj
Offset 00000H Record Type 0064
 Error 138: Module or Dictionary corrupt
Error: linker exited with status 1

The solution here is to make sure that "dmd -run" maintain the original
environment during execution. 

PR: https://github.com/dlang/dmd/pull/8121

--

Reply via email to