crossbuild cygwin-1.7.6-1 on linux x64

Alexandre Girao alexgirao@gmail.com
Mon Aug 23 18:29:00 GMT 2010


Hi,

	After a great struggle (and lots of googling around) i finally
compiled cygwin1.dll on
	linux and tested in a win32 environment, the process wasn't
straightforward but it worked.

	I've attached the original email body (for long lines format
protection) and all changes i've made
	(all trivial) as unified diff.

	What i want, is to know if i have done something *very* wrong in the
cygwin configuration
	and compilation, because the cygwin compilation raised a lot of
undefined references from
	cygserver, i had to compile cygserver separately and manually
(outside autotools) for the
	process to complete, below are the procedures i've followed.
	
	If this listing isn't the proper place to discuss this, please
forgive-me and point me the right
	direction.

	I also thank you all for the great work on cygwin.

procedures:


download required files

	mkdir -p ~/Downloads/cygwin-cross && cd ~/Downloads/cygwin-cross
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/binutils/binutils-2.20.51-2-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/gcc4/gcc4-4.3.4-3-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/cygwin/cygwin-1.7.6-1-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/cygwin/cygwin-1.7.6-1.tar.bz2

install cocom (shilka tool required by cygwin)

	# instructions at cocom/README.txt

prepare sources and auxiliary files

	mkdir -p ~/src && cd ~/src

	tar -xjf ~/Downloads/cygwin-cross/binutils-2.20.51-2-src.tar.bz2
	tar -xjf ~/Downloads/cygwin-cross/gcc4-4.3.4-3-src.tar.bz2
	tar -xjf gcc-4.3.4.tar.bz2

	tar -xjf ~/Downloads/cygwin-cross/cygwin-1.7.6-1-src.tar.bz2
	rm -fv src && ln -s cygwin-1.7.6-1 src

	cd ~/src/binutils-2.20.51-2
	git init && git add . && git commit -m 'initial commit' && git repack
-d && git prune

	cd ~/src/gcc-4.3.4
	git init && git add . && git commit -m 'initial commit'

	patch -p2 < ../gcc4-4.3.4-3.src.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3.src.patch'

	patch -p2 < ../gcc4-4.3.4-3.cygwin.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3.cygwin.patch'

	patch -p1 < ~/Downloads/cygwin-cross/gcc4-4.3.4-3-strsignal.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3-strsignal.patch'

	patch -p1 < ~/Downloads/cygwin-cross/gcc4-4.3.4-3-use-libstdc-wrappers.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3-use-libstdc-wrappers.patch'

	git repack -d && git prune

	cd ~/src/src
	git init && git add . && git commit -m 'initial commit'

	patch -p1 < ~/Downloads/cygwin-cross/cygwin-1.7.6-1-winsup-utils-mingw.patch
	git add . && git commit -m 'applied cygwin-1.7.6-1-winsup-utils-mingw.patch'

	git repack -d && git prune

	mkdir -p ~/src/cygwin-1.7.6-1-dist && tar -C
~/src/cygwin-1.7.6-1-dist -xjf
~/Downloads/cygwin-cross/cygwin-1.7.6-1.tar.bz2

################################################################################

setup (always execute this before going further)

	export _ZTARGET=i686-pc-cygwin
	export PATH=$PATH:~/cygwin-cross/bin:~/cygwin-cross/$_ZTARGET/bin

binutils

	mkdir -p ~/build/cygwin-cross/binutils && cd ~/build/cygwin-cross/binutils \
	&& ~/src/binutils-2.20.51-2/configure --target=$_ZTARGET
--prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross
--disable-nls 2>&1 | tee -a configure.log \
	&& make all 2>&1 | tee all.log \
	&& make install 2>&1 | tee install.log \

gcc4, gcc only

	&& mkdir -p ~/build/cygwin-cross/gcc4-gcc && cd ~/build/cygwin-cross/gcc4-gcc \
	&& ~/src/gcc-4.3.4/configure --target=$_ZTARGET
--prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross \
	  --enable-haifa --disable-bootstrap
