Bug 1327 – Long environment variable value causes link failure.
Status
RESOLVED
Resolution
MOVED
Severity
critical
Priority
P1
Component
tools
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-07-09T18:30:06Z
Last change time
2020-04-09T03:59:19Z
Keywords
link-failure, Optlink
Assigned to
No Owner
Creator
Bruce Adams
Comments
Comment #0 by tortoise_74 — 2007-07-09T18:30:06Z
Hi
I had some problems getting DMD to play nicely with cygwin. It turns out the problem was down to a long environment variable value. As a newcomer to D I was very confused. It was not at all obvious what was happening.
Regards,
Bruce.
F:\projects\Agenda>c:\cygwin\bin\make dtest2
dmc hello.d -o hello
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
hello.d:
hello.d:
link hello+hello,,,user32+kernel32/noi;
F:\projects\Agenda>set GCCINCDIR="C:\cygwin\usr\include;C:\cygwin\usr\include\sy
s;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cyg
win\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygw
in\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-
cygwin\bits;C:\cygwin\lib\gcc-lib\i686-pc-cygwin\3.4.4\include;C:\cygwin\usr\inc
lude;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin\usr\local\
i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys;C:\cygwin\
usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;C:\cygwin\u
sr\include\c++\3.4.4\i686-pc-cygwin\bits;C:\cygwin\lib\gcc\i686-pc-cygwin\C:\cyg
win\usr\include;C:\cygwin\usr\include\sys;C:\cygwin\usr\include\w32api;C:\cygwin
\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\local\i686-pc-cygwin\include\sys
;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin;
C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits;C:\cygwin\lib\gcc-lib\i686-p
c-cygwin\3.4.4\include;C:\cygwin\usr\include;C:\cygwin\usr\include\sys;C:\cygwin
\usr\include\w32api;C:\cygwin\usr\local\i686-pc-cygwin\include;C:\cygwin\usr\loc
al\i686-pc-cygwin\include\sys;C:\cygwin\usr\include\c++\3.4.4;C:\cygwin\usr\incl
ude\c++\3.4.4\i686-pc-cygwin;C:\cygwin\usr\include\c++\3.4.4\i686-pc-cygwin\bits
\include;C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++;;C:\cygwin\lib\gcc\i
686-pc-cygwin\3.4.4\include\c++\i686-pc-cygwin;C:\cygwin\lib\gcc\i686-pc-cygwin\
3.4.4\include"
F:\projects\Agenda>c:\cygwin\bin\make dtest2
dmc hello.d -o hello
c:\dmd\bin\..\..\dm\bin\link.exe hello,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
phobos.lib
Warning 2: File Not Found phobos.lib
OPTLINK : Warning 23: No Stack
hello.obj(hello)
Error 42: Symbol Undefined _main
hello.obj(hello)
Error 42: Symbol Undefined __acrtused_con
OPTLINK : Warning 134: No Start Address
--- errorlevel 2
hello.d:
--- errorlevel 2
make: *** [dtest2] Error 2
Comment #1 by tortoise_74 — 2007-07-09T18:51:24Z
I can confirm this also happens on the latest version (v2.002)
Comment #2 by wbaxter — 2007-07-09T19:10:01Z
Ouch. That must have taken ages to figure out.
Actually it seems to be related to both the variable name and its value. For instance "XCCINCDIR" worked ok, and many values of GCCINCDIR are ok for me. But other variables caused the problem too, like "FOOINCDIR". I can't really determine a pattern.
In any event you should probably use 'dmd' to compile D code and not 'dmc' (which is a C++ compiler) ;-)
Comment #3 by matti.niemenmaa+dbugzilla — 2007-07-10T03:49:29Z
Keep the version at the oldest, not the newest, relevant value, please.
Comment #4 by dlang-bugzilla — 2014-10-02T13:34:22Z
OPTLINK doesn't see the LIB variable if the environment is too big. In my case it starts to misbehave if the environment is longer than about 8K, but I guess the exact size varies depending on where LIB is in the environment. This affects D2 as well.
Comment #5 by pro.mathias.lang — 2020-04-09T03:53:26Z