D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1327 - Long environment variable value causes link failure.
Summary: Long environment variable value causes link failure.
Status: RESOLVED MOVED
Alias: None
Product: D
Classification: Unclassified
Component: tools (show other issues)
Version: D2
Hardware: x86 Windows
: P1 critical
Assignee: No Owner
URL:
Keywords: link-failure, Optlink
: 12054 (view as issue list)
Depends on:
Blocks:
 
Reported: 2007-07-09 18:30 UTC by Bruce Adams
Modified: 2020-04-09 03:59 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bruce Adams 2007-07-09 18:30:06 UTC
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 Bruce Adams 2007-07-09 18:51:24 UTC
I can confirm this also happens on the latest version (v2.002)
Comment 2 Bill Baxter 2007-07-09 19:10:01 UTC
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 Matti Niemenmaa 2007-07-10 03:49:29 UTC
Keep the version at the oldest, not the newest, relevant value, please.
Comment 4 Vladimir Panteleev 2014-10-02 13:34:22 UTC
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 Mathias LANG 2020-04-09 03:53:26 UTC
Since it's an OPTLINK-specific issue, and OPTLINK is now open source, transferring it to https://github.com/DigitalMars/optlink/issues/25
Comment 6 Mathias LANG 2020-04-09 03:59:19 UTC
*** Issue 12054 has been marked as a duplicate of this issue. ***