Gentoo Archives: gentoo-dev

From: Walter Dnes <waltdnes@××××××××.org>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] RFC: masking old versions of sys-devel/gcc
Date: Thu, 27 Apr 2017 02:09:13
Message-Id: 20170427020844.GA28587@waltdnes.org
In Reply to: Re: [gentoo-dev] RFC: masking old versions of sys-devel/gcc by "Andreas K. Huettel"
1 On Wed, Apr 26, 2017 at 11:32:21AM +0200, Andreas K. Huettel wrote
2
3 > Except that "switching back" from gcc-5 to gcc-4 doesn't really work,
4 > and that gcc-4 will happily use gcc-5 libraries, with unintended
5 > consequences.
6
7 It can be done, but it takes a little work. I do a contributed build
8 for Pale Moon using gcc 4.9.4 as per the developers' specs, and I use
9 5.4.0 for personal builds at home. This is done on a 32-bit CoentOS 6.5
10 chroot, in order to use an older gtk2 (long story). The native compiler
11 is gcc 4.7.4. I build self-contained gcc 4.9.4 and 5.4.0 environments.
12 Example follows, with gcc-4.9.4 going into $HOME/gcc494/
13
14 #######################################################################
15 #
16 # Instructions adapted from https://gcc.gnu.org/wiki/InstallingGCC
17
18 wget http://ftpmirror.gnu.org/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2
19 tar xjf gcc-4.9.4.tar.bz2
20
21 #
22 # To get gmp, mpc, mpfr, and isl libs
23 # You *MUST* run this script from the top-level GCC source dir
24
25 cd gcc-4.9.4
26 contrib/download_prerequisites
27
28 export CFLAGS="-O2 -march=native -mfpmath=sse -fomit-frame-pointer -pipe -fno-unwind-tables -fno-asynchronous-unwind-tables"
29 export CXXFLAGS="${CFLAGS}"
30 export MAKEOPTS="-j4"
31
32 #
33 # You *MUST NOT* run ./configure from the toplevel GCC source dir
34
35 mkdir gcc-build && cd gcc-build
36
37 ../configure --prefix=$HOME/gcc494 \
38 --disable-multilib \
39 --enable-libstdcxx-threads \
40 --enable-libstdcxx-time \
41 --enable-shared \
42 --enable-__cxa_atexit \
43 --disable-libunwind-exceptions \
44 --disable-libada
45
46 make -j4
47
48 make install
49 #######################################################################
50
51 So far, so good, but we also need to force invocations of "gcc" to use
52 this version. The build script sources the following commands (and
53 other build-specific stuff) before starting the compile...
54
55 #######################################################################
56 export GCCX_ROOT=$HOME/gcc494
57 export PATH=$GCCX_ROOT/bin:$PATH
58 export MANPATH=$GCCX_ROOT/share/man:MANPATH
59 export INFOPATH=$GCCX_ROOT/share/info:$INFOPATH
60 export LD_LIBRARY_PATH=$GCCX_ROOT/lib:$GCCX_ROOT/lib:$LD_LIBRARY_PATH
61 export LD_RUN_PATH=$GCCX_ROOT/lib:$GCCX_ROOT/lib:$LD_RUN_PATH
62 export LIBRARY_PATH=$GCCX_ROOT/lib:$GCCX_ROOT/lib:$LIBRARY_PATH
63 export INCLUDE_PATH=$GCCX_ROOT/include:$INCLUDE_PATH
64 export CPLUS_INCLUDE_PATH=$GCCX_ROOT/include:$CPLUS_INCLUDE_PATH
65 export C_INCLUDE_PATH=$GCCX_ROOT/include:$C_INCLUDE_PATH
66 #######################################################################
67
68 The include script to use gcc 5.4.0 differs in only the first line...
69
70 #######################################################################
71 export GCCX_ROOT=$HOME/gcc540
72 #######################################################################
73
74 Would the various "export" commands work if inserted into make.conf?
75 Actually, would they even need the "export " portion of the declaration?
76
77 --
78 Walter Dnes <waltdnes@××××××××.org>
79 I don't run "desktop environments"; I run useful applications