接著 , 要進行主要的 GCC Compiler 了 !!
首先要 Build 出 第一階段的 Cross Compiler. 這個階段的 Cross Compiler 不需要 glibc !!
當然才有辦法用這個 Cross Compiler 進行 eglibc / glibc 的 Compiler !!
GCC 的文件說明 , 建議在 Source Code 外部編譯 , 在我的Source Tree 中 先準備一個 GCC 的Source , 並且進行 下列的 patch :
Submitted By: Jim Gifford (jim at cross-lfs dot org)
Date: 07-22-2009
Initial Package Version: 4.4.1
Origin: Upstream
Upstream Status: Applied
Description: This is a branch update for gcc-4.4.1, and should be
rechecked periodically.
This patch was made from Revision # 149965.
diff -Naur gcc-4.4.1.orig/gcc/resource.c gcc-4.4.1/gcc/resource.c
--- gcc-4.4.1.orig/gcc/resource.c 2009-05-21 16:17:37.000000000 -0700
+++ gcc-4.4.1/gcc/resource.c 2009-07-22 16:22:24.000000000 -0700
@@ -945,10 +945,11 @@
/* If we found a basic block, get the live registers from it and update
them with anything set or killed between its start and the insn before
- TARGET. Otherwise, we must assume everything is live. */
+ TARGET; this custom life analysis is really about registers so we need
+ to use the LR problem. Otherwise, we must assume everything is live. */
if (b != -1)
{
- regset regs_live = df_get_live_in (BASIC_BLOCK (b));
+ regset regs_live = DF_LR_IN (BASIC_BLOCK (b));
rtx start_insn, stop_insn;
/* Compute hard regs live at start of block. */
@@ -1052,7 +1053,7 @@
{
HARD_REG_SET extra_live;
- REG_SET_TO_HARD_REG_SET (extra_live, df_get_live_in (bb));
+ REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb));
IOR_HARD_REG_SET (current_live_regs, extra_live);
}
}
diff -Naur gcc-4.4.1.orig/gcc/testsuite/gcc.c-torture/compile/pr40321.c gcc-4.4.1/gcc/testsuite/gcc.c-torture/compile/pr40321.c
--- gcc-4.4.1.orig/gcc/testsuite/gcc.c-torture/compile/pr40321.c 1969-12-31 16:00:00.000000000 -0800
+++ gcc-4.4.1/gcc/testsuite/gcc.c-torture/compile/pr40321.c 2009-07-22 07:45:21.000000000 -0700
@@ -0,0 +1,12 @@
+struct X { int flag; int pos; };
+int foo(struct X *a, struct X *b)
+{
+ while (1)
+ {
+ if (a->flag)
+ break;
+ ({ struct X *tmp = a; a = b; b = tmp; });
+ }
+
+ return a->pos + b->pos;
+}
diff -Naur gcc-4.4.1.orig/gcc/testsuite/g++.dg/torture/pr40321.C gcc-4.4.1/gcc/testsuite/g++.dg/torture/pr40321.C
--- gcc-4.4.1.orig/gcc/testsuite/g++.dg/torture/pr40321.C 1969-12-31 16:00:00.000000000 -0800
+++ gcc-4.4.1/gcc/testsuite/g++.dg/torture/pr40321.C 2009-07-22 07:45:21.000000000 -0700
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+
+struct VectorD2
+{
+ VectorD2() : x(0), y(0) { }
+ VectorD2(int _x, int _y) : x(_x), y(_y) { }
+ int x, y;
+ int GetLength2() const { return x*x + y*y; };
+ VectorD2 operator+(const VectorD2 vec) const {
+ return VectorD2(x+vec.x,y+vec.y);
+ }
+};
+struct Shape
+{
+ enum Type { ST_RECT, ST_CIRCLE } type;
+ VectorD2 pos;
+ VectorD2 radius;
+ bool CollisionWith(const Shape& s) const;
+};
+bool Shape::CollisionWith(const Shape& s) const
+{
+ if(type == ST_CIRCLE && s.type == ST_RECT)
+ return s.CollisionWith(*this);
+ return (pos + s.pos).GetLength2() < (radius + s.radius).GetLength2();
+}
diff -Naur gcc-4.4.1.orig/gcc/tree-ssa-pre.c gcc-4.4.1/gcc/tree-ssa-pre.c
--- gcc-4.4.1.orig/gcc/tree-ssa-pre.c 2009-02-20 07:20:38.000000000 -0800
+++ gcc-4.4.1/gcc/tree-ssa-pre.c 2009-07-22 07:45:21.000000000 -0700
@@ -3507,11 +3507,7 @@
}
-/* Add OP to EXP_GEN (block), and possibly to the maximal set if it is
- not defined by a phi node.
- PHI nodes can't go in the maximal sets because they are not in
- TMP_GEN, so it is possible to get into non-monotonic situations
- during ANTIC calculation, because it will *add* bits. */
+/* Add OP to EXP_GEN (block), and possibly to the maximal set. */
static void
add_to_exp_gen (basic_block block, tree op)
@@ -3523,9 +3519,7 @@
return;
result = get_or_alloc_expr_for_name (op);
bitmap_value_insert_into_set (EXP_GEN (block), result);
- if (TREE_CODE (op) != SSA_NAME
- || gimple_code (SSA_NAME_DEF_STMT (op)) != GIMPLE_PHI)
- bitmap_value_insert_into_set (maximal_set, result);
+ bitmap_value_insert_into_set (maximal_set, result);
}
}
@@ -3544,6 +3538,20 @@
add_to_value (get_expr_value_id (e), e);
bitmap_insert_into_set (PHI_GEN (block), e);
bitmap_value_insert_into_set (AVAIL_OUT (block), e);
+ if (!in_fre)
+ {
+ unsigned i;
+ for (i = 0; i < gimple_phi_num_args (phi); ++i)
+ {
+ tree arg = gimple_phi_arg_def (phi, i);
+ if (TREE_CODE (arg) == SSA_NAME)
+ {
+ e = get_or_alloc_expr_for_name (arg);
+ add_to_value (get_expr_value_id (e), e);
+ bitmap_value_insert_into_set (maximal_set, e);
+ }
+ }
+ }
}
}
@@ -4254,11 +4262,12 @@
FOR_ALL_BB (bb)
{
print_bitmap_set (dump_file, EXP_GEN (bb), "exp_gen", bb->index);
- print_bitmap_set (dump_file, TMP_GEN (bb), "tmp_gen",
- bb->index);
- print_bitmap_set (dump_file, AVAIL_OUT (bb), "avail_out",
- bb->index);
+ print_bitmap_set (dump_file, PHI_GEN (bb), "phi_gen", bb->index);
+ print_bitmap_set (dump_file, TMP_GEN (bb), "tmp_gen", bb->index);
+ print_bitmap_set (dump_file, AVAIL_OUT (bb), "avail_out", bb->index);
}
+
+ print_bitmap_set (dump_file, maximal_set, "maximal", 0);
}
/* Insert can get quite slow on an incredibly large number of basic
diff -Naur gcc-4.4.1.orig/gcc/version.c gcc-4.4.1/gcc/version.c
--- gcc-4.4.1.orig/gcc/version.c 2007-08-21 08:35:30.000000000 -0700
+++ gcc-4.4.1/gcc/version.c 2009-07-22 17:04:03.000000000 -0700
@@ -14,4 +14,4 @@
Makefile. */
const char version_string[] = BASEVER DATESTAMP DEVPHASE REVISION;
-const char pkgversion_string[] = PKGVERSION;
+const char pkgversion_string[] = "(GCC for Cross-LFS 4.4.1.20090722) ";
diff -Naur gcc-4.4.1.orig/libstdc++-v3/include/std/valarray gcc-4.4.1/libstdc++-v3/include/std/valarray
--- gcc-4.4.1.orig/libstdc++-v3/include/std/valarray 2009-04-09 16:23:07.000000000 -0700
+++ gcc-4.4.1/libstdc++-v3/include/std/valarray 2009-07-22 03:25:53.000000000 -0700
@@ -1,7 +1,7 @@
// The template and inlines for the -*- C++ -*- valarray class.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2009
+// 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -647,7 +647,7 @@
template
inline
valarray<_Tp>::valarray(initializer_list<_Tp> __l)
- : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size()))
+ : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size()))
{ std::__valarray_copy_construct (__l.begin(), __l.end(), _M_data); }
#endif
@@ -681,6 +681,7 @@
{
_GLIBCXX_DEBUG_ASSERT(_M_size == __l.size());
std::__valarray_copy(__l.begin(), __l.size(), _M_data);
+ return *this;
}
#endif
接著就可以進行 Compiler GCC Stage 1 了 :
A. 進行 Configure.
AR=ar LDFLAGS="-Wl,-rpath=${PREFIX}/$(TOOLCHAIN_DIR)/lib" \
$(SRC_VERSION)/configure \
--prefix=$(PREFIX)/$(TOOLCHAIN_DIR) \
--build=$(CLFS_HOST) --host=$(CLFS_HOST) --target=$(CLFS_TARGET) \
--with-sysroot=$(SYSROOT_PATH) \
--with-gmp=$(PREFIX)/$(TOOLCHAIN_DIR) \
--with-mpfr=$(PREFIX)/$(TOOLCHAIN_DIR) \
--with-ppl=$(PREFIX)/$(TOOLCHAIN_DIR) \
--with-cloog=$(PREFIX)/$(TOOLCHAIN_DIR) \
--with-newlib \
--without-headers \
--disable-multilib --disable-nls --disable-decimal-float \
--disable-libgomp --disable-libmudflap --disable-libssp \
--disable-shared --disable-threads \
--enable-languages="c"
其中要指定 -Wl,-rpath=${PREFIX}/$(TOOLCHAIN_DIR)/lib , rpath 是告訴 Compiler 將來 Run Time 時候要到哪去 載 so file . 如果妹有這個設定 , 將來 run time 時候會到 /lib 下尋找 so lib . 也就是說 , 將來這個 ToolChain 要固定 資料夾位置 , 不能任意換位置 .
B . make all-gcc all-target-libgcc
make 過程 , 我們只需要 gcc 和 libgcc 就好 , 其它的不 make .
C. make install-gcc install-target-libgcc
一樣只要 install gcc 和 libgcc 就好 ..
這樣就完成第一階段的 GCC Cross Compiler 了 ~~~~