LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   install gcc-3.4.6 in slackware-current (https://www.linuxquestions.org/questions/slackware-14/install-gcc-3-4-6-in-slackware-current-557325/)

lordwolf 05-28-2007 10:43 PM

install gcc-3.4.6 in slackware-current
 
hi everbody..

i'm currently on slackware-current (thanks to eric's mirror-slackware-current script ;)).. anyways, i need to compile qemu & kqemu, which doesn't work with the current gcc (4.x). my question is - will there be any problems (existing file overwritten, etc) if i do installpkg gcc-3.x from pasture? will the existing toolchain still be in 'one piece'? i plan to removepkg once i'm done with compiling those two packages :)

thanks.

H_TeXMeX_H 05-28-2007 11:32 PM

If those are the only two you need, why can't you just sort out the errors ? Maybe post them ... they are usually trivial ... I mean easy to fix. I know I used gcc-4.x for a while (on FC5), and I had to sort out a lot of problems ... but I sorted out every one :D ... of course, a little experience with C and C++ helps :), but usually the compiler just tells you what to fix and how to fix it (believe it or not).

GregLee 05-29-2007 12:23 AM

It shouldn't be a problem, since gcc is designed to allow several versions to coexist. If you installed gcc-4.1.2 over your old gcc, as I did, you can just: "cd /usr/bin; ln -sf gcc-3.4.6 gcc".

Zmyrgel 05-29-2007 01:14 AM

If you only need the qemu and kqemu packages you can install them from Alien's repository.

lordwolf 05-29-2007 01:42 AM

Quote:

Originally Posted by H_TeXMeX_H
If those are the only two you need, why can't you just sort out the errors ? Maybe post them ... they are usually trivial ... I mean easy to fix. I know I used gcc-4.x for a while (on FC5), and I had to sort out a lot of problems ... but I sorted out every one :D ... of course, a little experience with C and C++ helps :), but usually the compiler just tells you what to fix and how to fix it (believe it or not).

I'm not sure I want to change the original code :) - and I don't think the errors are fixable without doing that. a './configure' already says I shouldn't compile with 4.x - I tried disabling that check and compile anyways, but obviously, it failed. And I don't believe I've came across anybody who have compiled qemu using gcc-4.x ...

I was actually worried about breaking the original toolchain if I install (and later remove) gcc-3.4.6 ... I guess I can just reinstall 4.1.2 if that happens.. :cry:

gnashley 05-29-2007 01:44 AM

Installing the regular Slackware package for older gcc *will* overwrite somw newer files. This is because Slackware is meant to use just one compiler and installs binaries in /usr.
However, you can re-compile gcc-3.4 using a separate prefix and then create a wrapper for it to put in /usr/bin.

lordwolf 05-29-2007 01:48 AM

Quote:

Originally Posted by Zmyrgel
If you only need the qemu and kqemu packages you can install them from Alien's repository.

Actually, I've tried that... I had some problem with the kqemu package but I don't quite remember what it was.. :scratch: Anyhow, I decided to look into the SlackBuild script and then, I thought I should compile them myself (I did that on Zenwalk 4.2). That's when I realized the 4.x problem :cry:

lordwolf 05-29-2007 01:52 AM

Quote:

Originally Posted by gnashley
Installing the regular Slackware package for older gcc *will* overwrite somw newer files. This is because Slackware is meant to use just one compiler and installs binaries in /usr.
However, you can re-compile gcc-3.4 using a separate prefix and then create a wrapper for it to put in /usr/bin.

Yeah.. that's an idea! Now why didn't I think of that :p

gnashley 05-29-2007 04:00 AM

I use several alternative compilers, usually placing them in /opt, but usr/gcc-3.4.6 would be just as safe.
Here's the wrapper I use to run gcc-3.3.6:

#!/bin/sh
PATH=/opt/gcc-3.3.6/bin:$PATH
export PATH=/opt/gcc-3.3.6/lib/gcc-lib/i486-slackware-linux/3.3.6:$PATH
# export LD_LIBRARY_PATH=/opt/gcc-3.3.6/lib
exec "$@"

I name this script GCC336 and place it in /usr/bin. Then to use it instead of the regular compiler just type:
GCC336 make

GregLee 05-29-2007 11:10 AM

Quote:

Originally Posted by gnashley
Installing the regular Slackware package for older gcc *will* overwrite somw newer files.

It will? Other than the soft link /usr/bin/gcc and /usr/bin/cpp, could you name any files that will be overwritten?

jong357 05-29-2007 12:03 PM

Too many files to name. Bad idea installing both side by side unless you use a different prefix for one of them. Installing 3.4.6 from pasture would effectively destroy your gcc-4 install.

