X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VagJHkn44FNFNmor8YeXSRTdOaOVv7TyQJJ4kar378VOBPf4YQHB1yEAjy1tDTWIf8gt72aEw/sbH23hBRGZBgC2O3urEq6qFcIbfSnwVmbHxWwFjneyOpnAjMBO/JZV50Dwx+lG9INxnFKtDBrUCpvD4cKHAQLyugUgBRFwJS9qhydsyLxni7DzlYDWrK1bIqPnokirGOYQHtLyPsxs8wuJecT2DwEjJniozj3wvXchPxPC5dctj+BdHIzTBKqkMj6ppApdYcrWW95HBsWYuRtEWCDhNQhdotkLWNBS58qbYWAR8DJXFu4GoEt40gECSAaV6fBPiMvMK8Io/RoPMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4MmZlNuvFd2JZovpSEeZrXLgK+7G8l6gVsD4OFJw4so=; b=Lc7l+tV9U0nSF+aXhFxO7hifk1+JVMUzSN+yJI1IwlIhrCKT0NuLLmHOUtXXQ/WbGbriULhv58JRpL3QixriZfAuX0jGN6MTCiyLUAamGnemxV1GGbvLg9OdrY3ejCLGX+Qbq9af8bq2En9QCckfK3TMoxaSuDTp7KfrPzg6awNFmmjc74rck0qFUGtTWkkpoxhAdAUfV26Vzc1y4JVePJCRFWWTpRp6YNfpLctBgNgLX54Z0uE+D0rs6iEN4PMTjZ28tqGpeE7Tte331qPSR+foMRqkm6R4UTVvmUHDGtn2KcyAU5iH4R9Kq3AeaMPJOXKSy/X2yl8cSn3decbm9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4MmZlNuvFd2JZovpSEeZrXLgK+7G8l6gVsD4OFJw4so=; b=RUziC+9mZewO0GeTgKhuZat9ImbFx+SOrZygNTMD31bZAtvAjFonxArCyTIMh2gXg+ClI179PegBtgVcaPQTcgXkvPUAr2rIL3umXvARqUVuHhQK7K9iTTI43Dz6X56iOyRTxOExdj7fhYKAj13lZ+CUEkIRPsu3ZoE69oOulNNFgVo+B+/6FQvQuBnNfMACMcseBxtKvcZuqIPYDIIYoyWXTDjeHOpk+dTh3NFWIOXE8xkHRgQ8H9mSJf5TU61Fo04BFpgs3EaJD94kF3T3FGCDNzFGkM2eLfEZY5BXaGx6AMsXItKSjLe/UxZSwdeFB2nixXk/Pml9F/ZoAhdYVA== From: "Jay K (jayk123 AT hotmail DOT com) [via djgpp AT delorie DOT com]" To: "djgpp AT delorie DOT com" Subject: Re: command line length problems? Thread-Topic: command line length problems? Thread-Index: AQHYEqgO378iML9TM0+Fyd/vmysVYA== Date: Wed, 26 Jan 2022 11:30:01 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: suggested_attachment_session_id: cbf04818-e028-e11d-047a-b4167b893180 x-tmn: [sdUgSjWc6ryrDWlQo1bVvzZC5J7LjGhtmunLfI4OsGK+Tot2n3NZMICDiFXIiQ/C] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 84c185b3-072d-492f-25c6-08d9e0bf3100 x-ms-traffictypediagnostic: BY5PR14MB3397:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OtQweI1aP9DTy8YkT420oQvgQrWIYdRgCQ5CLCY+UJcHKe8j2XgUHJGvXaEnkHwmFiPn6L+mAagScTbZQ4/xTap6+PgUufpDZ6MezpB0PI3iUzETqgHp0662RiZ11f6MKSMx8Jmp+LZERb1Wmb1lMg8Dw2oX9BuXNC60lj5lWTYm1Xqms8h6yWHWSfQN/LHRiK1zNjAl97Ef0nyNREe1jWeXtBqRdAOfwH97QUY5+0+gHXDiMddkMM3cMMUuRBlVKQXZtdIm38IFIa4F7QeH0GNIxwFksBEsOSnI6UZc1qqAHSgypn8wXaCIww9YcdXmeIHCZtZ4WE2sm0Z5IPoDGWw9CvFn6GRuA2oJaJJhKc+2+9HGzZYPW5QUubgs1ArRyZ6UgZxtSEdGaVDdba0NwoKsgvM96nYnmheS2oshCmAEf0yYyyUM51lnEZSeN2xhtyfo49fP/7wFfrvZ/UQInLj6hpMPTwk3Gg8M2zQZdkiJtgndacthDrmUsykDmdri4E+sOlouaxF1QYA0uiIg6q85tXooF7CqgzL8hRFSRNN3Ex0mvSXoS3xCGq2OXYfEeMofwQ2mhbKRIECsrO7+aVPTSyLEklmrKEgHLQLaOx2jXNR9ZW/2/Kkwq71sCnfCed3uirC4DdHGWNtLQR8BY5XoqwwZ9PkHGOJTPwvIYcU= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?LFuc7GThtg7OR7WtYyJkgJiKnE5WuQy8UgZ+pe7Uwe+bmA8RnP7+vbmIfd?= =?iso-8859-1?Q?8cxpeVOEjYQXxKV+Tc7oZUAAG7tH+EckBx9QHs8o+/BlTSKKNjjfKugjZG?= =?iso-8859-1?Q?pwc15r4aT6XcFwZgZv5dtI/IiFgqJapLkH5Sl80SpDsG5DP1hVCGfHVFh6?= =?iso-8859-1?Q?uORVtrKRokXT6+31XieswM1Sjy5+XSs4BgXFUDuoUZndvb18niTT46+WdN?= =?iso-8859-1?Q?Tklx1Kn78VAZhqdrE7oLOGR1ifjEnld2eDc8M9yDIimzXtT3fWEvgha1xo?= =?iso-8859-1?Q?3DzsIvUavgRZo6LQT6chogiAJUEiT7gzcwilCE4uESsNF3szUbWzIXEzDT?= =?iso-8859-1?Q?Ak8SWwH7+qKlkPN6KqJHd0OugIICGIWz9YnbP9883A9cxtYrbo62/yHDX3?= =?iso-8859-1?Q?OXDWYA/peNxEN32WASWSDV+fnqIJ5vNAuCkTDjOAgACmIdXmyQRET9DP+a?= =?iso-8859-1?Q?RZi9vAQLyElc36PwxgoLONeaZIjPurdh1+5NVbq/zOkCIEvEksV4dA7VKQ?= =?iso-8859-1?Q?jfK6sD0PgzLw4Y2AJYqBV6h1Tb/emrs+gUqlLk/JtQvjbEMXfq4zW+LalS?= =?iso-8859-1?Q?6GVRriaE/JHjo8VyDUuc2Ji0O/QiyWnJCmpnT6ouERmwlN8vyEKb5bmRRD?= =?iso-8859-1?Q?cxVqfA3cJbi1aTuIAU2RIN5fpcG2gzhQbgkOblEJCZkJrNDD7I99KYQSyx?= =?iso-8859-1?Q?pWkkbH+zw9nFkJ/R7oRdYMfQ2HceizuA65ZMkUnGxE0xV+LCpd9ASQUJPJ?= =?iso-8859-1?Q?VUaOsNV98b80aZFKm3zHTaSyJhhWmn8k021vvEg8isL+UM1yhVSJKGLYss?= =?iso-8859-1?Q?MAantLTZLWJ8DrfaD69dXfzAjtwQ6SpBphwFEaiVx0Ve5YxPIoS74sNRcP?= =?iso-8859-1?Q?T/v2T7434YfDIJ3yyogxI5tfinSoPKHZPDktV9iGVXgbFzlR3as7M8NJDN?= =?iso-8859-1?Q?Sn7DQfDmL68ieO+b4oVg2+C1XjdXot9DbzrUnBFu9SI2WFkwG12Awf2YMK?= =?iso-8859-1?Q?GNujNTeK3HDrJHPMDZ1F9PmCEkzUpsvU62PlxN?= Content-Type: multipart/alternative; boundary="_000_MWHPR1401MB1951A1E9DA9688FF49E522C1E6209MWHPR1401MB1951_" MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-cd57b.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR1401MB1951.namprd14.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 84c185b3-072d-492f-25c6-08d9e0bf3100 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jan 2022 11:30:01.4323 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR14MB3397 --_000_MWHPR1401MB1951A1E9DA9688FF49E522C1E6209MWHPR1401MB1951_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Well I am having better results now under dosbox-x, though it is much slowe= r. Under 32bit Windows 10, trivial use of system() like with just a short comm= and name and no parameters, fails. From the source I can see, it is complicated. There are flags, etc. There is CMDLINE for up to 1k command lines. And newer gcc runs out of memory on small programs. So it could be any number of things, and unfortunately gdb largely fails on= the 32bit Windows 10. C:\dos>type exec.cpp #include #include #include using namespace std; int main(int argc, char** argv) { int i; string e =3D ".\\ech.exe"; for (i =3D 1; i < argc; ++i) { e +=3D " "; e +=3D argv[i]; } for (i =3D 1; i < argc; ++i)//again to make it longer { e +=3D " "; e +=3D argv[i]; } printf("%s\n"); //it does get here system(e.c_str()); // fails in here } C:\dos>type cc.bat hacky I know sorry c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap %1.cpp -o %1.s as %1.s -o %1.o ld c:/dos/lib/crt0.o %1.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:/dos/lib -lgcc -l= c -lstdcxx -lgcc -lc -o %1.exe C:\dos>go32-v2 go32/v2 version 2.0 built Oct 18 2015 09:41:08 Usage: go32 coff-image [args] Rename this to go32.exe only if you need a go32 that can run v2 binaries as well as v1 binaries (old makefiles). Put ahead of the old go32 in your PA= TH but do not delete your old go32 - leave it in the PATH after this one. Set GO32_V2_DEBUG=3Dy in the environment to get verbose output. DPMI memory available: 1103989 Kb DPMI swap space available: 0 Kb C:\dos>cc.bat ech C:\dos>c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap ech.cpp -= o ech.s C:\dos>as ech.s -o ech.o C:\dos>ld c:/dos/lib/crt0.o ech.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:/dos/lib = -lgcc -lc -lstdcxx -lgcc -lc -o ech.exe C:\dos>cc.bat exec C:\dos>c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap exec.cpp = -o exec.s C:\dos>as exec.s -o exec.o C:\dos>ld c:/dos/lib/crt0.o exec.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:/dos/lib= -lgcc -lc -lstdcxx -lgcc -lc -o exec.exe C:\dos>.\ech.exe a b c d c:/dos/ech.exe a b c d C:\dos>file ech.exe ech.exe: DOS-executable compiled w/DJGPP (stub v2.05) C:\dos>file exec.exe exec.exe: DOS-executable compiled w/DJGPP (stub v2.05) C:\dos>.\exec.exe a a Exiting due to signal SIGSEGV Stack Fault at eip=3D00000a11 eax=3D00010001 ebx=3D00020080 ecx=3D0000d000 edx=3D000007bf esi=3D00002b2b = edi=3D00002b1b ebp=3D000c773a esp=3D000c773a program=3DC:\DOS\EXEC.EXE cs: sel=3D00cf base=3D000d3a70 limit=3D00000db0 ds: sel=3D00b7 base=3D000cc180 limit=3D0000ffff es: sel=3D0040 invalid fs: sel=3D0000 gs: sel=3D0000 ss: sel=3D00b7 base=3D000cc180 limit=3D0000ffff App stack: [000c7ef0..00047ef0] Exceptn stack: [00047e1c..00045edc] C:\dos>gdb ech.exe GNU gdb (GDB) 8.0.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=3Di786-pc-msdosdjgpp --target=3Ddjgpp". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ech.exe...done. (gdb) break main Breakpoint 1 at 0x16f1: file ech.cpp, line 5. (gdb) r --------------------------- 16 bit MS-DOS Subsystem --------------------------- C:\Windows\system32\cmd.exe - gdb ech.exe NTVDM has encountered a System Error NTVDM has encountered a System Error 4001h Choose 'Close' to terminate the = application. --------------------------- Close Ignore --------------------------- but gdb works better under dosbox-x. Funny/sad that 32bit Windows 10 is seemingly not the best MS-DOS here. - Jay ________________________________ From: Jay K Sent: Wednesday, January 26, 2022 9:53 AM To: djgpp AT delorie DOT com Subject: command line lenght problems? Hi folks. I am trying to port my program to MS-DOS. For fun, granted. I figured DJGPP would help. Esp. because it seems to have a useful "sigalarm" functionality, I might use to implement preemptive threads. I have a prototype that suggests that will work: https://github.com/modula3/cm3/blob/3be819ed8e2fa60885aff0cb6278934a17b307= 02/m3-libs/m3core/src/thread/POSIX/test_dos_threads.cpp The rest of the Posix support helps also. I'm not sure about network/sockets, maybe give up. I have experimented with a few "DOS"s. FreeDOS, DosBos-X, 32bit Windows 10 VM. They all have advantages and disadvantages. Granted I could spend more time configuring each and none is "really" MS-DO= S. My program is a compiler, that produces .cpp files and would run g++ or gxx= , etc. (I might experiment with e.g. OpenWatcom, might, like if it can link the = djpp libraries.) I am seeing, I guess, command line length limitations. gcc and collect2 crash, but if I run them manually with shorter equivalent-= enough commands, they work. Advise? I tried trimming environment. That didn't help. I tried running bash, thinking within there, maybe Djgpp would use its technique to transfer command lines otherwise, but bash won't start. bash: --------------------------- 16 bit MS-DOS Subsystem --------------------------- Administrator: C:\Windows\system32\cmd.exe NTVDM has encountered a System Error NTVDM has encountered a System Error 4001h Choose 'Close' to terminate the = application. --------------------------- Close Ignore --------------------------- C:\dos>type 1.c #include int main() { printf("hello\n"); } C:\dos>gcc -v -c 1.c Using built-in specs. COLLECT_GCC=3Dc:/dos/bin/gcc.exe Target: djgpp Configured with: /gcc-9.30/configure djgpp --prefix=3D/dev/env/DJDIR --disa= ble-werror --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada --with-gcc-m= ajor-version-only --enable-libquadmath-support --enable-lto --disable-libst= dcxx-pch --enable-libstdcxx-filesystem-ts Thread model: single gcc version 9.3.0 (GCC) COLLECT_GCC_OPTIONS=3D'-v' '-c' '-mtune=3Dpentium' '-march=3Dpentium' c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -quiet -v -iprefix c:/dos/bin/..= /lib/gcc/djgpp/9/ -remap 1.c -quiet -dumpbase 1.c -mtune=3Dpentium -march= =3Dpentium -auxbase 1 -version -o c:/dos/tmp/cczF3Ew0.s Exiting due to signal SIGSEGV Stack Fault at eip=3D00000a11 eax=3D00010001 ebx=3D01ad0080 ecx=3D01549400 edx=3D004207bf esi=3D00001223 = edi=3D00001213 ebp=3D0042773a esp=3D0042773a program=3DC:\DOS\BIN\GCC.EXE cs: sel=3D00cf base=3D000d3a50 limit=3D00000db0 ds: sel=3D00b7 base=3D000cc160 limit=3D0000ffff es: sel=3D0040 invalid fs: sel=3D0000 gs: sel=3D0000 ss: sel=3D00b7 base=3D000cc160 limit=3D0000ffff App stack: [00423b78..00223b7c] Exceptn stack: [00223ac8..00221b88] C:\dos> c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -quiet -v -iprefix c:/dos= /bin/../lib/gcc/djgpp/9/ -remap 1.c -quiet -dumpbase 1.c -mtune=3Dpentium -= march=3Dpentium -auxbase 1 -version -o c:/dos/tmp/cczF3Ew0.s The system cannot execute the specified program. c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -iprefix c:/dos/bin/../lib/gcc/dj= gpp/9/ -remap 1.c -quiet -dumpbase 1.c -o 1.s =3D> success as 1.s =3D> success C:\dos>gcc 1.o -v ... 208 characters: c:/dos/bin/../libexec/gcc/djgpp/9/collect2.exe c:/dos/lib/crt0.o -Lc:/dos/b= in/../lib/gcc/djgpp/9 -Lc:/dos/bin/../lib/gcc -Lc:/dos/lib -Lc:/dos/bin/../= lib/gcc/djgpp/9/../../.. -Lc:/dos/lib 1.o -lgcc -lc -lgcc Exiting due to signal SIGSEGV Stack Fault at eip=3D00000a11 eax=3D00010001 ebx=3D001c0080 ecx=3D001804 90 characters: ld.exe c:/dos/lib/crt0.o 1.o -lgcc -lc -Lc:/dos/lib/gcc/djgpp/9 -Lc:/dos/li= b -o a.exe =3D> success .\a.exe =3D> success Suggestions? I mean, worst case, I will run: C:\dos>gcc --print-prog-name ld c:/dos/bin/ld.exe C:\dos>gcc --print-prog-name cc1 c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe and run things more manually "like" that, with response files. I had to reinvent the compiler driver though, it hides things so well. I suppose I could run gcc directly with -v, capture the command lines, change them to use response files and rerun them "verbatim", thereby preserving the compiler driver. Can/should the gcc driver handle this more automatically itself? Thank you, - Jay --_000_MWHPR1401MB1951A1E9DA9688FF49E522C1E6209MWHPR1401MB1951_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Well I am having better results now under dosbox-x, though it is much slowe= r.
Under 32bit Windows 10, trivial use of system() like with just a short comm= and name and no parameters, fails.
From the source I can see, it is complicated.
There are flags, etc. There is CMDLINE for up to 1k command lines.
And newer gcc runs out of memory on small programs.
So it could be any number of things, and unfortunately gdb largely fails on= the 32bit Windows 10.

