diff --git a/build/unix/build-toolchain/build-gcc.py b/build/unix/build-toolchain/build-gcc.py index 10b98c8a9210..3be28a2c5fdb 100755 --- a/build/unix/build-toolchain/build-gcc.py +++ b/build/unix/build-toolchain/build-gcc.py @@ -45,9 +45,33 @@ def build_tar(base_dir, tar_inst_dir): build_package(tar_source_dir, tar_build_dir, ["--prefix=%s" % tar_inst_dir]) -def build_one_stage(env, stage_dir): +def with_env(env, f): old_env = os.environ.copy() os.environ.update(env) + f() + os.environ.clear() + os.environ.update(old_env) + +def build_glibc(env, stage_dir, inst_dir): + def f(): + build_glibc_aux(stage_dir, inst_dir) + with_env(env, f) + +def build_glibc_aux(stage_dir, inst_dir): + glibc_build_dir = stage_dir + '/glibc' + build_package(glibc_source_dir, glibc_build_dir, + ["--disable-profile", + "--enable-add-ons=nptl", + "--without-selinux", + "--enable-kernel=2.6.18", + "--prefix=%s" % inst_dir]) + +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) lib_inst_dir = stage_dir + '/libinst' @@ -71,25 +95,22 @@ def build_one_stage(env, stage_dir): build_package(binutils_source_dir, binutils_build_dir, ["--prefix=%s" % tool_inst_dir]) - glibc_build_dir = stage_dir + '/glibc' - build_package(glibc_source_dir, glibc_build_dir, - ["--disable-profile", - "--enable-add-ons=nptl", - "--without-selinux", - "--enable-kernel=2.6.25", - "--prefix=%s" % tool_inst_dir]) - gcc_build_dir = stage_dir + '/gcc' - build_package(gcc_source_dir, gcc_build_dir, - ["--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-bootstrap"]) - os.environ.clear() - os.environ.update(old_env) + 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, + "--disable-bootstrap"] + if is_stage_one: + gcc_configure_args.append("--enable-languages=c") + else: + gcc_configure_args.append("--enable-languages=c,c++") + + build_package(gcc_source_dir, gcc_build_dir, gcc_configure_args) + build_glibc({"CC" : tool_inst_dir + "/bin/gcc", + "CXX" : tool_inst_dir + "/bin/g++"}, + stage_dir, tool_inst_dir) def build_tar_package(tar, name, base, directory): name = os.path.realpath(name) @@ -171,7 +192,7 @@ tar_inst_dir = build_dir + '/tar_inst' build_tar(build_dir, tar_inst_dir) stage1_dir = build_dir + '/stage1' -build_one_stage({"CC": "gcc", "CXX" : "g++"}, stage1_dir) +build_one_stage({"CC": "gcc", "CXX" : "g++"}, stage1_dir, True) stage1_tool_inst_dir = stage1_dir + '/inst' stage2_dir = build_dir + '/stage2' @@ -179,7 +200,7 @@ build_one_stage({"CC" : stage1_tool_inst_dir + "/bin/gcc", "CXX" : stage1_tool_inst_dir + "/bin/g++", "AR" : stage1_tool_inst_dir + "/bin/ar", "RANLIB" : "true" }, - stage2_dir) + stage2_dir, False) build_tar_package(tar_inst_dir + "/bin/tar", "toolchain.tar", stage2_dir, "inst")