# Cygwin update for PGI 11.2 on Windows

In release 11.2, the version of Cygwin shipped with PGI Workstation/Server on Windows was upgraded to Cygwin 1.7.7-1. This is the current version of Cygwin as of February, 2011. In general, PGI users should not notice significant differences in Cygwin behavior. However, there have been some changes from the previous version of Cygwin. This thread is intended to address those issues.

For information about configuring and troubleshooting Cygwin, you can visit
the following websites:

Cygwin FAQ: http://cygwin.com/faq.html

Cygwin Users Guide: http://cygwin.com/cygwin-ug-net.html

Cygwin mailing lists and archives: http://cygwin.com/lists.html

The version of the ‘make’ utility shipped with Cygwin 1.7.7 is make-3.81. In the transition from make-3.80 to make-3.81, the Cygwin maintainers eliminated support for Windows-style pathnames (e.g. ‘C:’ instead of ‘/c’).

PGI decided that in order to maintain backward compatibility, so as not to break PGI users’ makefiles, we would continue to ship make-3.80 as the default version of ‘make’. make-3.81 is available in /bin and /usr/bin named make-381.exe.

The default Cygwin naming convention for paths that contain drive letters is to use the prefix “/cygdrive”. For example, the Windows pathname “C:\cygwin” would be represented by the Cygwin path “/cygdrive/c/cygwin”. In the previous version of Cygwin shipped with PGI software, “C:\cygwin” was represented without the “/cygdrive” prefix, as “/c/cygwin”.

In order to maintain backward compatibility, the PGI installation of Cygwin includes a modified /etc/fstab, which eliminates the “/cygdrive” prefix.

For users who prefer to use the “/cygdrive” prefix, this can be changed by a simple modification to /etc/fstab. Comments in the file explain how to do this.

In order to get expected file system ownership and permission behavior, it is a good idea to set up the /etc/passwd and /etc/group files for Cygwin installations. Of course, because this affects system security, it is important that this is done by authorized personnel according to local IT security policies and procedures.

Before making any changes to passwd or group files it is a good practice to make backup copies of them, in case of problems.

To set up passwd and group files for Domain users on a network running Active Directory you can use the following commands:

Repeat for any users in Active Directory that will use Cygwin on this system:

• mkpasswd -d | grep <> >> /etc/passwd
mkgroup -d >> /etc/group

To set up passwd and group files for local Windows user accounts you can use the following commands:

• mkpasswd -l >> /etc/passwd
mkgroup -l >> /etc/group

See the Cygwin documentation for details on setting up passwd and group files. Links to the documentation are in the first message in this thread. Also see the Cygwin man pages for mkpasswd and mkgroup for details on the specific commands.

On systems with only the default passwd and group files, we have seen problems with use of the ‘tar’ command by users who belong to the Windows “Administrators” group. In this case the ‘tar’ command attempts to chown the files to the uids/gids in the tar archive. This can result in errors like the following:

tar: z_arg.f90: Cannot change ownership to uid 536, gid 500: Invalid argument

This can be fixed using the --no-same-owner option on the ‘tar’ command, or by setting up the passwd and group files. See the posting in this thread entitled “passwd and group files” for information on how to do this.

The first time the Cygwin DLL encounters a Windows or DOS-style path, it will issue a warning. In general, you cannot count on Cygwin commands working with Windows or DOS-style paths (e.g. C:\foo or \foo\bar). Once you have seen this warning there isn’t much point in turning it off, since it should not occur again.

If you do decide to modify the CYGWIN environment variable as described below, be aware that the PGI Workstation shell setup also sets this environment variable. You should only append to \$CYGWIN, not overwrite it.

Here is the warning message:

cygwin warning:
MS_DOS style path detected: <<path01>>
Preferred POSIX equivalent is: <<path02>>
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames


Handling of end-of-line characters in the Bash shell has changed from the version of Cygwin shipped with pre-11.2 PGI releases. Here are some notes about Bash and line endings from the cygwin-announce email list. Note that this is Cygwin-generated documentation.

1. When using binary mounts, cygwin programs try to emulate Linux. Bash on Linux does not understand \r\n line endings, but interprets the \r literally, which leads to syntax errors or odd variable assignments. Therefore, you will get the same behavior on Cygwin binary mounts by default.

2. d2u is your friend. You can use it to convert any problematic script into binary line endings.

3. Cygwin text mounts automatically work with either line ending style, because the \r is stripped before bash reads the file. If you absolutely must use files with \r\n line endings, consider mounting the directory where those files live as a text mount. However, text mounts are not as well tested or supported on the cygwin mailing list, so you may encounter other problems with other cygwin tools in those directories.

4. This version of bash has a cygwin-specific set option, named “igncr”, to force bash to ignore \r, independently of cygwin’s mount style. As of bash-3.2.3-5, it controls regular scripts, command substitution, and sourced files. I hope to convince the upstream bash maintainer to accept this patch into a future bash release even on Linux, rather than keeping it a cygwin-specific patch, but only time will tell. There are several ways to activate this option:

4a. For a single affected script, add this line just after the she-bang:

(set -o igncr) 2>/dev/null && set -o igncr; # comment is needed


4b. For a single script, invoke bash explicitly with the option, as in

bash -o igncr ./myscript' rather than the simpler './myscript'


4c. To affect all scripts, export the environment variable BASH_ENV, pointing to a file that sets the shell option as desired. Bash will source this file on startup for every script.

4d. Added in the bash-3.2-2 release: export the environment variable SHELLOPTS with igncr included in it. It is read-only from within bash, but you can set it before invoking bash; once in bash, it auto-tracks the current state of ‘set -o igncr’. If xported, then all bash child processes inherit the same option settings; with the exception added in 3.2.9-11 that certain interactive options are not inherited in
non-interactive use.

4e. bash-4.1.9-1 dropped support for ‘shopt -s igncr’; it did not make sense to support the option through both set and shopt, and SHELLOPTS proved to be more powerful.

1. You can also experiment with the IFS variable for controlling how bash will treat \r during variable expansion.

2. There are varying levels of speed at which bash operates. The fastest is on a binary mount with igncr disabled (the default behavior). Next would be text mounts with igncr disabled and no \r in the underlying file. Next would be binary mounts with igncr enabled. And the slowest that bash will operate is on text mounts with igncr enabled.

The output of commands run in a bash back-tick expansion may contain CR/LF at the end of the line, rather than the single LF found in unix and the version of Cygwin shipped with pre-11.2 PGI releases. Programs that use the native Win32 API will need to recognize and strip these characters from their input. For example:

native-prog another-prog

Here native-prog will need to handle CR/LF as the EOL character(s).

See the previous item in this thread for a detailed explanation of controlling CR behavior in Bash.

As of 11.2, the following environment variables are no longer set in PGI environments that launch Cygwin bash (pgi.bat):

    set MAKE_MODE=unix
set MAN_CONF=C:\cygwin\usr\share\misc\man.conf
set GROFF_FONT_PATH=C:\cygwin\usr\share\groff\1.18.1\font
set GROFF_TMAC_PATH=C:\cygwin\usr\share\groff\1.18.1\tmac
set MAGIC=C:\cygwin\usr\share\file\magic
set TERMCAP=C:\cygwin\etc\termcap
set TERM=ansi
set VIM=C:/cygwin/usr/share/vim


In addition, two new variables are set starting with 11.2:

    set CYGWIN=tty
set MANPATH=/C/PROGRA~1/PGI/win32/11.2/man:/usr/share/man


[Note, the MANPATH value will change based on 32 v. 64 and release]