C:\dos>type exec.cpp
#include <stdio.h>
#include <string>
#include <stdlib.h>
using namespace std;

int main(int argc, char** argv)
{
int i;
string e =3D ".\\ech.exe";
for (i =3D 1; i < argc; ++i)
{
 e +=3D " ";
 e +=3D argv[i];
}
for (i =3D 1; i < argc; ++i)//again to make it longer
{
 e +=3D " ";
 e +=3D argv[i];
}
printf("%s\n"); //it does get here 
system(e.c_str()); // fails in here
}

C:\dos>type cc.bat     hacky I know sorry
 
c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap %1.cpp -o %= 1.s
as %1.s -o %1.o
ld c:/dos/lib/crt0.o %1.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:/dos/lib -lg= cc -lc -lstdcxx -lgcc -lc -o %1.exe

C:\dos>go32-v2
go32/v2 version 2.0 built Oct 18 2015 09:41:08
Usage: go32 coff-image [args]
Rename this to go32.exe only if you need a go32 that can run v2 binari= es as
 well as v1 binaries (old makefiles).  Put ahead of the old = go32 in your PATH
 but do not delete your old go32 - leave it in the PATH after thi= s one.
Set GO32_V2_DEBUG=3Dy in the environment to get verbose output.

DPMI memory available: 1103989 Kb
DPMI swap space available: 0 Kb

