1 |
commit: 3b51089b55836bb36e0e0123f68068642ee0437f |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Apr 7 15:56:49 2018 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Apr 7 15:56:49 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=3b51089b |
7 |
|
8 |
README: wordsmithing, fixed a few typos |
9 |
|
10 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
11 |
|
12 |
README | 146 ++++++++++++++++++++++++++++++++++------------------------------- |
13 |
1 file changed, 76 insertions(+), 70 deletions(-) |
14 |
|
15 |
diff --git a/README b/README |
16 |
index 65703cb..99287a1 100644 |
17 |
--- a/README |
18 |
+++ b/README |
19 |
@@ -6,27 +6,31 @@ crossdev is a cross-compiler environment generator for Gentoo. |
20 |
It is useful for various purposes: |
21 |
|
22 |
- build cross-compiler toolchain for an operating system |
23 |
-- build cross-compiler toolchain for embedded targets (bare metal) |
24 |
+- build cross-compiler toolchain for embedded target (bare metal) |
25 |
- cross-compile whole Gentoo on a new (or existing) target |
26 |
- cross-compile your favourite tool for every target out there |
27 |
just to make sure it still compiles and works. Countless bugs |
28 |
- were found fixed like that :) |
29 |
+ were found and fixed like that :) |
30 |
|
31 |
Crossdev nano HOWTO |
32 |
------------------- |
33 |
|
34 |
-So you want to cross-compile a Gentoo package (say busybox): |
35 |
+So you want to cross-compile a Gentoo package (say busybox to s390x): |
36 |
|
37 |
-# crossdev -t s390x-unknown-linux-gnu |
38 |
-# (optional) ARCH=s390 PORTAGE_CONFIGROOT=/usr/s390x-unknown-linux-gnu eselect profile set default/linux/s390/17.0/s390x |
39 |
-# USE=static s390x-unknown-linux-gnu emerge -v1 busybox |
40 |
-# file /usr/s390x-unknown-linux-gnu/bin/busybox |
41 |
-/usr/s390x-unknown-linux-gnu/bin/busybox: ELF 64-bit MSB executable, IBM S/390, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, stripped |
42 |
+ # crossdev -t s390x-unknown-linux-gnu |
43 |
+ # (optional) ARCH=s390 PORTAGE_CONFIGROOT=/usr/s390x-unknown-linux-gnu eselect profile set default/linux/s390/17.0/s390x |
44 |
+ # USE=static s390x-unknown-linux-gnu-emerge -v1 busybox |
45 |
+ # file /usr/s390x-unknown-linux-gnu/bin/busybox |
46 |
+ /usr/s390x-unknown-linux-gnu/bin/busybox: ELF 64-bit MSB executable, IBM S/390, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, stripped |
47 |
|
48 |
Done! |
49 |
|
50 |
-You can even use qemu-user to run this binary (or even chroot |
51 |
-to /usr/s390x-unknown-linux-gnu! |
52 |
+You can use qemu-user to run this binary: |
53 |
+ |
54 |
+ $ qemu-s390x -L /usr/s390x-unknown-linux-gnu/ /usr/s390x-unknown-linux-gnu/bin/busybox uname -m |
55 |
+ s390x |
56 |
+ |
57 |
+or even chroot to /usr/s390x-unknown-linux-gnu directory! |
58 |
|
59 |
https://wiki.gentoo.org/wiki/Crossdev_qemu-static-user-chroot |
60 |
|
61 |
@@ -36,7 +40,7 @@ Supported platforms |
62 |
Cross-compilation is fairly well supported to linux targets. |
63 |
Windows is not too broken either. |
64 |
|
65 |
-But prepare for rough corners. This doc will try to help you |
66 |
+Be prepared for rough corners. This doc will try to help you |
67 |
understand what crossdev does and does not do. |
68 |
|
69 |
A few examples of targets that worked today (produce running |
70 |
@@ -75,31 +79,31 @@ executables or kernels if applies): |
71 |
x86_64-pc-linux-gnu-7.3.0 |
72 |
x86_64-w64-mingw32-7.3.0 |
73 |
|
74 |
-A few more things are likely to Just Work |
75 |
-and many more can be made work with a litle touch. |
76 |
+A few more targets are likely to Just Work. |
77 |
+And many more can be made to work with a litle touch. |
78 |
|
79 |
How crossdev works (high-level overview) |
80 |
---------------------------------------- |
81 |
|
82 |
-crossdev is a tiny shell wrapper around emerge. Wrapper overrides |
83 |
-a few variabled to aim emerge to another target. |
84 |
+crossdev is a tiny shell wrapper around emerge tool. The wrapper |
85 |
+overrides a few variables to aim emerge at another target. |
86 |
|
87 |
-Crossdev leverages following features of portage (and ::gentoo ebulds): |
88 |
+Crossdev leverages the following features of portage (and ::gentoo |
89 |
+ebulds): |
90 |
|
91 |
- ability to override ROOT=/usr/<target> to install cross-compiled |
92 |
packages into a new root on a filesystem to avoid cluttering host. |
93 |
|
94 |
- ability to override PORTAGE_CONFIGROOT=/usr/<target> to untangle |
95 |
- from host's portage configuration. |
96 |
- |
97 |
- Namely crossdev populates /usr/<target>/etc/portage/ with defaults |
98 |
- suitable for cross-compiling (ARCH, KERNEL, ELIBC variables and so on). |
99 |
- You can change all of it. |
100 |
+ from host's /etc/portage/ configuration. Namely crossdev populates |
101 |
+ /usr/<target>/etc/portage/ |
102 |
+ with defaults suitable for cross-compiling (ARCH, KERNEL, ELIBC |
103 |
+ variables and so on). You can change all of them. |
104 |
|
105 |
- set CBUILD/CHOST/CTARGET variables accordingly to force build |
106 |
system into cross-compiling mode. For autotools-based system |
107 |
- it means running the following configure script: |
108 |
- ./configure --build=${CBUILD} --host=${CHOST} --target=${CTARGET} |
109 |
+ it means running ./configure script using following options: |
110 |
+ ./configure --build=${CBUILD} --host=${CHOST} --target=${CTARGET} ... |
111 |
|
112 |
If toolchains were simple programs crossdev would be a one-liner script: |
113 |
|
114 |
@@ -114,27 +118,29 @@ Unfortunately todays' toolchains have loops in their build-time dependencies: |
115 |
|
116 |
- cross-compiler itself normally needs a libc built for <target> because |
117 |
libc defines various aspects of userland ABI and features provided. |
118 |
-- and libc for <target> needs a cross-comiler because it's written in C |
119 |
+- and libc is written in C and thus needs a cross-compiler to be built for |
120 |
+ <target>. |
121 |
|
122 |
That's where crossdev comes in useful. It unties this vicious compiler<->libc |
123 |
-circle by carefully running the following emerge commands (assume s390x-linux |
124 |
+circle by carefully running the following emerge commands (assume s390x |
125 |
example). |
126 |
|
127 |
Here is what crossdev actually does: |
128 |
|
129 |
1. create an overlay with new ebuilds (symlinks to existing ebuilds) |
130 |
-2. build cross-binutils |
131 |
- $ emerge cross-s390x-unknown-linux-gnu/binutils |
132 |
-3. Install minimal set of system headers (kernel and libc) |
133 |
+2. build cross-binutils: |
134 |
+ $ emerge cross-s390x-unknown-linux-gnu/binutils |
135 |
+3. Install system headers (kernel headers and libc headers): |
136 |
$ USE="headers-only" emerge cross-s390x-unknown-linux-gnu/linux-headers |
137 |
$ USE="headers-only" emerge cross-s390x-unknown-linux-gnu/glibc |
138 |
-4. Build minimal GCC without libc support (not able link final executables yet) |
139 |
+4. Build minimal GCC without libc support (not able to link final |
140 |
+ executables yet) |
141 |
$ USE="-*" emerge cross-s390x-unknown-linux-gnu/gcc |
142 |
-5. Build complete libc |
143 |
- $ USE="-headers-only" emerge cross-s390x-unknown-linux-gnu/linux-headers |
144 |
- $ USE="-headers-only" emerge cross-s390x-unknown-linux-gnu/glibc |
145 |
-6. Build full GCC (able to link final binaries and can do c++) |
146 |
- $ USE="" emerge cross-s390x-unknown-linux-gnu/gcc |
147 |
+5. Build complete libc (gcc will need crt.o files) |
148 |
+ $ emerge cross-s390x-unknown-linux-gnu/linux-headers |
149 |
+ $ emerge cross-s390x-unknown-linux-gnu/glibc |
150 |
+6. Build full GCC (able to link final binaries for C and C++) |
151 |
+ $ emerge cross-s390x-unknown-linux-gnu/gcc |
152 |
|
153 |
Done! |
154 |
|
155 |
@@ -142,12 +148,13 @@ How crossdev works (more details) |
156 |
--------------------------------- |
157 |
|
158 |
This section contains more details on what actually happens. |
159 |
-Here we expand on each step briefly outlined in previous section: |
160 |
+Here we elaborate on each step outlined in previous section: |
161 |
|
162 |
1. create an overlay with new ebuilds (symlinks to existing ebuilds) |
163 |
- <skipping actual commands>. After this step the outcomes are: |
164 |
+ <skipping numeruos mkdir and ln commands>. After this step the |
165 |
+ outcomes are: |
166 |
|
167 |
- - overlay layout is formed: |
168 |
+ - overlay layout is formed in cross-overlay/: |
169 |
|
170 |
$ ls -l cross-overlay/cross-s390x-unknown-linux-gnu |
171 |
binutils -> /gentoo-ebuilds/gentoo/sys-devel/binutils |
172 |
@@ -165,7 +172,6 @@ Here we expand on each step briefly outlined in previous section: |
173 |
Here we override ARCH, LIBC, KERNEL, CBUILD, CHOST, CTARGET and a |
174 |
few other variables. |
175 |
|
176 |
- |
177 |
- a few convenience wrappers are created: |
178 |
|
179 |
/usr/bin/s390x-unknown-linux-gnu-emerge -> cross-emerge |
180 |
@@ -173,13 +179,13 @@ Here we expand on each step briefly outlined in previous section: |
181 |
/usr/bin/s390x-unknown-linux-gnu-fix-root -> cross-fix-root |
182 |
|
183 |
This way we share ebuild code and still can install cross-compilers |
184 |
- independently. Each with it's owv version of libc. |
185 |
+ independently. Each with it's own version of libc. |
186 |
|
187 |
2. build cross-binutils |
188 |
- $ emerge cross-s390x-unknown-linux-gnu/binutils |
189 |
+ # emerge cross-s390x-unknown-linux-gnu/binutils |
190 |
|
191 |
- This way we can install the same version of binutils aiming different |
192 |
- targets. As a result we get tools like: |
193 |
+ This way we can install the same version of binutils aiming at |
194 |
+ a new target. As a result we get tools like: |
195 |
s390x-unknown-linux-gnu-ar (static library archiver) |
196 |
s390x-unknown-linux-gnu-as (assembler) |
197 |
s390x-unknown-linux-gnu-ld (linker) |
198 |
@@ -191,56 +197,56 @@ Here we expand on each step briefly outlined in previous section: |
199 |
$ USE="headers-only" emerge cross-s390x-unknown-linux-gnu/linux-headers |
200 |
$ USE="headers-only" emerge cross-s390x-unknown-linux-gnu/glibc |
201 |
|
202 |
- As we don't have cross-compiler yet we just copy a bunch on |
203 |
+ As we don't have cross-compiler yet ebuilds just copy a bunch of |
204 |
header files into |
205 |
/usr/s390x-unknown-linux-gnu/usr/include |
206 |
and setup symlinks like: |
207 |
/usr/s390x-unknown-linux-gnu/sys-include -> usr/include |
208 |
to make cross-gcc happy. |
209 |
|
210 |
- These symlinks are target-dependent. A few unusual examples: |
211 |
+ These include symlinks are target-dependent. A few unusual examples: |
212 |
|
213 |
- windows (mingw): /usr/x86_64-w64-mingw32/mingw -> usr |
214 |
- hurd: /usr/i686-pc-gnu/include -> usr/include |
215 |
- - DOS (didn't try yet): /usr/i686-pc-gnu/dev/env/DJDIR/include -> ../../../usr/include |
216 |
+ - DOS: /usr/i686-pc-gnu/dev/env/DJDIR/include -> ../../../usr/include |
217 |
|
218 |
Side note: we could have omited symlink creation completely |
219 |
and build gcc with parameter: |
220 |
--with-native-system-header-dir=${EPREFIX}/usr/include |
221 |
- That way ${SYSROOT} would be even more like normal root. |
222 |
- Worth a try this one line :) |
223 |
+ That way ${SYSROOT} directory contents would be even more like normal |
224 |
+ root. Worth a try! TODO: actually do it. |
225 |
|
226 |
-4. Build minimal GCC without libc support (not able link final executables yet) |
227 |
- $ USE="-*" emerge cross-s390x-unknown-linux-gnu/gcc |
228 |
+4. Build minimal GCC without libc support (not able to link final executables |
229 |
+ yet) |
230 |
+ # USE="-*" emerge cross-s390x-unknown-linux-gnu/gcc |
231 |
|
232 |
- Here gcc uses headers from step [3.] to find out what |
233 |
- target libc can do: |
234 |
+ Here gcc uses headers from step [3.] to find out what target libc can do: |
235 |
|
236 |
- POSIX support |
237 |
- trigonometry functions |
238 |
- threading |
239 |
- vital constants |
240 |
|
241 |
- As a result we only get C code generator. No knowledge |
242 |
- of how to link executables or shared libraries as those |
243 |
- require bits of libc. |
244 |
+ As a result we only get C code generator. No knowledge of how to link |
245 |
+ executables or shared libraries as those require bits of libc. |
246 |
|
247 |
- For tiniest targets (bare-metal) this can be a final step to get basic toolchain. |
248 |
+ For tiniest targets (bare-metal) this can be a final step to get basic |
249 |
+ C toolchain. |
250 |
|
251 |
5. Build complete libc |
252 |
- $ USE="-headers-only" emerge cross-s390x-unknown-linux-gnu/linux-headers |
253 |
- $ USE="-headers-only" emerge cross-s390x-unknown-linux-gnu/glibc |
254 |
+ # emerge cross-s390x-unknown-linux-gnu/linux-headers |
255 |
+ # emerge cross-s390x-unknown-linux-gnu/glibc |
256 |
|
257 |
- Here we rebuild full libc against system headers. As a result we get C startup |
258 |
- files and can link full programs! |
259 |
+ Here we build full libc against system headers. As a result we get C |
260 |
+ startup files (crt.o) and can now link full C programs! |
261 |
|
262 |
-6. Build full GCC (able to link final binaries and can do c++) |
263 |
- $ USE="" emerge cross-s390x-unknown-linux-gnu/gcc |
264 |
+6. Build full GCC (able to link final binaries for C and C++) |
265 |
+ # USE="" emerge cross-s390x-unknown-linux-gnu/gcc |
266 |
|
267 |
- Here we get full c++ support, various default flags enabled (pie, sanitizers, |
268 |
- stack protectors and many other things). |
269 |
+ Here we get full C++ support, various default flags enabled (pie, |
270 |
+ sanitizers, stack protectors and others). |
271 |
|
272 |
- This thing is ready for large-scale operations. |
273 |
+ The final result is ready for large-scale operations. |
274 |
|
275 |
Various notes (AKA dirty little tricks) |
276 |
--------------------------------------- |
277 |
@@ -252,22 +258,22 @@ Various notes (AKA dirty little tricks) |
278 |
|
279 |
crossdev installs /usr/share/config.site with a bunch of cache |
280 |
variables preset for targets. It might be a nice place to drop |
281 |
- more things into. Or a source of all your cross-compilation |
282 |
- problems :) |
283 |
+ more things into. Or it could be a source of all your cross-compilation |
284 |
+ problems if variables set incorrect values. |
285 |
|
286 |
-- eclass inheritance |
287 |
+- eclass importing |
288 |
|
289 |
To find out various things about target crossdev loads multilib.eclass |
290 |
and tries to find out default ABI supported by the target. |
291 |
|
292 |
- crossdev is just a tiny shell script around emerge :) |
293 |
|
294 |
- It's full source code of comparable to the size of this README. |
295 |
+ It's full source code is comparable to the size of this README. |
296 |
|
297 |
- USE=headers-only |
298 |
|
299 |
- Many toolchain ebuilds (mostly libcs and kernel headers) are aware |
300 |
- of headers-only install specifically for crossdev and similar tools |
301 |
+ Many toolchain ebuilds (libcs and kernel headers) are aware of |
302 |
+ headers-only install specifically for crossdev and similar tools |
303 |
to be able to build cross-toolchains. |
304 |
|
305 |
- How to test crossdev layout generation: |