Gentoo Archives: gentoo-user

From: Nils Holland <nhg@×××××.org>
To: gentoo-user@l.g.o
Subject: [gentoo-user] The CHOST variable
Date: Fri, 04 Feb 2011 00:05:26
Message-Id: 20110203234352.GA5264@eee1215n.fritz.box
1 Hi folks,
2
3 well, it's not that a certain thing I'm intending to do has pointed me
4 to it, but I've just noticed that something I've taken for granted for
5 years is something I probably fail to understand correctly. And as I'm
6 always eager to learn, I'm wondering if someone can point me in the
7 right direction.
8
9 I'm talking about the CHOST variable as defined in /etc/make.conf, and
10 what actually lies behind it.
11
12 Obviously, whatever is specified in make.conf as CHOST is passed to
13 ./configure as --host when emerging packages. Ok, I know several
14 things about that: The contents of the CHOST variable is a "target
15 triplet" in the form of (for example) i686-pc-linux-gnu. According to
16 the autoconf info documentation, packages using the GNU build
17 environment use this triplet to properly configure the package at hand
18 for the specified target architecture. If no --host is given to
19 configure, it will try to determine the correct triplet for the
20 current system by the rules specified in "config.sub". Beside --host,
21 configure also accepts --build and --target, which specify the system
22 on which the package is being configured and built (--build) and the
23 the type of architecture for which a compiler being configured is
24 supposed to be able to generate code (--target, which - I believe -
25 only really seems to make sense when building a compiler like
26 GCC). These can also be influenced via make.conf, where they are
27 called CBUILD and CTARGET.
28
29 All of this is fine so far and relatively understandable. But a few
30 questions remain:
31
32 1) So a package using the GNU build system determines or is passed
33 (via --host aka. CHOST) a target triplet specifying the system on
34 which the resulting compiled code is supposed to run. What does the
35 package do with that information? Does it only use it to determine
36 what it has to compile (different / special code for different systems
37 / architectures), or does this already have an influence on the
38 optimization of the resulting code for a certain (sub-)architecture?
39 Forthermore: Does configuring a package with, say,
40 --host=i686-pc-linux-gnu already automatically mean that said package
41 would not be able to run on (for example) an i486-pc-linux-gnu host?
42 Or can this only be said to be true if the package itself decides to
43 compile different / incompatible code for i686 and i486; in other
44 words: If the package itself does not make any distinction on the CPU
45 subtype, then the result would run "everywhere", as --host does not by
46 itself imply any such thing as --march=?
47
48 2) /etc/make.conf contains a note that one should not change the CHOST
49 lightly (not that I'm planning to) and links to a nice document
50 explaining how it can be done anyway (which, I have to admit, didn't
51 make me any wiser, however). The question is, out of curiosity, why
52 the CHOST should not be changed and what would happen if one did it
53 anyway. I willingly believe that it would lead to problems, but would
54 the actual cause of these problems actually be caused by the
55 configuration of the machine being mixed up (for example, by the GNU
56 build system / autoconf suddenly looking for a compiler or similiar
57 tools / libraries under a path or by a name involving, for example,
58 i486-pc-linux-gnu, which does not automatically exist of the
59 appropriate tools have not been installed accordingly. Or would
60 problems arise because code generated with the new CHOST does no
61 longer "fit" to code generated with the previous / old CHOST?
62
63 Any hints here would be welcome. Again, it's not that I need to know
64 in order to do something, but all of this stuff has always worked so
65 well every time I've built a package, and if feels kind of strange not
66 to know why / how it actually works. As neither the docs of autoconf,
67 binutils nor GCC could properly enlighten me, I thought I'd ask
68 here. ;-)
69
70 Greetings,
71 Nils
72
73
74 --
75 Nils Holland * Ti Systems, Wunstorf-Luthe (Germany)
76 Powered by GNU/Linux since 1998

Replies

Subject Author
Re: [gentoo-user] The CHOST variable Alan McKinnon <alan.mckinnon@×××××.com>
Re: [gentoo-user] The CHOST variable Enrico Weigelt <weigelt@×××××.de>