C:\dos>cc.bat ech

C:\dos>c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap e= ch.cpp -o ech.s

C:\dos>as ech.s -o ech.o

C:\dos>ld c:/dos/lib/crt0.o ech.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:/= dos/lib -lgcc -lc -lstdcxx -lgcc -lc -o ech.exe

C:\dos>cc.bat exec

C:\dos>c:/dos/libexec/gcc/djgpp/4.94/cc1plus.exe -g -quiet -remap e= xec.cpp -o exec.s

C:\dos>as exec.s -o exec.o

C:\dos>ld c:/dos/lib/crt0.o exec.o -LC:/dos/lib/gcc/djgpp/4.94 -Lc:= /dos/lib -lgcc -lc -lstdcxx -lgcc -lc -o exec.exe

C:\dos>.\ech.exe a b c d
c:/dos/ech.exe
a
b
c
d

C:\dos>file ech.exe
ech.exe: DOS-executable compiled w/DJGPP (stub v2.05)

C:\dos>file exec.exe
exec.exe: DOS-executable compiled w/DJGPP (stub v2.05)

C:\dos>.\exec.exe a
a
Exiting due to signal SIGSEGV
Stack Fault at eip=3D00000a11
eax=3D00010001 ebx=3D00020080 ecx=3D0000d000 edx=3D000007bf esi=3D0000= 2b2b edi=3D00002b1b
ebp=3D000c773a esp=3D000c773a program=3DC:\DOS\EXEC.EXE
cs: sel=3D00cf  base=3D000d3a70  limit=3D00000db0
ds: sel=3D00b7  base=3D000cc180  limit=3D0000ffff
es: sel=3D0040  invalid
fs: sel=3D0000
gs: sel=3D0000
ss: sel=3D00b7  base=3D000cc180  limit=3D0000ffff
App stack: [000c7ef0..00047ef0]  Exceptn stack: [00047e1c..00045e= dc]


