0010-eglibc-Cross-building-and-testing-instructions.patch 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. From 9373891f13f3550f9b3f896c34ac152efd369ca9 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 18 Mar 2015 00:42:58 +0000
  4. Subject: [PATCH] eglibc: Cross building and testing instructions
  5. Ported from eglibc
  6. Upstream-Status: Pending
  7. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  8. ---
  9. GLIBC.cross-building | 383 +++++++++++++++++++++++++++++++++++++++++++
  10. GLIBC.cross-testing | 205 +++++++++++++++++++++++
  11. 2 files changed, 588 insertions(+)
  12. create mode 100644 GLIBC.cross-building
  13. create mode 100644 GLIBC.cross-testing
  14. diff --git a/GLIBC.cross-building b/GLIBC.cross-building
  15. new file mode 100644
  16. index 0000000000..e6e0da1aaf
  17. --- /dev/null
  18. +++ b/GLIBC.cross-building
  19. @@ -0,0 +1,383 @@
  20. + -*- mode: text -*-
  21. +
  22. + Cross-Compiling GLIBC
  23. + Jim Blandy <jimb@codesourcery.com>
  24. +
  25. +
  26. +Introduction
  27. +
  28. +Most GNU tools have a simple build procedure: you run their
  29. +'configure' script, and then you run 'make'. Unfortunately, the
  30. +process of cross-compiling the GNU C library is quite a bit more
  31. +involved:
  32. +
  33. +1) Build a cross-compiler, with certain facilities disabled.
  34. +
  35. +2) Configure the C library using the compiler you built in step 1).
  36. + Build a few of the C run-time object files, but not the rest of the
  37. + library. Install the library's header files and the run-time
  38. + object files, and create a dummy libc.so.
  39. +
  40. +3) Build a second cross-compiler, using the header files and object
  41. + files you installed in step 2.
  42. +
  43. +4) Configure, build, and install a fresh C library, using the compiler
  44. + built in step 3.
  45. +
  46. +5) Build a third cross-compiler, based on the C library built in step 4.
  47. +
  48. +The reason for this complexity is that, although GCC and the GNU C
  49. +library are distributed separately, they are not actually independent
  50. +of each other: GCC requires the C library's headers and some object
  51. +files to compile its own libraries, while the C library depends on
  52. +GCC's libraries. GLIBC includes features and bug fixes to the stock
  53. +GNU C library that simplify this process, but the fundamental
  54. +interdependency stands.
  55. +
  56. +In this document, we explain how to cross-compile an GLIBC/GCC pair
  57. +from source. Our intended audience is developers who are already
  58. +familiar with the GNU toolchain and comfortable working with
  59. +cross-development tools. While we do present a worked example to
  60. +accompany the explanation, for clarity's sake we do not cover many of
  61. +the options available to cross-toolchain users.
  62. +
  63. +
  64. +Preparation
  65. +
  66. +GLIBC requires recent versions of the GNU binutils, GCC, and the
  67. +Linux kernel. The web page <http://www.eglibc.org/prerequisites>
  68. +documents the current requirements, and lists patches needed for
  69. +certain target architectures. As of this writing, these build
  70. +instructions have been tested with binutils 2.22.51, GCC 4.6.2,
  71. +and Linux 3.1.
  72. +
  73. +First, let's set some variables, to simplify later commands. We'll
  74. +build GLIBC and GCC for an ARM target, known to the Linux kernel
  75. +as 'arm', and we'll do the build on an Intel x86_64 Linux box:
  76. +
  77. + $ build=x86_64-pc-linux-gnu
  78. + $ host=$build
  79. + $ target=arm-none-linux-gnueabi
  80. + $ linux_arch=arm
  81. +
  82. +We're using the aforementioned versions of Binutils, GCC, and Linux:
  83. +
  84. + $ binutilsv=binutils-2.22.51
  85. + $ gccv=gcc-4.6.2
  86. + $ linuxv=linux-3.1
  87. +
  88. +We're carrying out the entire process under '~/cross-build', which
  89. +contains unpacked source trees for binutils, gcc, and linux kernel,
  90. +along with GLIBC svn trunk (which can be checked-out with
  91. +'svn co http://www.eglibc.org/svn/trunk eglibc'):
  92. +
  93. + $ top=$HOME/cross-build/$target
  94. + $ src=$HOME/cross-build/src
  95. + $ ls $src
  96. + binutils-2.22.51 glibc gcc-4.6.2 linux-3.1
  97. +
  98. +We're going to place our build directories in a subdirectory 'obj',
  99. +we'll install the cross-development toolchain in 'tools', and we'll
  100. +place our sysroot (containing files to be installed on the target
  101. +system) in 'sysroot':
  102. +
  103. + $ obj=$top/obj
  104. + $ tools=$top/tools
  105. + $ sysroot=$top/sysroot
  106. +
  107. +
  108. +Binutils
  109. +
  110. +Configuring and building binutils for the target is straightforward:
  111. +
  112. + $ mkdir -p $obj/binutils
  113. + $ cd $obj/binutils
  114. + $ $src/$binutilsv/configure \
  115. + > --target=$target \
  116. + > --prefix=$tools \
  117. + > --with-sysroot=$sysroot
  118. + $ make
  119. + $ make install
  120. +
  121. +
  122. +The First GCC
  123. +
  124. +For our work, we need a cross-compiler targeting an ARM Linux
  125. +system. However, that configuration includes the shared library
  126. +'libgcc_s.so', which is compiled against the GLIBC headers (which we
  127. +haven't installed yet) and linked against 'libc.so' (which we haven't
  128. +built yet).
  129. +
  130. +Fortunately, there are configuration options for GCC which tell it not
  131. +to build 'libgcc_s.so'. The '--without-headers' option is supposed to
  132. +take care of this, but its implementation is incomplete, so you must
  133. +also configure with the '--with-newlib' option. While '--with-newlib'
  134. +appears to mean "Use the Newlib C library", its effect is to tell the
  135. +GCC build machinery, "Don't assume there is a C library available."
  136. +
  137. +We also need to disable some of the libraries that would normally be
  138. +built along with GCC, and specify that only the compiler for the C
  139. +language is needed.
  140. +
  141. +So, we create a build directory, configure, make, and install.
  142. +
  143. + $ mkdir -p $obj/gcc1
  144. + $ cd $obj/gcc1
  145. + $ $src/$gccv/configure \
  146. + > --target=$target \
  147. + > --prefix=$tools \
  148. + > --without-headers --with-newlib \
  149. + > --disable-shared --disable-threads --disable-libssp \
  150. + > --disable-libgomp --disable-libmudflap --disable-libquadmath \
  151. + > --disable-decimal-float --disable-libffi \
  152. + > --enable-languages=c
  153. + $ PATH=$tools/bin:$PATH make
  154. + $ PATH=$tools/bin:$PATH make install
  155. +
  156. +
  157. +Linux Kernel Headers
  158. +
  159. +To configure GLIBC, we also need Linux kernel headers in place.
  160. +Fortunately, the Linux makefiles have a target that installs them for
  161. +us. Since the process does modify the source tree a bit, we make a
  162. +copy first:
  163. +
  164. + $ cp -r $src/$linuxv $obj/linux
  165. + $ cd $obj/linux
  166. +
  167. +Now we're ready to install the headers into the sysroot:
  168. +
  169. + $ PATH=$tools/bin:$PATH \
  170. + > make headers_install \
  171. + > ARCH=$linux_arch CROSS_COMPILE=$target- \
  172. + > INSTALL_HDR_PATH=$sysroot/usr
  173. +
  174. +
  175. +GLIBC Headers and Preliminary Objects
  176. +
  177. +Using the cross-compiler we've just built, we can now configure GLIBC
  178. +well enough to install the headers and build the object files that the
  179. +full cross-compiler will need:
  180. +
  181. + $ mkdir -p $obj/glibc-headers
  182. + $ cd $obj/glibc-headers
  183. + $ BUILD_CC=gcc \
  184. + > CC=$tools/bin/$target-gcc \
  185. + > CXX=$tools/bin/$target-g++ \
  186. + > AR=$tools/bin/$target-ar \
  187. + > RANLIB=$tools/bin/$target-ranlib \
  188. + > $src/glibc/libc/configure \
  189. + > --prefix=/usr \
  190. + > --with-headers=$sysroot/usr/include \
  191. + > --build=$build \
  192. + > --host=$target \
  193. + > --disable-profile --without-gd --without-cvs \
  194. + > --enable-add-ons=nptl,libidn,../ports
  195. +
  196. +The option '--prefix=/usr' may look strange, but you should never
  197. +configure GLIBC with a prefix other than '/usr': in various places,
  198. +GLIBC's build system checks whether the prefix is '/usr', and does
  199. +special handling only if that is the case. Unless you use this
  200. +prefix, you will get a sysroot that does not use the standard Linux
  201. +directory layouts and cannot be used as a basis for the root
  202. +filesystem on your target system compatibly with normal GLIBC
  203. +installations.
  204. +
  205. +The '--with-headers' option tells GLIBC where the Linux headers have
  206. +been installed.
  207. +
  208. +The '--enable-add-ons=nptl,libidn,../ports' option tells GLIBC to look
  209. +for the listed glibc add-ons. Most notably the ports add-on (located
  210. +just above the libc sources in the GLIBC svn tree) is required to
  211. +support ARM targets.
  212. +
  213. +We can now use the 'install-headers' makefile target to install the
  214. +headers:
  215. +
  216. + $ make install-headers install_root=$sysroot \
  217. + > install-bootstrap-headers=yes
  218. +
  219. +The 'install_root' variable indicates where the files should actually
  220. +be installed; its value is treated as the parent of the '--prefix'
  221. +directory we passed to the configure script, so the headers will go in
  222. +'$sysroot/usr/include'. The 'install-bootstrap-headers' variable
  223. +requests special handling for certain tricky header files.
  224. +
  225. +Next, there are a few object files needed to link shared libraries,
  226. +which we build and install by hand:
  227. +
  228. + $ mkdir -p $sysroot/usr/lib
  229. + $ make csu/subdir_lib
  230. + $ cp csu/crt1.o csu/crti.o csu/crtn.o $sysroot/usr/lib
  231. +
  232. +Finally, 'libgcc_s.so' requires a 'libc.so' to link against. However,
  233. +since we will never actually execute its code, it doesn't matter what
  234. +it contains. So, treating '/dev/null' as a C source file, we produce
  235. +a dummy 'libc.so' in one step:
  236. +
  237. + $ $tools/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
  238. + > -o $sysroot/usr/lib/libc.so
  239. +
  240. +
  241. +The Second GCC
  242. +
  243. +With the GLIBC headers and selected object files installed, we can
  244. +now build a GCC that is capable of compiling GLIBC. We configure,
  245. +build, and install the second GCC, again building only the C compiler,
  246. +and avoiding libraries we won't use:
  247. +
  248. + $ mkdir -p $obj/gcc2
  249. + $ cd $obj/gcc2
  250. + $ $src/$gccv/configure \
  251. + > --target=$target \
  252. + > --prefix=$tools \
  253. + > --with-sysroot=$sysroot \
  254. + > --disable-libssp --disable-libgomp --disable-libmudflap \
  255. + > --disable-libffi --disable-libquadmath \
  256. + > --enable-languages=c
  257. + $ PATH=$tools/bin:$PATH make
  258. + $ PATH=$tools/bin:$PATH make install
  259. +
  260. +
  261. +GLIBC, Complete
  262. +
  263. +With the second compiler built and installed, we're now ready for the
  264. +full GLIBC build:
  265. +
  266. + $ mkdir -p $obj/glibc
  267. + $ cd $obj/glibc
  268. + $ BUILD_CC=gcc \
  269. + > CC=$tools/bin/$target-gcc \
  270. + > CXX=$tools/bin/$target-g++ \
  271. + > AR=$tools/bin/$target-ar \
  272. + > RANLIB=$tools/bin/$target-ranlib \
  273. + > $src/glibc/libc/configure \
  274. + > --prefix=/usr \
  275. + > --with-headers=$sysroot/usr/include \
  276. + > --with-kconfig=$obj/linux/scripts/kconfig \
  277. + > --build=$build \
  278. + > --host=$target \
  279. + > --disable-profile --without-gd --without-cvs \
  280. + > --enable-add-ons=nptl,libidn,../ports
  281. +
  282. +Note the additional '--with-kconfig' option. This tells GLIBC where to
  283. +find the host config tools used by the kernel 'make config' and 'make
  284. +menuconfig'. These tools can be re-used by GLIBC for its own 'make
  285. +*config' support, which will create 'option-groups.config' for you.
  286. +But first make sure those tools have been built by running some
  287. +dummy 'make *config' calls in the kernel directory:
  288. +
  289. + $ cd $obj/linux
  290. + $ PATH=$tools/bin:$PATH make config \
  291. + > ARCH=$linux_arch CROSS_COMPILE=$target- \
  292. + $ PATH=$tools/bin:$PATH make menuconfig \
  293. + > ARCH=$linux_arch CROSS_COMPILE=$target- \
  294. +
  295. +Now we can configure and build the full GLIBC:
  296. +
  297. + $ cd $obj/glibc
  298. + $ PATH=$tools/bin:$PATH make defconfig
  299. + $ PATH=$tools/bin:$PATH make menuconfig
  300. + $ PATH=$tools/bin:$PATH make
  301. + $ PATH=$tools/bin:$PATH make install install_root=$sysroot
  302. +
  303. +At this point, we have a complete GLIBC installation in '$sysroot',
  304. +with header files, library files, and most of the C runtime startup
  305. +files in place.
  306. +
  307. +
  308. +The Third GCC
  309. +
  310. +Finally, we recompile GCC against this full installation, enabling
  311. +whatever languages and libraries we would like to use:
  312. +
  313. + $ mkdir -p $obj/gcc3
  314. + $ cd $obj/gcc3
  315. + $ $src/$gccv/configure \
  316. + > --target=$target \
  317. + > --prefix=$tools \
  318. + > --with-sysroot=$sysroot \
  319. + > --enable-__cxa_atexit \
  320. + > --disable-libssp --disable-libgomp --disable-libmudflap \
  321. + > --enable-languages=c,c++
  322. + $ PATH=$tools/bin:$PATH make
  323. + $ PATH=$tools/bin:$PATH make install
  324. +
  325. +The '--enable-__cxa_atexit' option tells GCC what sort of C++
  326. +destructor support to expect from the C library; it's required with
  327. +GLIBC.
  328. +
  329. +And since GCC's installation process isn't designed to help construct
  330. +sysroot trees, we must manually copy certain libraries into place in
  331. +the sysroot.
  332. +
  333. + $ cp -d $tools/$target/lib/libgcc_s.so* $sysroot/lib
  334. + $ cp -d $tools/$target/lib/libstdc++.so* $sysroot/usr/lib
  335. +
  336. +
  337. +Trying Things Out
  338. +
  339. +At this point, '$tools' contains a cross toolchain ready to use
  340. +the GLIBC installation in '$sysroot':
  341. +
  342. + $ cat > hello.c <<EOF
  343. + > #include <stdio.h>
  344. + > int
  345. + > main (int argc, char **argv)
  346. + > {
  347. + > puts ("Hello, world!");
  348. + > return 0;
  349. + > }
  350. + > EOF
  351. + $ $tools/bin/$target-gcc -Wall hello.c -o hello
  352. + $ cat > c++-hello.cc <<EOF
  353. + > #include <iostream>
  354. + > int
  355. + > main (int argc, char **argv)
  356. + > {
  357. + > std::cout << "Hello, C++ world!" << std::endl;
  358. + > return 0;
  359. + > }
  360. + > EOF
  361. + $ $tools/bin/$target-g++ -Wall c++-hello.cc -o c++-hello
  362. +
  363. +
  364. +We can use 'readelf' to verify that these are indeed executables for
  365. +our target, using our dynamic linker:
  366. +
  367. + $ $tools/bin/$target-readelf -hl hello
  368. + ELF Header:
  369. + ...
  370. + Type: EXEC (Executable file)
  371. + Machine: ARM
  372. +
  373. + ...
  374. + Program Headers:
  375. + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
  376. + PHDR 0x000034 0x10000034 0x10000034 0x00100 0x00100 R E 0x4
  377. + INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1
  378. + [Requesting program interpreter: /lib/ld-linux.so.3]
  379. + LOAD 0x000000 0x00008000 0x00008000 0x0042c 0x0042c R E 0x8000
  380. + ...
  381. +
  382. +Looking at the dynamic section of the installed 'libgcc_s.so', we see
  383. +that the 'NEEDED' entry for the C library does include the '.6'
  384. +suffix, indicating that was linked against our fully build GLIBC, and
  385. +not our dummy 'libc.so':
  386. +
  387. + $ $tools/bin/$target-readelf -d $sysroot/lib/libgcc_s.so.1
  388. + Dynamic section at offset 0x1083c contains 24 entries:
  389. + Tag Type Name/Value
  390. + 0x00000001 (NEEDED) Shared library: [libc.so.6]
  391. + 0x0000000e (SONAME) Library soname: [libgcc_s.so.1]
  392. + ...
  393. +
  394. +
  395. +And on the target machine, we can run our programs:
  396. +
  397. + $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \
  398. + > ./hello
  399. + Hello, world!
  400. + $ $sysroot/lib/ld.so.1 --library-path $sysroot/lib:$sysroot/usr/lib \
  401. + > ./c++-hello
  402. + Hello, C++ world!
  403. diff --git a/GLIBC.cross-testing b/GLIBC.cross-testing
  404. new file mode 100644
  405. index 0000000000..b67b468466
  406. --- /dev/null
  407. +++ b/GLIBC.cross-testing
  408. @@ -0,0 +1,205 @@
  409. + -*- mode: text -*-
  410. +
  411. + Cross-Testing With GLIBC
  412. + Jim Blandy <jimb@codesourcery.com>
  413. +
  414. +
  415. +Introduction
  416. +
  417. +Developers writing software for embedded systems often use a desktop
  418. +or other similarly capable computer for development, but need to run
  419. +tests on the embedded system, or perhaps on a simulator. When
  420. +configured for cross-compilation, the stock GNU C library simply
  421. +disables running tests altogether: the command 'make tests' builds
  422. +test programs, but does not run them. GLIBC, however, provides
  423. +facilities for compiling tests and generating data files on the build
  424. +system, but running the test programs themselves on a remote system or
  425. +simulator.
  426. +
  427. +
  428. +Test environment requirements
  429. +
  430. +The test environment must meet certain conditions for GLIBC's
  431. +cross-testing facilities to work:
  432. +
  433. +- Shared filesystems. The 'build' system, on which you configure and
  434. + compile GLIBC, and the 'host' system, on which you intend to run
  435. + GLIBC, must share a filesystem containing the GLIBC build and
  436. + source trees. Files must appear at the same paths on both systems.
  437. +
  438. +- Remote-shell like invocation. There must be a way to run a program
  439. + on the host system from the build system, passing it properly quoted
  440. + command-line arguments, setting environment variables, and
  441. + inheriting the caller's standard input and output.
  442. +
  443. +
  444. +Usage
  445. +
  446. +To use GLIBC's cross-testing support, provide values for the
  447. +following Make variables when you invoke 'make':
  448. +
  449. +- cross-test-wrapper
  450. +
  451. + This should be the name of the cross-testing wrapper command, along
  452. + with any arguments.
  453. +
  454. +- cross-localedef
  455. +
  456. + This should be the name of a cross-capable localedef program, like
  457. + that included in the GLIBC 'localedef' module, along with any
  458. + arguments needed.
  459. +
  460. +These are each explained in detail below.
  461. +
  462. +
  463. +The Cross-Testing Wrapper
  464. +
  465. +To run test programs reliably, the stock GNU C library takes care to
  466. +ensure that test programs use the newly compiled dynamic linker and
  467. +shared libraries, and never the host system's installed libraries. To
  468. +accomplish this, it runs the tests by explicitly invoking the dynamic
  469. +linker from the build tree, passing it a list of build tree
  470. +directories to search for shared libraries, followed by the name of
  471. +the executable to run and its arguments.
  472. +
  473. +For example, where one might normally run a test program like this:
  474. +
  475. + $ ./tst-foo arg1 arg2
  476. +
  477. +the GNU C library might run that program like this:
  478. +
  479. + $ $objdir/elf/ld-linux.so.3 --library-path $objdir \
  480. + ./tst-foo arg1 arg2
  481. +
  482. +(where $objdir is the path to the top of the build tree, and the
  483. +trailing backslash indicates a continuation of the command). In other
  484. +words, each test program invocation is 'wrapped up' inside an explicit
  485. +invocation of the dynamic linker, which must itself execute the test
  486. +program, having loaded shared libraries from the appropriate
  487. +directories.
  488. +
  489. +To support cross-testing, GLIBC allows the developer to optionally
  490. +set the 'cross-test-wrapper' Make variable to another wrapper command,
  491. +to which it passes the entire dynamic linker invocation shown above as
  492. +arguments. For example, if the developer supplies a wrapper of
  493. +'my-wrapper hostname', then GLIBC would run the test above as
  494. +follows:
  495. +
  496. + $ my-wrapper hostname \
  497. + $objdir/elf/ld-linux.so.3 --library-path $objdir \
  498. + ./tst-foo arg1 arg2
  499. +
  500. +The 'my-wrapper' command is responsible for executing the command
  501. +given on the host system.
  502. +
  503. +Since tests are run in varying directories, the wrapper should either
  504. +be in your command search path, or 'cross-test-wrapper' should give an
  505. +absolute path for the wrapper.
  506. +
  507. +The wrapper must meet several requirements:
  508. +
  509. +- It must preserve the current directory. As explained above, the
  510. + build directory tree must be visible on both the build and host
  511. + systems, at the same path. The test wrapper must ensure that the
  512. + current directory it inherits is also inherited by the dynamic
  513. + linker (and thus the test program itself).
  514. +
  515. +- It must preserve environment variables' values. Many GLIBC tests
  516. + set environment variables for test runs; in native testing, it
  517. + invokes programs like this:
  518. +
  519. + $ GCONV_PATH=$objdir/iconvdata \
  520. + $objdir/elf/ld-linux.so.3 --library-path $objdir \
  521. + ./tst-foo arg1 arg2
  522. +
  523. + With the cross-testing wrapper, that invocation becomes:
  524. +
  525. + $ GCONV_PATH=$objdir/iconvdata \
  526. + my-wrapper hostname \
  527. + $objdir/elf/ld-linux.so.3 --library-path $objdir \
  528. + ./tst-foo arg1 arg2
  529. +
  530. + Here, 'my-wrapper' must ensure that the value it sees for
  531. + 'GCONV_PATH' will be seen by the dynamic linker, and thus 'tst-foo'
  532. + itself. (The wrapper supplied with GLIBC simply preserves the
  533. + values of *all* enviroment variables, with a fixed set of
  534. + exceptions.)
  535. +
  536. + If your wrapper is a shell script, take care to correctly propagate
  537. + environment variables whose values contain spaces and shell
  538. + metacharacters.
  539. +
  540. +- It must pass the command's arguments, unmodified. The arguments
  541. + seen by the test program should be exactly those seen by the wrapper
  542. + (after whatever arguments are given to the wrapper itself). The
  543. + GLIBC test framework performs all needed shell word splitting and
  544. + expansion (wildcard expansion, parameter substitution, and so on)
  545. + before invoking the wrapper; further expansion may break the tests.
  546. +
  547. +
  548. +The 'cross-test-ssh.sh' script
  549. +
  550. +If you want to use 'ssh' (or something sufficiently similar) to run
  551. +test programs on your host system, GLIBC includes a shell script,
  552. +'scripts/cross-test-ssh.sh', which you can use as your wrapper
  553. +command. This script takes care of setting the test command's current
  554. +directory, propagating environment variable values, and carrying
  555. +command-line arguments, all across an 'ssh' connection. You may even
  556. +supply an alternative to 'ssh' on the command line, if needed.
  557. +
  558. +For more details, pass 'cross-test-ssh.sh' the '--help' option.
  559. +
  560. +
  561. +The Cross-Compiling Locale Definition Command
  562. +
  563. +Some GLIBC tests rely on locales generated especially for the test
  564. +process. In a native configuration, these tests simply run the
  565. +'localedef' command built by the normal GLIBC build process,
  566. +'locale/localedef', to process and install their locales. However, in
  567. +a cross-compiling configuration, this 'localedef' is built for the
  568. +host system, not the build system, and since it requires quite a bit
  569. +of memory to run (we have seen it fail on systems with 64MiB of
  570. +memory), it may not be practical to run it on the host system.
  571. +
  572. +If set, GLIBC uses the 'cross-localedef' Make variable as the command
  573. +to run on the build system to process and install locales. The
  574. +localedef program built from the GLIBC 'localedef' module is
  575. +suitable.
  576. +
  577. +The value of 'cross-localedef' may also include command-line arguments
  578. +to be passed to the program; if you are using GLIBC's 'localedef',
  579. +you may include endianness and 'uint32_t' alignment arguments here.
  580. +
  581. +
  582. +Example
  583. +
  584. +In developing GLIBC's cross-testing facility, we invoked 'make' with
  585. +the following script:
  586. +
  587. + #!/bin/sh
  588. +
  589. + srcdir=...
  590. + test_hostname=...
  591. + localedefdir=...
  592. + cross_gxx=...-g++
  593. +
  594. + wrapper="$srcdir/scripts/cross-test-ssh.sh $test_hostname"
  595. + localedef="$localedefdir/localedef --little-endian --uint32-align=4"
  596. +
  597. + make cross-test-wrapper="$wrapper" \
  598. + cross-localedef="$localedef" \
  599. + CXX="$cross_gxx" \
  600. + "$@"
  601. +
  602. +
  603. +Other Cross-Testing Concerns
  604. +
  605. +Here are notes on some other issues which you may encounter in running
  606. +the GLIBC tests in a cross-compiling environment:
  607. +
  608. +- Some tests require a C++ cross-compiler; you should set the 'CXX'
  609. + Make variable to the name of an appropriate cross-compiler.
  610. +
  611. +- Some tests require access to libstdc++.so.6 and libgcc_s.so.1; we
  612. + simply place copies of these libraries in the top GLIBC build
  613. + directory.