Bug 683975 - swap the glibc and gcc build order during stage2. r=rail.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Mon, 27 Feb 2012 14:34:47 -0500
changeset 87859 c75d0a91f7edd41de26d4539d66cef65790df184
parent 87858 caa24e77612d81dc7188f32ca6bf23adfba6c20d
child 87860 5176e915dfd91d5d53ad10b4dc0cb7c9dde6d89a
push id22160
push usermbrubeck@mozilla.com
push dateTue, 28 Feb 2012 17:21:33 +0000
treeherdermozilla-central@dde4e0089a18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrail
bugs683975
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 683975 - swap the glibc and gcc build order during stage2. r=rail.
build/unix/build-toolchain/build-gcc.py
--- a/build/unix/build-toolchain/build-gcc.py
+++ b/build/unix/build-toolchain/build-gcc.py
@@ -94,16 +94,43 @@ def build_linux_headers_aux(inst_dir):
                                "headers_install"])
     shutil.move(linux_source_dir + "/dest", inst_dir)
 
 def build_linux_headers(inst_dir):
     def f():
         build_linux_headers_aux(inst_dir)
     with_env({"PATH" : aux_inst_dir + "/bin:%s" % os.environ["PATH"]}, f)
 
+def build_gcc(stage_dir, is_stage_one):
+    gcc_build_dir = stage_dir + '/gcc'
+    tool_inst_dir = stage_dir + '/inst'
+    lib_inst_dir = stage_dir + '/libinst'
+    gcc_configure_args = ["--prefix=%s" % tool_inst_dir,
+                          "--enable-__cxa_atexit",
+                          "--with-gmp=%s" % lib_inst_dir,
+                          "--with-mpfr=%s" % lib_inst_dir,
+                          "--with-mpc=%s" % lib_inst_dir,
+                          "--enable-languages=c,c++",
+                          "--disable-multilib",
+                          "--disable-bootstrap"]
+    if is_stage_one:
+        # We build the stage1 gcc without shared libraries. Otherwise its
+        # libgcc.so would depend on the system libc.so, which causes problems
+        # when it tries to use that libgcc.so and the libc we are about to
+        # build.
+        gcc_configure_args.append("--disable-shared")
+
+    build_package(gcc_source_dir, gcc_build_dir, gcc_configure_args)
+
+    if is_stage_one:
+        # The glibc build system uses -lgcc_eh, but at least in this setup
+        # libgcc.a has all it needs.
+        d = tool_inst_dir + "/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/"
+        os.symlink(d + "libgcc.a", d + "libgcc_eh.a")
+
 def build_one_stage(env, stage_dir, is_stage_one):
     def f():
         build_one_stage_aux(stage_dir, is_stage_one)
     with_env(env, f)
 
 def build_one_stage_aux(stage_dir, is_stage_one):
     os.mkdir(stage_dir)
 
@@ -124,43 +151,28 @@ def build_one_stage_aux(stage_dir, is_st
 
     tool_inst_dir = stage_dir + '/inst'
     build_linux_headers(tool_inst_dir)
 
     binutils_build_dir = stage_dir + '/binutils'
     build_package(binutils_source_dir, binutils_build_dir,
                   ["--prefix=%s" % tool_inst_dir])
 
-    gcc_build_dir = stage_dir + '/gcc'
-    gcc_configure_args = ["--prefix=%s" % tool_inst_dir,
-                          "--enable-__cxa_atexit",
-                          "--with-gmp=%s" % lib_inst_dir,
-                          "--with-mpfr=%s" % lib_inst_dir,
-                          "--with-mpc=%s" % lib_inst_dir,
-                          "--enable-languages=c,c++",
-                          "--disable-multilib",
-                          "--disable-bootstrap"]
+    # During stage one we have to build gcc first, this glibc doesn't even
+    # build with gcc 4.6. During stage two, we have to build glibc first.
+    # The problem is that libstdc++ is built with xgcc and if glibc has
+    # not been built yet xgcc will use the system one.
     if is_stage_one:
-        # We build the stage1 gcc without shared libraries. Otherwise its
-        # libgcc.so would depend on the system libc.so, which causes problems
-        # when it tries to use that libgcc.so and the libc we are about to
-        # build.
-        gcc_configure_args.append("--disable-shared")
-
-    build_package(gcc_source_dir, gcc_build_dir, gcc_configure_args)
-
-    if is_stage_one:
-        # The glibc build system uses -lgcc_eh, but at least in this setup
-        # libgcc.a has all it needs.
-        d = tool_inst_dir + "/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/"
-        os.symlink(d + "libgcc.a", d + "libgcc_eh.a")
-
-    build_glibc({"CC"  : tool_inst_dir + "/bin/gcc",
-                 "CXX" : tool_inst_dir + "/bin/g++"},
-                stage_dir, tool_inst_dir)
+        build_gcc(stage_dir, is_stage_one)
+        build_glibc({"CC"  : tool_inst_dir + "/bin/gcc",
+                     "CXX" : tool_inst_dir + "/bin/g++"},
+                    stage_dir, tool_inst_dir)
+    else:
+        build_glibc({}, stage_dir, tool_inst_dir)
+        build_gcc(stage_dir, is_stage_one)
 
 def build_tar_package(tar, name, base, directory):
     name = os.path.realpath(name)
     run_in(base, [tar, "-cf", name, "--mtime=2012-01-01", "--owner=root",
                   directory])
 
 ##############################################