C:\dos>gdb ech.exe
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses= /gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "= ;show copying"
and "show warranty" for details.
This GDB was configured as "--host=3Di786-pc-msdosdjgpp --target= =3Ddjgpp".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "= word"...
Reading symbols from ech.exe...done.
(gdb) break main
Breakpoint 1 at 0x16f1: file ech.cpp, line 5.
(gdb) r

---------------------------
16 bit MS-DOS Subsystem
---------------------------
C:\Windows\system32\cmd.exe - gdb  ech.exe
NTVDM has encountered a System Error
NTVDM has encountered a System Error 4001h Choose 'Close' to terminate= the application.
---------------------------
Close   Ignore  
---------------------------

but gdb works better under dosbox-x.

Funny/sad that 32bit Windows 10 is seemingly not the best MS-DOS here.

 - Jay


From: Jay K
Sent: Wednesday, January 26, 2022 9:53 AM
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Subject: command line lenght problems?
 
Hi folks.

I am trying to port my program to MS-DOS. For fun, granted.
I figured DJGPP would help.
Esp. because it seems to have a useful "sigalarm" functional= ity,
I might use to implement preemptive threads.
I have a prototype that suggests that will work:
 https://github.com/modula3/cm3/blob/3be819ed8e2fa60885aff0cb6278= 934a17b30702/m3-libs/m3core/src/thread/POSIX/test_dos_threads.cpp