I use 4.2 in /usr and 3.4.6 in /opt. Gnashley has the right of it with making a wrapper script. However, you wouldn't want to append to your PATH on a global basis (such as in /etc/profile.d or /etc/profile) because it'll look in the first PATH directory you specify and use that. So if I put Gnashley's script in /etc/profile.d and just compiled something with "make", it'll use 3.4.6....

What I do is similar to a wrapper script. I make an alias in /etc/bashrc..
Code:

alias gcc346='CC=/opt/gcc-3.4.6/bin/gcc'
Then, if I'm compiling something, and wan't to use 3.4.6, I do what Gnashley does... "gcc346 make"

Or, if I'm calling a build script, "gcc346 foobar.SlackBuild"

Also, appending to your library PATH is unecessary because each seperate instance of gcc knows where to find it's own libs, which is why that bit is commented out in Gnashley's script.

Here is a build script if anyone is interested.. I like to make monolithic gcc packages instead of busting it up.
Code:

#!/bin/sh
#
# $CFLAGS are set globaly in /etc/bashrc

CWD=`pwd`
TMP=/tmp
PKGNAME=gcc
PKG=$TMP/package-$PKGNAME
VERSION=3.4.6
PKGVER=${VERSION}
ARCH=i686
BUILD=1
BOOT_CFLAGS="-march=i686 -O2 -pipe"

rm -rf $PKG
mkdir -p $PKG/install

cd $TMP
echo
echo "$PKGNAME-$VERSION source is now extracting..."
rm -rf $PKGNAME-$VERSION
rm -rf $PKGNAME-build
tar xjf $CWD/$PKGNAME-$VERSION.tar.bz2
mkdir $PKGNAME-build
cd $PKGNAME-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 754 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
# Use libiberty.a from Binutils:
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
# Prevent the fixincludes script from running & delete debug ref
sed -i.bak \
        -e 's,\./fixinc\.sh,-c true,' \
        -e '/^LIBGCC2_DEBUG/d' gcc/Makefile.in

cd ../$PKGNAME-build

# See if we should bootstrap or not:
if gcc -dumpversion | grep $VERSION 2>/dev/null 1>/dev/null ;then
  bootstrapgcc=no
else
  bootstrapgcc=yes
fi
if [ "$CC" = "/opt/gcc-3.4.6/bin/gcc" ]; then
  bootstrapgcc=no
fi

if [ "$bootstrapgcc" = "no" ]; then
  # rebuilding the same version:
  ../$PKGNAME-$VERSION/configure --prefix=/opt/$PKGNAME-$VERSION \
        --enable-shared \
        --disable-multilib \
        --disable-bootstrap \
        --enable-languages=c,c++ \
        --enable-clocale=gnu \
        --enable-threads=posix \
        --enable-__cxa_atexi
  make LDFLAGS="-s"
fi
if [ "$bootstrapgcc" = "yes" ]; then
  # upgrading to a new version:
  ../$PKGNAME-$VERSION/configure --prefix=/opt/$PKGNAME-$VERSION \
        --enable-shared \
        --disable-multilib \
        --enable-languages=c,c++ \
        --enable-clocale=gnu \
        --enable-threads=posix \
        --enable-__cxa_atexit
  make LDFLAGS="-s" bootstrap
fi

# Ask the user if they want to run the test suite:
echo
echo "Compilation of $PKGNAME-$VERSION is now done. You might want"
echo "to take the time to review the above output and make sure"
echo "it completed with no errors..."
echo
echo "The GCC test suite is very comprehensive and is almost guaranteed"
echo "to generate a few failures. It also takes quite some time to run..."
echo
echo "Do you wish to test the results? ([y], [n])"
if [ ! "$RESP" ]; then
  read RESP;
  echo
fi
if [ "$RESP" = "y" ]; then
  echo "O.k... Probably not a bad idea..."
  echo
  runtest=yes
  sleep 2
  make -k check
fi
if [ "$RESP" = "n" ]; then
    echo "Skipping tests..."
    echo
    sleep 2
fi

make DESTDIR=$PKG install -j1
mkdir -p $PKG/usr/lib
# Should probably keep it where it is and symlink to /usr...
# We really don't have to do this at all actually...
mv $PKG/opt/$PKGNAME-$VERSION/lib/libstdc++.so.6.0.3 $PKG/usr/lib
( cd $PKG/opt/$PKGNAME-$VERSION/lib
  ln -sf ../../../usr/lib/libstdc++.so.6.0.3 . )

# Fix info dir
if [ -f $PKG/opt/$PKGNAME-$VERSION/info/dir ]; then
  rm $PKG/opt/$PKGNAME-$VERSION/info/dir
fi

