The libiconv/lib/genaliases.c should change genaliases.c to create canonical.sh as a binary file.
When I was trying to build libiconv as stated in README.windows "2) Native binaries, built using the MS Visual C/C++ tool chain.", I found that canonical.sh created by genaliases.c is a DOS text file (line-ending with 0D 0A) and this caused sed in cygwin failed to work.
As canonical.sh is intended to work in any UNIX-like systems, like cygwin, so does sed in cygwin too, cannonical.sh should be created as a UNIX line-ending script file.
However, if compiled with cygwin gcc, fprintf() to a text file (opened with "w", not "wb") a '\n' will write 0D 0A instead of 0A.
See the attached patch file.