The rest of the Posix support helps also.
 I'm not sure about network/sockets, maybe give up.

I have experimented with a few "DOS"s.
 FreeDOS, DosBos-X, 32bit Windows 10 VM.

They all have advantages and disadvantages.

Granted I could spend more time configuring each and none is "rea= lly" MS-DOS.

My program is a compiler, that produces .cpp files and would run g++ o= r gxx, etc.
  (I might experiment with e.g. OpenWatcom, might, like if it can= link the djpp libraries.)

I am seeing, I guess, command line length limitations.

gcc and collect2 crash, but if I run them manually with shorter equiva= lent-enough commands, they work.

Advise?

I tried trimming environment. That didn't help.
I tried running bash, thinking within there, maybe Djgpp would use
its technique to transfer command lines otherwise, but bash won't star= t.

bash:
---------------------------
16 bit MS-DOS Subsystem
---------------------------
Administrator: C:\Windows\system32\cmd.exe
NTVDM has encountered a System Error
NTVDM has encountered a System Error 4001h Choose 'Close' to terminate= the application.
---------------------------
Close   Ignore  
---------------------------


C:\dos>type 1.c
#include <stdio.h>
int main()
{
printf("hello\n");
}

C:\dos>gcc -v -c 1.c
Using built-in specs.
COLLECT_GCC=3Dc:/dos/bin/gcc.exe
Target: djgpp
Configured with: /gcc-9.30/configure djgpp --prefix=3D/dev/env/DJDIR -= -disable-werror --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada --with-= gcc-major-version-only --enable-libquadmath-support --enable-lto --disable-= libstdcxx-pch --enable-libstdcxx-filesystem-ts
Thread model: single
gcc version 9.3.0 (GCC)
COLLECT_GCC_OPTIONS=3D'-v' '-c' '-mtune=3Dpentium' '-march=3Dpentium'<= /div>
 c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -quiet -v -iprefix c:/= dos/bin/../lib/gcc/djgpp/9/ -remap 1.c -quiet -dumpbase 1.c -mtune=3Dpentiu= m -march=3Dpentium -auxbase 1 -version -o c:/dos/tmp/cczF3Ew0.s