# Compress and strip
( cd $PKG/opt/$PKGNAME-$VERSION/man
    gzip -9 */*
    cd man1
    ln -svf g++.1.gz c++.1.gz
    ln -svf gcc.1.gz cc.1.gz )

# Redundant becuase of LDFLAGS
( cd $PKG
    find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
    find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )
find $PKG -name "*.a" | xargs file | grep "archive" | cut -f 1 -d : | xargs strip -g

# Make the package description:
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.

  |-----handy-ruler----------------------------------------------------------|
gcc: gcc (GCC with C support)
gcc:
gcc: GCC is the GNU Compiler Collection.
gcc:
gcc: This package contains those parts of the compiler collection needed
gcc: to compile C code.
gcc:
gcc:
gcc:
gcc:
gcc:
EOF

# Build the package:
cd $PKG
makepkg -l y -c n $TMP/$PKGNAME-$PKGVER-$ARCH-$BUILD.tgz

if [ "$runtest" = "yes" ]; then
  echo "Here are the test results for GCC-$VERSION"
  echo
  echo
  echo "******************************************************************"
  echo "* !!!!!!!!!!!!!!!  BEGINNING OF TEST SUMMARY  !!!!!!!!!!!!!!!!!! *"
  echo "******************************************************************"
  echo
  echo "If this is the only thing you see, then your missing"
  echo "some packages that were needed in order to run the test"
  echo "suite. Tcl, Expect and DejaGNU must be installed first..."
  echo
  cd $TMP/$PKGNAME-build
  ../$PKGNAME-$VERSION/contrib/test_summary
  # For just the brief summaries:
  #../$PKGNAME-$VERSION/contrib/test_summary | grep -A7 Summ
  echo
  echo "******************************************************************"
  echo "* !!!!!!!!!!!!!!!    END OF TEST SUMMARY    !!!!!!!!!!!!!!!!!! *"
  echo "******************************************************************"
  echo
  echo "Package creation complete..."
  echo
fi


Alien Bob 05-29-2007 12:12 PM

Alternatively you can install my gcc34 "compatibility" package from here: http://www.slackware.com/~alien/slackbuilds/gcc34/

It installs happily alongside the gcc4 that ships with Slackware-current, and it will not overwrite a thing. The compile of QEMU will pick up this gcc34 and build a good package. All the other software keeps compiling with the standard gcc4.
I have had several people reporting success in using this gcc34 package.

Read the SlackBuild for more information on how you can call the gcc34 binary if you need it.

Eric

GregLee 05-29-2007 12:23 PM

Quote:

Originally Posted by jong357
Too many files to name.

I didn't ask you to name them all. How about naming two?

gnashley 05-29-2007 12:26 PM

I just install the wrapper into /usr/bin for simplicity -it allows me to distribute a safely installable package that doesn't require you to edit/create any config files, such as .bashrc, etc.

I include the LD_LIBRARY_PATH, but commented out, in case a user needs it. I've found a few situations where it was needed, such as when compiling with gcc-2.95.3(for programs that link to the gcclib) or mingW32 or other cross-compiler.

H_TeXMeX_H 05-29-2007 12:27 PM

One more thing, have you tried the cvs snapshots of qemu ... maybe they got it working with the newer gcc ... they should have after all this time it has been out.

Alien Bob 05-29-2007 01:17 PM

No they haven't. And I doubt they will anytime soon.

Eric

theoffset 05-29-2007 02:04 PM

Quote:

Originally Posted by H_TeXMeX_H
One more thing, have you tried the cvs snapshots of qemu ... maybe they got it working with the newer gcc ... they should have after all this time it has been out.

They won't... and that's for a while. The problem is that Qemu actually uses GCC to run ("it uses the compiler in some ways it wasn't meant to be used" http://lists.gnu.org/archive/html/qe...msg00238.html), mostly to generate the assembler-backend used to recompile code.

The thing is that there were some significant changes in the 4.x branch which had made it mostly uncompatible with the way Qemu uses it. Still, I've read of people who got it working with 4.0 (IIRC), but doing some odd tricks with the compiler (http://lists.gnu.org/archive/html/qe.../msg00187.html, that's for PPC, tho').

H_TeXMeX_H 05-29-2007 03:02 PM

Oh, I see, didn't know that. Thanks for the info. Guess the only solution is to install gcc-3.x. Oh well ...

jong357 05-29-2007 03:36 PM

Quote:

Originally Posted by GregLee
I didn't ask you to name them all. How about naming two?

How's about doing a little footwork yourself? Since you seem incapable of finding out for yourself I'll go ahead and tell you.

This is just from /var/log/packages and doesn't include symlinks. And this is also according to how I build it and not Slackware... Change my TARGET to Slackwares TARGET and that'll be about the only diff. And, ofcourse, I did a sed @opt/gcc-3.4.6@usr@ before my sort|uniq... As you can see, it will overwrite many files, thus resulting in a broken gcc-4. Do a uniq -u and you'll see all the broken clutter on your system doing nothing...
Code:

$ cat gcc-4.2.0-i686-1 gcc-3.4.6-i686-1 | sort | uniq -d
usr/bin/c++
usr/bin/cpp
usr/bin/g++
usr/bin/gcc
usr/bin/gccbug
usr/bin/gcov
usr/bin/i686-pc-linux-gnu-c++
usr/bin/i686-pc-linux-gnu-g++
usr/bin/i686-pc-linux-gnu-gcc
usr/info/
usr/info/cpp.info
usr/info/cppinternals.info
usr/info/gcc.info
usr/info/gccinstall.info
usr/info/gccint.info
usr/lib/libgcc_s.so.1
usr/lib/libstdc++.a
usr/lib/libstdc++.la
usr/lib/libsupc++.a
usr/lib/libsupc++.la
usr/man/
usr/man/man1/
usr/man/man1/cpp.1.gz
usr/man/man1/g++.1.gz
usr/man/man1/gcc.1.gz
usr/man/man1/gcov.1.gz
usr/man/man7/
usr/man/man7/fsf-funding.7.gz
usr/man/man7/gfdl.7.gz
usr/man/man7/gpl.7.gz
usr/share/
usr/share/locale/
usr/share/locale/be/
usr/share/locale/be/LC_MESSAGES/
usr/share/locale/be/LC_MESSAGES/gcc.mo
usr/share/locale/ca/
usr/share/locale/ca/LC_MESSAGES/
usr/share/locale/ca/LC_MESSAGES/gcc.mo
usr/share/locale/da/
usr/share/locale/da/LC_MESSAGES/
usr/share/locale/da/LC_MESSAGES/gcc.mo
usr/share/locale/de/
usr/share/locale/de/LC_MESSAGES/
usr/share/locale/de/LC_MESSAGES/gcc.mo
usr/share/locale/de/LC_MESSAGES/libstdc++.mo
usr/share/locale/el/
usr/share/locale/el/LC_MESSAGES/
usr/share/locale/el/LC_MESSAGES/gcc.mo
usr/share/locale/es/
usr/share/locale/es/LC_MESSAGES/
usr/share/locale/es/LC_MESSAGES/gcc.mo
usr/share/locale/fr/
usr/share/locale/fr/LC_MESSAGES/
usr/share/locale/fr/LC_MESSAGES/gcc.mo
usr/share/locale/fr/LC_MESSAGES/libstdc++.mo
usr/share/locale/ja/
usr/share/locale/ja/LC_MESSAGES/
usr/share/locale/ja/LC_MESSAGES/gcc.mo
usr/share/locale/nl/
usr/share/locale/nl/LC_MESSAGES/
usr/share/locale/nl/LC_MESSAGES/gcc.mo
usr/share/locale/rw/
usr/share/locale/rw/LC_MESSAGES/
usr/share/locale/rw/LC_MESSAGES/gcc.mo
usr/share/locale/sv/
usr/share/locale/sv/LC_MESSAGES/
usr/share/locale/sv/LC_MESSAGES/gcc.mo
usr/share/locale/tr/
usr/share/locale/tr/LC_MESSAGES/
usr/share/locale/tr/LC_MESSAGES/gcc.mo


GregLee 05-29-2007 05:23 PM

Quote:

Originally Posted by jong357
How's about doing a little footwork yourself? Since you seem incapable of finding out for yourself I'll go ahead and tell you.

Well, thank you for going to all that trouble. I did look for myself, actually, and didn't find any overwritten files that would affect how the gcc compiler works, except for the two I mentioned earlier. I forgot about documentation, and you're right, there are a lot of document files that would be replaced, as well as the bug-submitter and gcov. But the only other gcc file in the Slackware packages that might matter to how gcc compiles, so far as I can see, is /usr/lib/libgcc_s.so.1, and neither version of gcc is dynamically linked to that.

rworkman 05-29-2007 07:06 PM

Why is this still being argued? It's a moot point. Eric has posted a link to gcc-3.4.6 packages on his page at Slackware.com; they solve the problem without any undesirable side effects.

lordwolf 05-30-2007 01:19 AM

Quote:

Originally Posted by Alien Bob
Alternatively you can install my gcc34 "compatibility" package from here: http://www.slackware.com/~alien/slackbuilds/gcc34/

It installs happily alongside the gcc4 that ships with Slackware-current, and it will not overwrite a thing. The compile of QEMU will pick up this gcc34 and build a good package. All the other software keeps compiling with the standard gcc4.
I have had several people reporting success in using this gcc34 package.

Read the SlackBuild for more information on how you can call the gcc34 binary if you need it.

Eric

Yay! Allright, Eric! I didn't see this when I browse through your 'site' before :D I'll try using your package first... lucky thing I haven't started compiling my own :p


All times are GMT -5. The time now is 11:19 PM.