On 2024-12-13 08:13, Johannes Khoshnazar-Thoma via Cygwin wrote:
Hi list,

At the moment I am stuck building a cygwin gcc compiler that runs on
Linux and creates cygwin executables.

Here's what I did:

Downloaded and installed binutils:

git clone --depth 1 -b master https://sourceware.org/git/binutils-gdb.git 
binutils
cd binutils
./configure --prefix=/home/johannes/cygwin-build-gcc/sysroot/ --disable-shared --enable-static --with-sysroot=/home/johannes/cygwin-build-gcc/sysroot/ -- target=x86_64-pc-cygwin --disable-multilib --disable-nls --enable-lto --disable-gdb
make -j 10
make install

which went fine.

Now after trying to compile gcc it (later) complains about missing windows.h header.
So I downloaded and installed the MinGW-w64 package, configured and installed it
(also to this sysroot but in the x86_64-pc-cygwin directory:

git clone --depth 1 -b master https://git.code.sf.net/p/mingw-w64/mingw-w64 mingw-w64
cd mingw-w64
./configure --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 \
--prefix=/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin --without-crt
make install

(I also tried with --host=x86_64-pc-cygwin)

Question: As far as I understood it, installing the MinGW headers is a 
prerequisite
to building a x86_64-pc-cygwin cross compiler (because libgcc will need certain
windows headers). Is that correct?

Then I tried various gcc configure options:

git clone --depth 1 -b releases/gcc-14 https://gcc.gnu.org/git/gcc.git gcc
cd gcc
./contrib/download_prerequisites
../configure --target=x86_64-pc-cygwin --host=x86_64-pc-linux --disable-shared \
--enable-static --disable-multilib --prefix=/home/johannes/cygwin-build-gcc/ sysroot/ \
--enable-languages=c,c++ --disable-nls --enable-threads=posix \
--with-newlib=/home/johannes/cygwin-build-gcc/newlib-cygwin \
--with-cygwin=/home/johannes/cygwin-build-gcc/newlib-cygwin 
--with-system-libunwind
make -j 8

Building gcc (xgcc) works fine but when the stage1 compiler tries to compile
libgcc I get lots of errors complaining about certain types not found:

Compiler command line is:

/home/johannes/cygwin-build-gcc/gcc/build/./gcc/xgcc \
-B/home/johannes/cygwin-build-gcc/gcc/build/./gcc/ \
-B/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/bin/ \
-B/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/lib/ \
-isystem /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/include \
-isystem /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/sys-include   
 \
-g -O2 -O2 -I../../../libgcc/../winsup/w32api/include -I../../../libgcc/../ winsup/include \ -I../../../libgcc/../winsup/cygwin/include -g -O2 -DIN_GCC - DCROSS_DIRECTORY_STRUCTURE  \ -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes - Wmissing-prototypes \
-Wold-style-definition  -isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc \
-fno-stack-protector -Dinhibit_libc  -I. -I. -I../.././gcc -I../../../libgcc \
-I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include \
-I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS - DUSE_EMUTLS  \
-o unwind-seh.o -MT unwind-seh.o -MD -MP -MF unwind-seh.dep -fexceptions -c \
../../../libgcc/unwind-seh.c

First few error outputs are:

In file included from /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/ include/winnt.h:16,                  from /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/ include/minwindef.h:163,                  from /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/ include/windef.h:9,                  from /home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/ include/windows.h:69,
                  from ./unwind.h:34,
                  from ../../../libgcc/unwind-seh.c:29:
/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/include/ ctype.h:43:17:error: unknown type name 'wctype_t'
    43 |   _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
       |                 ^~~~~~~~
/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/include/ctype.h:123:24 error: unknown type name 'wint_t'
   123 |   int __cdecl iswalpha(wint_t _C);
       |                        ^~~~~~
/home/johannes/cygwin-build-gcc/sysroot/x86_64-pc-cygwin/include/ctype.h:124:24 error: unknown type name 'wint_t'
   124 |   int __cdecl iswupper(wint_t _C);
       |                        ^~~~~~

followed by many others.

Researching a bit showed that there is a _cygwin.h header that #defines _INTPTR_T_DEFINED
to prevent corecrt.h to typedef intptr_t. But in my case the cygwin headers are 
not
included.

I also tried to symlink winsup to the gcc root directory: same result plus
a non-existent header:

../../../libgcc/../winsup/cygwin/include/features.h:13:10: fatal error: sys/ features.h: No such file or directory
    13 | #include <sys/features.h>

Is there a web resource that explains how to create a cygwin cross compiler
for Linux? Or even better a shell script that does it? What should I do to
fix the intptr_t issue?

Read the instructions:

        https://x.cygwin.com/docs/cg/cross.html

Recipe for Fedora:

        https://cygwin.com/pipermail/cygwin-cvs/2020q3/014567.html

Fedora copr:

        https://copr.fedorainfracloud.org/coprs/yselkowitz/cygwin/

Posts:

        https://inbox.sourceware.org/cygwin/?q=s:cross

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                -- Antoine de Saint-Exupéry

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to