CYGPATH environment variable should be supported for execution in Cygwin

Bug #1282943 reported by Kedar Sovani
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Won't Fix
Wishlist
Terry Guo

Bug Description

While the toolchain works excellently on Linux, the following problem is seen with Cygwin on Windows :

Cygwin uses paths as /cygdrive/c/windows/ whereas, Windows and the rest of the system interpret these paths as c:\windows

The 'cygpath' utility converts between these two paths. Some toolchains rely on the presence of the environment variable 'CYGPATH'. If this variable is defined, the utility pointed to by this variable is used to convert between paths from Cygwin to Windows.

It would be good to have this support in this toolchain so that Cygwin environment can be supported easily.

Revision history for this message
Terry Guo (terry.guo) wrote :

Would you please give an example to demo your usage model? Thanks.

Changed in gcc-arm-embedded:
assignee: nobody → Terry Guo (terry.guo)
Revision history for this message
Kedar Sovani (kedars) wrote :

For example in Cygwin:

Cygwin Paths:
$ ls /cygdrive/c/Users/kedars/Downloads/a.c
/cygdrive/c/Users/kedars/Downloads/a.c

Now the toolchain requires to convert this to a C:\ format. This is achieved using:
$ cygpath.exe -w /cygdrive/c/Users/kedars/Downloads/a.c
C:\Users\kedars\Downloads\a.c

So all inputs to the toolchain should be converted in this fashion.

Similarly, when the toolchain generates dependency files, it will use C:\ format. But the 'make' utility of Cygwin expects paths of the format /cygdrive/c format. This is achieved using:
$ cygpath.exe -u c:/Users/kedars/Downloads/a.c
/cygdrive/c/Users/kedars/Downloads/a.c

Here is the link for how this is done in CodeSourcery:
http://doc.ironwoodlabs.com/arm-arm-none-eabi/html/getting-started/sec-setting-up-environment.html#sec-cygwin

Details about the cygpath utility:
http://cygwin.com/cygwin-ug-net/using-utils.html#cygpath

Revision history for this message
Terry Guo (terry.guo) wrote :

Thanks for your example. It turns out that our tool chain doesn't support cygwin style path:

terguo01@sha-win-053 /cygdrive/d/toolchain/cases
$ export CYGPATH=d:/Cygwin/cygwin/bin/cygpath

terguo01@sha-win-053 /cygdrive/d/toolchain/cases
$ echo $CYGPATH
d:/Cygwin/cygwin/bin/cygpath

terguo01@sha-win-053 /cygdrive/d/toolchain/cases
$ ../gcc-arm-none-eabi-4_8-2013q4-20131204-win32/bin/arm-none-eabi-gcc -c /cygdrive/d/toolchain/cases/1267504-ice.c -S
arm-none-eabi-gcc.exe: error: /cygdrive/d/toolchain/cases/1267504-ice.c: No such file or directory
arm-none-eabi-gcc.exe: fatal error: no input files
compilation terminated.

terguo01@sha-win-053 /cygdrive/d/toolchain/cases
$ ls /cygdrive/d/toolchain/cases/1267504-ice.c
/cygdrive/d/toolchain/cases/1267504-ice.c

terguo01@sha-win-053 /cygdrive/d/toolchain/cases
$

This could be a useful feature to enable toolchain to handle cygwin style path. I will look into it.

Revision history for this message
Terry Guo (terry.guo) wrote :

Had a little study and found CS has a file named cygpath.c in their libiberty to handle such case. Judging from the header of this file, I guess they plan to open source it and contribute to libiberty. But this never happens, perhaps they forgot this thing.

Terry Guo (terry.guo)
Changed in gcc-arm-embedded:
importance: Undecided → Wishlist
Changed in gcc-arm-embedded:
status: New → Confirmed
Revision history for this message
Yixiao Li (liyixiao7) wrote :

Any progress on this feature?

I also encountered this problem when moving the development environment of one project from Linux to Cygwin recently.
I like the launchpad version arm compiler very much and hope this feature can be supported soon.

