daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Jan 15th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 5.5. GCC-4.7.1 - Pass 1
  2. The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.
  3. Approximate build time: 5.5 SBU
  4. Required disk space: 1.4 GB
  5. 5.5.1. Installation of Cross GCC
  6. GCC now requires the GMP, MPFR and MPC packages. As these packages may not be included in your host
  7. distribution, they will be built with GCC. Unpack each package into the GCC source directory and rename the
  8. resulting directories so the GCC build procedures will automatically use them:
  9. Note
  10. There are frequent misunderstandings about this chapter. The procedures are the same as every other chapter
  11. as explained earlier (Package build instructions). First extract the gcc tarball from the sources directory and
  12. then change to the directory created. Only then should you proceed with the instructions below.
  13. tar -Jxf ../mpfr-3.1.1.tar.xz
  14. mv -v mpfr-3.1.1 mpfr
  15. tar -Jxf ../gmp-5.0.5.tar.xz
  16. mv -v gmp-5.0.5 gmp
  17. tar -zxf ../mpc-1.0.tar.gz
  18. mv -v mpc-1.0 mpc
  19. The following command will change the location of GCC's default dynamic linker to use the one installed in / tools.
  20. It also removes / usr/ include from GCC's include search path. Issue:
  21. for file in \
  22. $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
  23. do
  24. cp -uv $file{,.orig}
  25. sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
  26. -e 's@/usr@/tools@g' $file.orig > $file
  27. echo '
  28. #undef STANDARD_STARTFILE_PREFIX_1
  29. #undef STANDARD_STARTFILE_PREFIX_2
  30. #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
  31. #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
  32. touch $file.orig
  33. done
  34. In case the above seems hard to follow, let's break it down a bit. First we find all the files under the gcc/ config
  35. directory that are named either linux. h, linux64. h or sysv4. h. For each file found, we copy it to a file of the
  36. same name but with an added suffix of “.orig”. Then the first sed expression prepends “/tools” to every instance of
  37. “/lib/ld”, “/lib64/ld” or “/lib32/ld”, while the second one replaces hard-coded instances of “/usr”. Next, we add our
  38. define statements which alter the default startfile prefix to the end of the file. Note that the trailing “/” in “/tools/lib/”
  39. is required. Finally, we use touch to update the timestamp on the copied files. When used in conjunction with cp -u,
  40. this prevents unexpected changes to the original files in case the commands are inadvertently run twice.
  41. Linux From Scratch - Version 7.2
  42. 39
  43. GCC doesn't detect stack protection correctly, which causes problems for the build of Glibc-2.16.0, so fix that by
  44. issuing the following command:
  45. sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
  46. The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:
  47. mkdir -v ../gcc-build
  48. cd ../gcc-build
  49. Prepare GCC for compilation:
  50. ../gcc-4.7.1/configure \
  51. --target=$LFS_TGT \
  52. --prefix=/tools \
  53. --with-sysroot=$LFS \
  54. --with-newlib \
  55. --without-headers \
  56. --with-local-prefix=/tools \
  57. --with-native-system-header-dir=/tools/include \
  58. --disable-nls \
  59. --disable-shared \
  60. --disable-multilib \
  61. --disable-decimal-float \
  62. --disable-threads \
  63. --disable-libmudflap \
  64. --disable-libssp \
  65. --disable-libgomp \
  66. --disable-libquadmath \
  67. --enable-languages=c \
  68. --with-mpfr-include=$(pwd)/../gcc-4.7.1/mpfr/src \
  69. --with-mpfr-lib=$(pwd)/mpfr/src/.libs
  70. The meaning of the configure options:
  71. --with-newlib
  72. Since a working C library is not yet available, this ensures that the inhibit_libc constant is defined when building
  73. libgcc. This prevents the compiling of any code that requires libc support.
  74. --without-headers
  75. When creating a complete cross-compiler, GCC requires standard headers compatible with the target system.
  76. For our purposes these headers will not be needed. This switch prevents GCC from looking for them.
  77. --with-local-prefix=/tools
  78. The local prefix is the location in the system that GCC will search for locally installed include files. The default
  79. is / usr/ local. Setting this to / tools helps keep the host location of / usr/ local out of this GCC's
  80. search path.
  81. --with-native-system-header-dir=/tools/include
  82. By default GCC searches / usr/ include for system headers. In conjunction with the sysroot switch, this
  83. would translate normally to $LFS/ usr/ include. However the headers that will be installed in the next two
  84. Linux From Scratch - Version 7.2
  85. 40
  86. sections will go to $LFS/ tools/ include. This switch ensures that gcc will find them correctly. In the
  87. second pass of GCC, this same switch will ensure that no headers from the host system are found.
  88. --disable-shared
  89. This switch forces GCC to link its internal libraries statically. We do this to avoid possible issues with the host
  90. system.
  91. --disable-decimal-float, --disable-threads, --disable-libmudflap,
  92. --disable-libssp, --disable-libgomp, --disable-libquadmath
  93. These switches disable support for the decimal floating point extension, threading, libmudflap, libssp and
  94. libgomp and libquadmath respectively. These features will fail to compile when building a cross-compiler and
  95. are not necessary for the task of cross-compiling the temporary libc.
  96. --disable-multilib
  97. On x86_64, LFS does not yet support a multilib configuration. This switch is harmless for x86.
  98. --enable-languages=c
  99. This option ensures that only the C compiler is built. This is the only language needed now.
  100. Compile GCC by running:
  101. make
  102. Compilation is now complete. At this point, the test suite would normally be run, but, as mentioned before, the test
  103. suite framework is not in place yet. The benefits of running the tests at this point are minimal since the programs
  104. from this first pass will soon be replaced.
  105. Install the package:
  106. make install
  107. Using - - disable- shared means that the libgcc_ eh. a file isn't created and installed. The Glibc package
  108. depends on this library as it uses - lgcc_ eh within its build system. This dependency can be satisfied by creating a
  109. symlink to libgcc. a, since that file will end up containing the objects normally contained in libgcc_ eh. a:
  110. ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
  111. Details on this package are located in Section 6.17.2, “Contents of GCC.”
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top