Web lists-archives.com

Re: [Mingw-users] I'm a newbie to MinGW. How Can I build MinGW from source?




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23/02/17 02:23, Ranger wrote:
> My build OS: ubuntu 14
> gcc version: 4.9

FWIW, I'm on LinuxMint Debian Edition, with gcc-4.8.2 as host compiler;
a bit older than yours, but that shouldn't matter.

> Note: my login account: www 

If you always refer to your home directory as $HOME, that's irrelevant.

> How do fix the error in gcc rebuild?
> 
> I follow steps in Keith Marshall-3's reply for "Problem with
> configure when trying to build gcc 5.3":

Well, you didn't follow them religiously :-)

> 1.downloaded source code
> binutils-2.25.1-1-mingw32-src.tar.xz
> mingwrt-3.22.4-mingw32-src.tar.xz
> w32api-3.18.2-mingw32-src.tar.xz
> gcc-5.3.0-3-mingw32-src.tar.xz

Okay, I reviewed (and repeated) my build procedure, (to remind myself 
what I did, and to check that I hadn't overlooked anything).  I used:

- - binutils-2.26 (from a GNU distribution mirror)
- - gcc-5.3.0 (as distributed by MinGW.org, with our patches applied)
- - mingwrt-5.0 preview snapshot, as posted 2017-02-12
- - w32api-5.0 preview snapshot (likewise)

> 2.mkdir /home/www/mingw32-src
>   mkdir /home/www/mingw32
>   cd /home/www/mingw32-src

I used a slight modification of this:

  $ mkdir -p $HOME/mingw32-src/build/{binutils,gcc,mingwrt,w32api}
  $ cd mingw32-src

then unpacked the mingwrt and w32api tarballs; (for gcc and binutils, 
I created symbolic links to previously unpacked working copies, which
I happened to have elsewhere within my file system).

> 3.mingwrt:
> untar mingwrt-3.22.4-mingw32-src.tar.xz in /home/www/mingw32-src and
> get mingwrt-3.22.4 folder
> cd /home/www/mingw32-src/mingwrt3.22.4
> ./configure --prefix=/home/www/mingw32

You don't say how you established the $HOME/mingw32 directory, into
which this will install; rather than leaving this...

> make install-headers

...to establish it by default, (and overwrite anything which may be
there already), I prefer to do something like, (with knowledge that
$HOME/mingw32-gcc-sandbox definitely doesn't exist beforehand):

  $ mkdir $HOME/mingw32-gcc-sandbox
  $ (cd $HOME && ln -fs mingw32-gcc-sandbox mingw32)
  $ (cd $HOME/mingw32 && ln -s . mingw)

and ensure that $HOME/mingw32/bin is included at or near the end of 
$PATH; (I have this set in $HOME/.profile):

  test -d $HOME/mingw32/bin && PATH=$PATH:$HOME/mingw32/bin

This allows me to have multiple side-by-side installations, (different 
versions, or alternative experimental builds), and switch between them
by the simple expedient of remapping one symbolic link.

With that all set up, then you should configure fully:

  $ cd build/mingwrt
  $ ../../mingwrt-5.0/configure --build=unknown --host=mingw32 \
     --prefix=$HOME/mingw32
  $ make install-headers

> 4.w32api:
> untar w32api-3.18.2-mingw32-src.tar.xz in  /home/www/mingw32-src and
> get w32api-3.18.2 folder
> cd /home/www/mingw32-src/w32api-3.18.2
> ./configure --prefix=/home/www/mingw32
> make install-headers

Likewise, you should configure fully:

  $ cd ../w32api
  $ ../../w32api-5.0/configure --build=unknown --host=mingw32 \
     --prefix=$HOME/mingw32
  $ make install-headers

> 5.GNU binutils:
> untar binutils-2.25.1-1-mingw32-src.tar.xz in /home/www/mingw32-src
> and get binutils-2.25.1 folder
> cd /homw/www/mingw32-src/binutils-2.25.1
> mkdir build
> cd build  (pwd is /home/www/mingw32-src/binutils-2.25.1/build)
> ../configure --prefix=/home/www/mingw32 \
>  --with-sysroot=/home/www/mingw32 --target=mingw32
> make
> make install

That looks okay; I did it mostly the same:

  $ cd ../binutils
  $ ../../binutils-2.26/configure --target=mingw32 \
     --{prefix,with-sysroot}=$HOME/mingw32 --disable-nls
  $ make && make install

> 6.Symbolically link:
> cd /home/www/mingw32
> ln -s /home/www/mingw32 mingw

Again, looks okay, (although I prefer the 'ln -s . mingw' format).

> 7.Prepare GCC source:
> untar gcc-5.3.0-3-mingw32-src.tar.xz in /home/www/mingw32-src and get
> gcc-5.3.0 folder

Okay, but your next step seems kind of pointless:

> cd /home/www/mingw32-src
> mkdir src
> mv gcc-5.3.0 src
> cd src/gcc-5.3.0 (pwd is /home/www/mingw32-src/src/gcc-5.3.0 )

(You can just as well leave the source at $HOME/mingw32-src/gcc-5.3.0).

> ./contrib/download_prerequisites

I didn't use this; I manually downloaded gmp, mpfr, and mpc, unpacked
all of them in $HOME/mingw32-src, then:

  $ cd $HOME/mingw32-src/gcc-5.3.0
  $ ln -s ../gmp-6.1.0 gmp
  $ ln -s ../mpfr-3.1.3 mpfr
  $ ln -s ../mpc-1.0.2 mpc

Then, while you're here, and before you proceed any further, you should 
apply the MinGW.org patches, (which are delivered in the MinGW source 
tarball, along with *unpatched* original GCC source); if you installed
mingw-pkg, then the easiest way to do this is:

  $ mingw-pkg patch

otherwise, you could do it like this:

  $ (for p in arch/mingw32/*.patch; do patch -p1 < $p; done)

> 8.Build GCC:
> cd /home/www/mingw32-src
> mkdir build
> cd build     (pwd is /home/www/mingw32-src/build)
> ../src/gcc-5.3.0/configure --prefix=/home/www/mingw32 \
>  --with-sysroot=/home/www/mingw32

Once again, you should configure it fully:

  $ cd $HOME/mingw32-src/build/gcc
  $ ../../gcc-5.3.0/configure --{prefix,with-sysroot}=$HOME/mingw32 \
     --target=mingw32 --with-arch=i586 --with-tune=generic \
     --enable-shared --enable-threads --disable-win32-registry \
     --disable-sjlj-exceptions --disable-multilib --disable-nls \
     --disable-libvtv --with-dwarf2 --enable-languages=c,c++
  $ make all-gcc && make install-gcc

> make all-gcc (here has a error: can't find
> /home/www/mingw32/usr/include.

Likely a consequence of your incomplete configuration; when configured 
as I've indicated, I see no such problem...

> I mkdir this path and rebuild successfully)

...and here, rather than eliminating the cause of the problem, you've 
kludged around a symptom of it, likely leaving further consequences to 
surface later.

> make install-gcc

Yes, but what is it installing, and where?  Since it wasn't properly 
configured, it's likely as useful as a chocolate teapot.

At this point, I would like to throw in a caveat, of which I have been 
reminded on working through the procedure again: even if you ultimately 
aim to create an OpenMP enabled cross-compiler, you should *not* add 
the '--enable-libgomp' configuration option at this stage.  If you do, 
you will not be able to complete the stage-2 gcc build, without having 
installed pthreads support, and you will not be able to compile that 
pthreads support until after you have completed the stage-2 gcc build.

> At present, I finish building cross compiler.

No, you haven't; you've merely completed the stage-1 gcc build and 
installed it into $HOME/mingw32.  Before you go any further, you
should confirm that it is accessible via $PATH, and is working:

  $ which mingw32-gcc
  /home/keith/mingw32/bin/mingw32-gcc

  $ mingw32-gcc --version
  mingw32-gcc (GCC) 5.3.0
  Copyright (C) 2015 Free Software Foundation, Inc.
  ...

> Next,I'll start to build second pass.

You're not ready to do that yet!  Your next step *must* be to go back 
to mingwrt, and to w32api, to build and install the runtime libraries;
without them, the stage-2 gcc build will fail; (indeed, it's to give 
you an opportunity to install these, that the gcc build is segregated 
into two separate stages):

  $ cd ../mingwrt
  $ ./config.status --recheck
  $ ./config.status
  $ make
  $ make install

  $ cd ../w32api
  $ ./config.status --recheck
  $ ./config.status
  $ make
  $ make install

Now, you're ready to proceed with the stage-2 gcc build; however...

> 9. Prepare GCC source again:
> untar gcc-5.3.0-3-mingw32-src.tar.xz in /home/www/mingw32-src and get
> gcc-5.3.0 folder again
> cd /home/www/mingw32-src
> mkdir srcx
> mv gcc-5.3.0 srcx
> cd srcx/gcc-5.3.0 (pwd is /home/www/mingw32-src/srcx/gcc-5.3.0 )
> ./contrib/download_prerequisites

...this is utterly futile, and together with this...

> 10.Build GCC again:
> cd /home/ww/mingw32-src
> mkdir buildx
> cd buildx        (pwd is /home/www/mingw32-src/buildx)
> mingw-pkg SRCDIR=../srcx/gcc-5.3.0 patch
> ../srcx/gcc-5.3.0/configure --prefix=/mingw --disable-win32-registry \
>   --target=mingw32 --with-arch=i586 --enable-languages=c,c++ \
>   --enable-static --enable-shared --enable-threads --with-dwarf2 \
>   --disable-sjlj-exceptions --enable-version-specific-runtime-libs \
>   --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw \
>   --enable-libstdcxx-debug --with-tune=generic --enable-libgomp \
>   --disable-libvtv --enable-nls

...is entirely wrong!  (I don't mean because you've chosen different 
options to those that I did; for you, your choice may be appropriate.  
However, your --prefix is definitely wrong -- should be the same as
you used in the stage-1 build -- and --with-sysroot is required, but 
conspicuously absent.  Also, I'd question your references to /mingw;
does your Ubuntu box have any such directory?)

What you *should do*, at this point, is:

  $ cd ../gcc
  $ make all
  $ make install

to complete the stage-2 build, and final installation of the *cross* 
compiler; (note that it will *not* be OpenMP enabled -- if you want to 
pursue that aspect, we can follow up in a future post).  Also, if you 
still want to pursue the use of the cross-compiler to create a native 
Windows gcc build, (and please explain why you think you need to do 
this, because it isn't at all clear why you think you might need it), 
we can follow up on that, later.

- -- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJYr18pAAoJEMCtNsY0flo/9YgP/0mkgbaNCD8TuW8cCpwI46mG
SqXbEX1MNCL6TAalXSwtyOJbfwWRnO39JCtxokr/SbYxVwnnvSyMFok3rztld/H2
nwjA7gJmY0iEZE2dx6PrHf9x1BgklChLTgCt+C0zZokFou0qVznEr1uvrlGQt4Jj
EwePzbwDX6mBH1pjD4QIdPwC6a0Jweu/K1tsrGnULSbtYSl/rRgXTW8/JXCZ49aW
Q5aqLPq8hsarKxB88oOHQf4+qI91LyNPiula5/J4JyOXKgBCbhV6iBoMBXrkLAhs
sMB5Lpcd7DRLKtOski44WwYuc8/HwckhZsEAUMR4yKN9uaLT7TS4nsQwOTcI6Q8L
UEODQOz1YDKiVdvVXMGmFsQLCLScnXYnVqbb3TGmOu0W2bjtVOot8sMThNLG8mRz
4GVDWKjp79Du05A1Qufqmbx14LBkOgD814+9kXDXOWziE/19BzONK8hQxKyIMp7B
ni7Dg+6e3fN5ZwGT4R0NrwK2juPRUuxJ7JE/nR3YMr9w0fsbox9MC7ZxEecLgtEX
1zA9MBkypDpPmSCN2sxvImqiKM8jUFyMUojC9dzLRwQKKm+RU5IhdPt8QFoZcvoH
Jr5Ci0nPS+CwdNABwmkoWmW0NyvZj5zT4Xjt3HF7JQkzZ5NuUZH5XRqrFpQBwp3I
b8Y6XBpvkSp2d0yzjbYP
=NNlX
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe