www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18729] New: dmd -run executes in different environment


          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: nobody puremagic.com
          Reporter: johnnymarler 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.
OPTLINK : Warning 9: Unknown Option : OUT
OPTLINK : Warning 9: Unknown Option : LIBPATH
OPTLINK : Warning 9: Unknown Option : LIBPATH
OPTLINK : Warning 9: Unknown Option : LIBPATH
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

Apr 04 2018