--enable-version-specific-runtime-libs --enable-static --enable-shared
--enable-shared-libgcc \
	  --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2
--disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers \
	  --enable-threads=posix --with-arch=i686 --with-tune=generic
--with-newlib 2>&1 | tee -a configure.log \
	&& make CFLAGS='-DUSE_CYGWIN_LIBSTDCXX_WRAPPERS=0
-DHAVE_GAS_ALIGNED_COMM=1 -g -O2' all-gcc 2>&1 | tee all.log \
	&& make install-gcc 2>&1 | tee install.log \

cygwin's newlib

	&& mkdir -p ~/build/cygwin-cross/newlib && cd ~/build/cygwin-cross/newlib \
	&& ~/src/src/configure --target=$_ZTARGET --prefix=$HOME/cygwin-cross
--exec-prefix=$HOME/cygwin-cross 2>&1 | tee -a configure.log \
        && make configure-target-newlib 2>&1 | tee configure-target-newlib.log \
        && make -C ${_ZTARGET}/newlib 2>&1 | tee -a newlib.log \
        && make -C ${_ZTARGET}/newlib install 2>&1 | tee -a newlib-install.log \

gcc4, full

	&& mkdir -p ~/build/cygwin-cross/gcc4-all && cd ~/build/cygwin-cross/gcc4-all \
	&& ~/src/gcc-4.3.4/configure --target=$_ZTARGET
--prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross \
	  --enable-haifa --disable-bootstrap
--enable-version-specific-runtime-libs --enable-static --enable-shared
--enable-shared-libgcc \
	  --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2
--disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers \
	  --enable-threads=posix --with-arch=i686 --with-tune=generic
--with-newlib 2>&1 | tee -a configure.log \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib
~/cygwin-cross/$_ZTARGET/lib/libkernel32.a --def
~/src/src/winsup/w32api/lib/kernel32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib
~/cygwin-cross/$_ZTARGET/lib/libuser32.a --def
~/src/src/winsup/w32api/lib/user32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib
~/cygwin-cross/$_ZTARGET/lib/libadvapi32.a --def
~/src/src/winsup/w32api/lib/advapi32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib
~/cygwin-cross/$_ZTARGET/lib/libshell32.a --def
~/src/src/winsup/w32api/lib/shell32.def \
	&& (cd ~/cygwin-cross/${_ZTARGET} && tar -cjf
include-newlib-original.tar.bz2 include) \
	&& rsync -a --exclude '- CVS' ~/src/src/winsup/cygwin/include/
~/cygwin-cross/${_ZTARGET}/include/ \
	&& ln -s ~/src/cygwin-1.7.6-1-dist/usr/lib/libcygwin.a
~/cygwin-cross/${_ZTARGET}/lib/libcygwin.a \
	&& ln -s ~/src/cygwin-1.7.6-1-dist/usr/lib/crt0.o
~/cygwin-cross/${_ZTARGET}/lib/crt0.o \
	&& make CFLAGS='-DUSE_CYGWIN_LIBSTDCXX_WRAPPERS=0
-DHAVE_GAS_ALIGNED_COMM=1 -g -O2
-I$(HOME)/src/src/winsup/w32api/include' all 2>&1 | tee all.log \
	&& make install 2>&1 | tee install.log \
	&& echo 'main() {puts("hello world of real possibilities!");}' |
${_ZTARGET}-gcc -o "_test_${_ZTARGET}_pe32_output" -x c - && echo
'gcc4 can generate pe executables' \

cygwin

	&& mkdir -p ~/build/cygwin-cross/cygwin && cd ~/build/cygwin-cross/cygwin \
	&& ~/src/src/configure --target=$_ZTARGET 2>&1 | tee -a configure.log \
	&& make all 2>&1 | tee all.log \

	# generate cygwin0.dll manually

		&& pushd i686-pc-cygwin/winsup/cygwin \
		&& mkdir -p __libcygserver && cd __libcygserver \
		&& alias compile="i686-pc-cygwin-c++ \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup/cygwin \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup/w32api/lib \
		    -isystem $HOME/src/src/winsup/include \
		    -isystem $HOME/src/src/winsup/cygwin/include \
		    -isystem $HOME/src/src/winsup/w32api/include \
		    -B$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/newlib/ \
		    -isystem $HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/newlib/targ-include