Exiting due to signal SIGSEGV
Stack Fault at eip=3D00000a11
eax=3D00010001 ebx=3D01ad0080 ecx=3D01549400 edx=3D004207bf esi=3D0000= 1223 edi=3D00001213
ebp=3D0042773a esp=3D0042773a program=3DC:\DOS\BIN\GCC.EXE
cs: sel=3D00cf  base=3D000d3a50  limit=3D00000db0
ds: sel=3D00b7  base=3D000cc160  limit=3D0000ffff
es: sel=3D0040  invalid
fs: sel=3D0000
gs: sel=3D0000
ss: sel=3D00b7  base=3D000cc160  limit=3D0000ffff
App stack: [00423b78..00223b7c]  Exceptn stack: [00223ac8..00221b= 88]



C:\dos> c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -quiet -v -iprefi= x c:/dos/bin/../lib/gcc/djgpp/9/ -remap 1.c -quiet -dumpbase 1.c -mtune=3Dp= entium -march=3Dpentium -auxbase 1 -version -o c:/dos/tmp/cczF3Ew0.s
The system cannot execute the specified program.


c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe -iprefix c:/dos/bin/../lib/g= cc/djgpp/9/ -remap 1.c -quiet -dumpbase 1.c -o 1.s

=3D> success

as 1.s

 =3D> success

