SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have been building my own SlackBuild scripts for several packages. I have a question regarding compiling, especially in regards to compiling for i686.
To start with, I attempt to copy the format of the official SlackBuild scripts in Slackware. In most you see some sections that look like:
Code:
ARCH=${ARCH:-i486}
<SNIP>
if [ "$ARCH" = "i386" ]; then
SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2"
fi
<SNIP>
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr
$ARCH-slackware-linux
make
make install DESTDIR=$PKG
I would like to compile for i686. As such, I have made my SlackBuild scripts look like this:
Code:
ARCH=${ARCH:-i686}
<SNIP>
if [ "$ARCH" = "i386" ]; then
SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2"
fi
<SNIP>
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr
$ARCH-slackware-linux
make
make install DESTDIR=$PKG
I have not had any issue with this working, but it did bring up two question (possibly related to each other).
First, what does the $ARCH-slackware-linux do? If $ARCH=i686, should I still be using $ARCH-slackware-linux, or should I switch that to i486-slackware-linux?
Secondly, I often get a message when compiling:
Code:
configure: WARNING: you should use --build, --host, --target
checking build system type... i686-slackware-linux-gnu
checking host system type... i686-slackware-linux-gnu
On my system, I see things like /usr/i486-slackware-linux and /usr/lib/gcc-lib/i486-slackware-linux.
How does this all come together? Just looking to understand the compiling process a little better.
Switch it to i486-slackware-linux as those are actual libraries that are necessary for compiling and running programs in those directories. You can change the march and mcpu/mtune to whatever you want, but you _must_ keep that i486-slackware-linux
Some configure scripts I've seen can be called like this:
./configure [options] [build]
for example you could run "./configure [options] i686-pc-linux-gnu". Other scripts have "build" as one of the options, so instead you would run "./configure [options] --build=i686-pc-linux-gnu".
I have no idea of how these options affect what gets compiled, hopefully someone can explain that.
Yes you need the bacslash so that the line gets used with the ./configure command.
'march' establishes the minimum required architecture. Using a 'bigger' 'mcpu' means that when the software is compiled, if any optimizations are available for the bigger arch, they will be enabled -but still not ruling out running on the lesser architecture. For most software this is not an issue, but there are some key packages that may benefit from this.
The i486-slackware-linux host and target are built into the distro from the groud up. Have a look at the build scripts for GCC and GLIBC. By compiling GLIBC with a 1486-slackware-linux 'target' a separate directory for libraries is created and recognized in the /usr directory. Then, when GCC is compiled by linking to those libraries, each program compiled with this compiler can be aware of those libraries.and their specific location.
-------------
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--target $ARCH-slackware-linux
make
make install DESTDIR=$PKG
--------------
to avoid the WARNING.
( but this warning should also show up when you use original slackbuild scripts )
and to add to gnashley's explanation....
quote from the glibc FAQ----------------
1.18. How can I compile on my fast ix86 machine a working libc for my slow i386? After installing libc, programs abort with "Illegal Instruction".
{AJ} glibc and gcc might generate some instructions on your machine that aren't available on i386. You've got to tell glibc that you're configuring for i386 with adding i386 as your machine, for example:
../configure --prefix=/usr i386-pc-linux-gnu
And you need to tell gcc to only generate i386 code, just add `-mcpu=i386' (just -m386 doesn't work) to your CFLAGS.
{UD} This applies not only to the i386. Compiling on a i686 for any older model will also fail if the above methods are not used.
---------------------
i don't understand why a variable is being used here... i mean, don't you need to leave that at "i486-slackware-linux" regardless of what march/mcpu settings you use??
well...i guess you are right.
i still don't understand how it all works, but " i486-slackware-linux "
should point the compiler to the /usr/i486-slackware-linux dir which
contains some libs and some binaries,
or to /usr/lib/gcc-lib/i486-slackware-linux/
so there's no use to change that to i686-slackware-linux.
OK, starting to understand this. My next question that comes up is this:
I see several different methods. Something like:
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
$ARCH-slackware-linux
make
make install DESTDIR=$PKG
Which seems to be incorrect when ARCH=i686 (since, as noted by others above, . So we have
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
i486-slackware-linux
make
make install DESTDIR=$PKG
Which would seem to be correct for i686.
But what does that mean? I hope this makes sense. What I would like to know, is this the same as:
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--build=i486-slackware-linux
make
make install DESTDIR=$PKG
or
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--target=i486-slackware-linux
make
make install DESTDIR=$PKG
or
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--host=i486-slackware-linux
make
make install DESTDIR=$PKG
To (possibly) make the question more clear: I am compiling on a stock Slackware system. The computer is i686. The package will be for the computer that it is compiled on, only. Does that mean that a correct SlackBuild, if I wish to compile for i686 should look like this:
Code:
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--build=i486-slackware-linux \
--host=i486-slackware-linux \
--target=i486-slackware-linux
make
make install DESTDIR=$PKG
quote----------------
The configure script should also take an argument which specifies the type of system to build the program for. This argument should look like this:
cpu-company-system
For example, an Athlon-based GNU/Linux system might be ‘i686-pc-linux-gnu’.
The configure script needs to be able to decode all plausible alternatives for how to describe a machine. Thus, ‘athlon-pc-gnu/linux’ would be a valid alias. There is a shell script called config.sub that you can use as a subroutine to validate system types and canonicalize aliases.
The configure script should also take the option --build=buildtype, which should be equivalent to a plain buildtype argument. For example, ‘configure --build=i686-pc-linux-gnu’ is equivalent to ‘configure i686-pc-linux-gnu’. When the build type is not specified by an option or argument, the configure script should normally guess it using the shell script config.guess.
----------------------endquote
edit : shouldn't that be : Where SLKFLAGS="-O2 -march=i686 -mcpu=i686" ?
...........................................................................^....................
edit : shouldn't that be : Where SLKFLAGS="-O2 -march=i686 -mcpu=i686" ?
...........................................................................^....................
egag
DOH!!! I am the king of typos in this thread.
This was exactly the info I was looking for. So the final thing to understand, then, is the --host and --target, which I assume should also be i486-slackware-linux for any x86 builds.
***EDIT***
Just read the link. So those are only need for cross-compiling. I get it all, now.
***/EDIT***
Originally posted by shilo So the final thing to understand, then, is the --host and --target, which I assume should also be i486-slackware-linux for any x86 builds.
that's not the impression i got after reading the link...
Quote:
argument which specifies the type of system to build the program for.
if that's true, then if i wanted to build a binary for a mandrake box on my slackware box i should use a:
Code:
i586-mandrake-linux
or something like that, considering that's the environment i'm building for??
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.