Revision history for this message
Terry Guo (terry.guo) wrote :

No progress so far but it is in my todo list.

description: updated
Revision history for this message
Terry Guo (terry.guo) wrote :

The CSL patch to support cygwin style path has a fatal flaw, thus wont' be adopted to this tool chain at the moment. I would like to suggest to use MINGW and MSYS instead of CYGWIN as described in this webpage http://www.jann.cc/2013/10/10/embedded_development_with_open_source_tools_on_windows.html.

Revision history for this message
Richard Lang (r-e-lang) wrote :

So, am I right in understanding that until this enhancement is implemented, trying to invoke this toolchain from Cygwin cmake/make just aint going to work?

Any feeling on when this might be supported Terry? I'm currently looking at shifting a company wide Windows based development environment that currently uses IAR toolchain for target build and Cygwin cmake & gcc for unit testing over to this GCC cross compiler toolchain, and with this outstanding issue looks like I might have to backtrack on Cygwin and shift to MinGW-w64 plus windows native make & cmake in order to have build tools that play nicely.

Revision history for this message
Richard Lang (r-e-lang) wrote :

For reference - as an alternative to cygwin, current version ( 2015-Q4) does seem to handle MSYS2 representations of Windows paths ("c:\foo\bar" -> "/c/foo/bar") OK. Am invoking the Windows native arm-none-eabi-gcc from MSYS cmake and GNU make successfully.

Revision history for this message
hasan (porosh2016) wrote :

Dear All,

I have same problem that means arm-none-eabi gcc does not support cygwin.

My error is arm-none-eabi-gcc: fatal error: no input files.

In this time I was using AC6 STM32 MCU GCC.
Can you help me ?

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

Hi Hasan,

You can try prepending 'cygpath -w' to the files you want to compile which will translate cygwin path to Windows path. Unfortunately we are already very busy and do not have time to work on support for cygwin paths.

Best regards,

Revision history for this message
Yves Chevallier (nowox) wrote :

I have the same issue so I tried to build the toolchain on Cygwin (which should be possible as it is possible for GCC). Unfortunately I got this error:

```
+++ uname
+++ sed y/LINUXDARWIN/linuxdarwin/
++ uname_string=CYGwin_nT-6.1
+++ uname -m
+++ sed y/XI/xi/
++ host_arch=x86_64
++ '[' xCYGwin_nT-6.1 == xlinux ']'
++ '[' xCYGwin_nT-6.1 == xdarwin ']'
++ error 'Unsupported build system : CYGwin_nT-6.1'
++ set +u
++ echo './install-sources.sh: error: Unsupported build system : CYGwin_nT-6.1'
./install-sources.sh: error: Unsupported build system : CYGwin_nT-6.1
++ exit 1
```

I patched `build_common.sh` to add this:

    if [ "x$uname_string" == "xlinux" ] || [ "x$uname_string" == "xCYGwin_nT-6.1" ]; then

But it still doesn't work, the build script failed at some point. It builds everything but arm-none-eabi-gcc :(

So I changed my strategy and wrote this Perl script:

```
#!/usr/bin/perl
#file: arm-none-eabi-gcc
#desc: Hijack the arguments sent to arm-none-eabi-gcc to fix absolute paths
my $cc = 'arm-none-eabi-gcc';
my $gcc = '"/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/5.4 2016q3/bin/arm-none-eabi-gcc.exe"';
my @newargs;

foreach (@ARGV) {
    if (m|^(.*?)(/cygdrive/[a-z]/[^ '"]+)(.*?)$|) {
        my $path = `cygpath -w '$2'`;
        chomp $path;
        my $arg = "$1'$path'$3";
        push @newargs, $arg;
    } else {
        push @newargs, $_
    }
}

unshift @newargs, $gcc;

exec(join ' ', @newargs);
```

It's ugly, but it works...

Joey Ye (jinyun-ye)
Changed in gcc-arm-embedded:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.