\
		    -isystem $HOME/src/src/newlib/libc/include \
		    -c -nostdinc++  -DHAVE_CONFIG_H  -g -O2 -MMD  -Werror -fmerge-constants \
		    -ftracer -mno-use-libstdc-wrappers  -Wall -Wstrict-aliasing
-Wwrite-strings \
		    -fno-common -pipe -fbuiltin -fmessage-length=0  -I.. \
		    -I$HOME/src/src/winsup/cygwin \
		    -I$HOME/src/src/winsup/w32api/include \
		    -I$HOME/src/src/winsup/cygwin/config/i386 \
		    -I$HOME/cygwin-cross/lib/gcc/i686-pc-cygwin/4.3.4/include \
		    -fno-rtti -fno-exceptions";

		for i in $HOME/src/src/winsup/cygserver/*.cc; do compile -o
"$(basename ${i%.cc}.o)" "$i"; done \
		&& i686-pc-cygwin-ar cr ../__libcygserver.a *.o \
		&& cd .. \
		&& make EXTRA_OFILES='__libcygserver.a' cygwin0.dll \
		&& popd

	make all \
	&& DESTDIR=~/cygwin-dist make install 2>&1 | tee install.log \




thanks and sorry for the long email,

Alexandre Girao
-------------- next part --------------
Hi,

	After a great struggle (and lots of googling around) i finally compiled cygwin1.dll on
	linux and tested in a win32 environment, the process wasn't straightforward but it worked.

	I've attached the original email body (for long lines format protection) and all changes i've made
	(all trivial) as unified diff.

	What i want, is to know if i have done something *very* wrong in the cygwin configuration
	and compilation, because the cygwin compilation raised a lot of undefined references from
	cygserver, i had to compile cygserver separately and manually (outside autotools) for the
	process to complete, below are the procedures i've followed.
	
	If this listing isn't the proper place to discuss this, please forgive-me and point me the right
	direction.

	I also thank you all for the great work on cygwin.

procedures:


download required files

	mkdir -p ~/Downloads/cygwin-cross && cd ~/Downloads/cygwin-cross
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/binutils/binutils-2.20.51-2-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/gcc4/gcc4-4.3.4-3-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/cygwin/cygwin-1.7.6-1-src.tar.bz2
	wget -c http://mirror.cpsc.ucalgary.ca/mirror/cygwin.com/release/cygwin/cygwin-1.7.6-1.tar.bz2

install cocom (shilka tool required by cygwin)

	# instructions at cocom/README.txt

prepare sources and auxiliary files

	mkdir -p ~/src && cd ~/src

	tar -xjf ~/Downloads/cygwin-cross/binutils-2.20.51-2-src.tar.bz2
	tar -xjf ~/Downloads/cygwin-cross/gcc4-4.3.4-3-src.tar.bz2
	tar -xjf gcc-4.3.4.tar.bz2

	tar -xjf ~/Downloads/cygwin-cross/cygwin-1.7.6-1-src.tar.bz2
	rm -fv src && ln -s cygwin-1.7.6-1 src

	cd ~/src/binutils-2.20.51-2
	git init && git add . && git commit -m 'initial commit' && git repack -d && git prune

	cd ~/src/gcc-4.3.4
	git init && git add . && git commit -m 'initial commit'

	patch -p2 < ../gcc4-4.3.4-3.src.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3.src.patch'

	patch -p2 < ../gcc4-4.3.4-3.cygwin.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3.cygwin.patch'

	patch -p1 < ~/Downloads/cygwin-cross/gcc4-4.3.4-3-strsignal.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3-strsignal.patch'

	patch -p1 < ~/Downloads/cygwin-cross/gcc4-4.3.4-3-use-libstdc-wrappers.patch
	git add . && git commit -m 'applied gcc4-4.3.4-3-use-libstdc-wrappers.patch'

	git repack -d && git prune

	cd ~/src/src
	git init && git add . && git commit -m 'initial commit'

	patch -p1 < ~/Downloads/cygwin-cross/cygwin-1.7.6-1-winsup-utils-mingw.patch
	git add . && git commit -m 'applied cygwin-1.7.6-1-winsup-utils-mingw.patch'

	git repack -d && git prune

	mkdir -p ~/src/cygwin-1.7.6-1-dist && tar -C ~/src/cygwin-1.7.6-1-dist -xjf ~/Downloads/cygwin-cross/cygwin-1.7.6-1.tar.bz2

################################################################################

setup (always execute this before going further)

	export _ZTARGET=i686-pc-cygwin
	export PATH=$PATH:~/cygwin-cross/bin:~/cygwin-cross/$_ZTARGET/bin

binutils

	mkdir -p ~/build/cygwin-cross/binutils && cd ~/build/cygwin-cross/binutils \
	&& ~/src/binutils-2.20.51-2/configure --target=$_ZTARGET --prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross --disable-nls 2>&1 | tee -a configure.log \
	&& make all 2>&1 | tee all.log \
	&& make install 2>&1 | tee install.log \

gcc4, gcc only

	&& mkdir -p ~/build/cygwin-cross/gcc4-gcc && cd ~/build/cygwin-cross/gcc4-gcc \
	&& ~/src/gcc-4.3.4/configure --target=$_ZTARGET --prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross \
	  --enable-haifa --disable-bootstrap --enable-version-specific-runtime-libs --enable-static --enable-shared --enable-shared-libgcc \
	  --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers \
	  --enable-threads=posix --with-arch=i686 --with-tune=generic --with-newlib 2>&1 | tee -a configure.log \
	&& make CFLAGS='-DUSE_CYGWIN_LIBSTDCXX_WRAPPERS=0 -DHAVE_GAS_ALIGNED_COMM=1 -g -O2' all-gcc 2>&1 | tee all.log \
	&& make install-gcc 2>&1 | tee install.log \

cygwin's newlib

	&& mkdir -p ~/build/cygwin-cross/newlib && cd ~/build/cygwin-cross/newlib \
	&& ~/src/src/configure --target=$_ZTARGET --prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross 2>&1 | tee -a configure.log \
        && make configure-target-newlib 2>&1 | tee configure-target-newlib.log \
        && make -C ${_ZTARGET}/newlib 2>&1 | tee -a newlib.log \
        && make -C ${_ZTARGET}/newlib install 2>&1 | tee -a newlib-install.log \

gcc4, full

	&& mkdir -p ~/build/cygwin-cross/gcc4-all && cd ~/build/cygwin-cross/gcc4-all \
	&& ~/src/gcc-4.3.4/configure --target=$_ZTARGET --prefix=$HOME/cygwin-cross --exec-prefix=$HOME/cygwin-cross \
	  --enable-haifa --disable-bootstrap --enable-version-specific-runtime-libs --enable-static --enable-shared --enable-shared-libgcc \
	  --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers \
	  --enable-threads=posix --with-arch=i686 --with-tune=generic --with-newlib 2>&1 | tee -a configure.log \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib ~/cygwin-cross/$_ZTARGET/lib/libkernel32.a --def ~/src/src/winsup/w32api/lib/kernel32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib ~/cygwin-cross/$_ZTARGET/lib/libuser32.a --def ~/src/src/winsup/w32api/lib/user32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib ~/cygwin-cross/$_ZTARGET/lib/libadvapi32.a --def ~/src/src/winsup/w32api/lib/advapi32.def \
	&& ${_ZTARGET}-dlltool --as=${_ZTARGET}-as -k --output-lib ~/cygwin-cross/$_ZTARGET/lib/libshell32.a --def ~/src/src/winsup/w32api/lib/shell32.def \
	&& (cd ~/cygwin-cross/${_ZTARGET} && tar -cjf include-newlib-original.tar.bz2 include) \
	&& rsync -a --exclude '- CVS' ~/src/src/winsup/cygwin/include/ ~/cygwin-cross/${_ZTARGET}/include/ \
	&& ln -s ~/src/cygwin-1.7.6-1-dist/usr/lib/libcygwin.a ~/cygwin-cross/${_ZTARGET}/lib/libcygwin.a \
	&& ln -s ~/src/cygwin-1.7.6-1-dist/usr/lib/crt0.o ~/cygwin-cross/${_ZTARGET}/lib/crt0.o \
	&& make CFLAGS='-DUSE_CYGWIN_LIBSTDCXX_WRAPPERS=0 -DHAVE_GAS_ALIGNED_COMM=1 -g -O2 -I$(HOME)/src/src/winsup/w32api/include' all 2>&1 | tee all.log \
	&& make install 2>&1 | tee install.log \
	&& echo 'main() {puts("hello world of real possibilities!");}' | ${_ZTARGET}-gcc -o "_test_${_ZTARGET}_pe32_output" -x c - && echo 'gcc4 can generate pe executables' \

cygwin

	&& mkdir -p ~/build/cygwin-cross/cygwin && cd ~/build/cygwin-cross/cygwin \
	&& ~/src/src/configure --target=$_ZTARGET 2>&1 | tee -a configure.log \
	&& make all 2>&1 | tee all.log \

	# generate cygwin0.dll manually

		&& pushd i686-pc-cygwin/winsup/cygwin \
		&& mkdir -p __libcygserver && cd __libcygserver \
		&& alias compile="i686-pc-cygwin-c++ \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup/cygwin \
		    -L$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/winsup/w32api/lib \
		    -isystem $HOME/src/src/winsup/include \
		    -isystem $HOME/src/src/winsup/cygwin/include \
		    -isystem $HOME/src/src/winsup/w32api/include \
		    -B$HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/newlib/ \
		    -isystem $HOME/build/cygwin-cross/cygwin/i686-pc-cygwin/newlib/targ-include \
		    -isystem $HOME/src/src/newlib/libc/include \
		    -c -nostdinc++  -DHAVE_CONFIG_H  -g -O2 -MMD  -Werror -fmerge-constants \
		    -ftracer -mno-use-libstdc-wrappers  -Wall -Wstrict-aliasing -Wwrite-strings \
		    -fno-common -pipe -fbuiltin -fmessage-length=0  -I.. \
		    -I$HOME/src/src/winsup/cygwin \
		    -I$HOME/src/src/winsup/w32api/include \
		    -I$HOME/src/src/winsup/cygwin/config/i386 \
		    -I$HOME/cygwin-cross/lib/gcc/i686-pc-cygwin/4.3.4/include \
		    -fno-rtti -fno-exceptions";

		for i in $HOME/src/src/winsup/cygserver/*.cc; do compile -o "$(basename ${i%.cc}.o)" "$i"; done \
		&& i686-pc-cygwin-ar cr ../__libcygserver.a *.o \
		&& cd .. \
		&& make EXTRA_OFILES='__libcygserver.a' cygwin0.dll \
		&& popd

	make all \
	&& DESTDIR=~/cygwin-dist make install 2>&1 | tee install.log \




thanks and sorry for the long email,

Alexandre Girao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: email-cygwin-developers--all.log.gz
Type: application/x-gzip
Size: 32618 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: email-cygwin-developers--config.log.gz
Type: application/x-gzip
Size: 6296 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-1.7.6-1-winsup-utils-mingw.patch
Type: text/x-patch
Size: 280 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc4-4.3.4-3-gcc_unwind.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc4-4.3.4-3-strsignal.patch
Type: text/x-patch
Size: 287 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc4-4.3.4-3-use-libstdc-wrappers.patch
Type: text/x-patch
Size: 485 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20100823/d75a2472/attachment-0005.bin>


More information about the Cygwin-developers mailing list