C:\dos>gcc 1.o -v
...

208 characters:
c:/dos/bin/../libexec/gcc/djgpp/9/collect2.exe c:/dos/lib/crt0.o -Lc:/= dos/bin/../lib/gcc/djgpp/9 -Lc:/dos/bin/../lib/gcc -Lc:/dos/lib -Lc:/dos/bi= n/../lib/gcc/djgpp/9/../../.. -Lc:/dos/lib 1.o -lgcc -lc -lgcc

Exiting due to signal SIGSEGV
Stack Fault at eip=3D00000a11
eax=3D00010001 ebx=3D001c0080 ecx=3D001804

90 characters:
ld.exe c:/dos/lib/crt0.o 1.o -lgcc -lc -Lc:/dos/lib/gcc/djgpp/9 -Lc:/d= os/lib -o a.exe

 =3D> success

.\a.exe

=3D> success


Suggestions?
I mean, worst case, I will run:

C:\dos>gcc --print-prog-name ld
c:/dos/bin/ld.exe

C:\dos>gcc --print-prog-name cc1
c:/dos/bin/../libexec/gcc/djgpp/9/cc1.exe

and run things more manually "like" that, with response file= s.

I had to reinvent the compiler driver though, it hides things so well.=
I suppose I could run gcc directly with -v, capture the command lines,=
change them to use response files and rerun them "verbatim",= thereby
preserving the compiler driver.

Can/should the gcc driver handle this more automatically itself?

Thank you,
 - Jay
--_000_MWHPR1401MB1951A1E9DA9688FF49E522C1E6209MWHPR1401MB1951_--