Note: I'm filing this bug for partially for information purposes, not sure whether it is worth trying to fix. There is a workaround. There is also a possible solution example linked below.
Affected SDCC versions: possibly all versions back to commit 2546(?)
A couple users have reported a problem with SDCC calling the preprocessor on Windows when the sdcc binaries reside in a folder on non-C drives under a path that has spaces.
Apparent Issue
This appears to be a bug caused by a combination of:
Workaround
The workaround is to turn on 8.3 short path names for the desired drive
fsutil.exe 8dot3name query D:fsutil 8dot3name set D: 0fsutil.exe 8dot3name query D:D:\>fsutil file setshortname "D:\My stuff" "mystuf~1"Possible solution implementation
GBDK's compiler driver ( lcc) seems to have a possible solution using spawnvp() with a shim version for linux/macos. The original implementation was likely written ~20 years ago and had some improvements about 4 years ago for better quoting support. We haven't heard of any issues so far, but that is hard to say with certainty since cross platform path support can be complicated and users don't always report problems.
Example of issue
These are some summarized versions of the issue, I can paste full details if desired.
Failing:
...
sdcc: Calling preprocessor...
sdcc: sdcpp -nostdinc -Wall (snip)
**THIS LINE**
+ D:\My stuff\gbdk\bin\sdcpp.exe -nostdinc -Wall (snip)
sdcc: Generating code...
'D:\My' is not recognized as an internal or external command,
operable program or batch file.
Working:
...
sdcc: Calling preprocessor...
sdcc: sdcpp -nostdinc -Wall (snip)
**THIS LINE**
+ C:\MYSTUF~1\gbdk\bin\sdcpp.exe -nostdinc -Wall (snip)
sdcc: Generating code...
ignoring nonexistent directory "C:/My stuff/gbdk/bin/../include/sm83"
(snip)
Bugs: #3632
Bugs: #3810
Patches: #482
Wiki: SDCC 4.5.0 Release
Checking the SDCC source, it is written:
It seems that it was relevant more than 20 years ago, but now...
The command.com is a 16-bit program and it's not used on any NT-based Windows, only on Windows 95, 98 and ME.
And I've just tested cmd.exe on Windows 2000 and it already accepts the "program" "argument" form (see the attached build) so all the newer versions (in the last two decades) must work the same.
Then the solution could possibly be to completely drop the conversion to 8.3 and just quote the zeroth argument, as I wouldn't expect anybody running a new versions of SDCC on a machine/OS which depends on any command.com or on a cmd.exe from previous century.
Uff, checking the implementation more, it seems not only about the
cmd.exeper se, but about what_popenfrom the MS library in Windows is willing to accept, which is... (surprise!) ... more complicated.So, the form
""program 0" "argument 1" "argument 2""works with_popen.The 4.4.0 32-bit Windows binary already doesn't run on Windows 2000, this API is "from XP on" (attached)
Last edit: Janko Stamenović 2024-10-25
Now: Patch #482
https://sourceforge.net/p/sdcc/patches/482/
Please try [r15082] or later to see if this work for you now.
Related
Commit: [r15082]
Thanks!
Tested this out and it does appear to resolve the issue for path names with a space and 8.3 short name generation turned off. The recent build with the change does not error out under conditions where the old build does.
For this comparison:
-recent build is
1516014560