1 module gccbuild.build.gcc; 2 3 import scriptlike, gccbuild; 4 5 void buildStage1GCC() 6 { 7 auto comp = build.gcc; 8 if (!comp.stage1BuildCommand.matchesBuildType) 9 return; 10 startSection("Building stage 1 gcc"); 11 auto saveCWD = comp.prepareBuildDir(); 12 auto oldPath = updatePathVar(binDirStage1); 13 14 runBuildCommands(comp.stage1BuildCommand.commands, ["CONFIGURE" : comp.configureFile.toString()]); 15 restorePathVar(oldPath); 16 if (!keepBuildFiles) 17 rmdirRecurse(comp.buildFolder); 18 endSection(); 19 } 20 21 void detectMultilib() 22 { 23 auto oldPath = updatePathVar(binDirStage1); 24 detectMultilib(build.target ~ "-gcc"); 25 restorePathVar(oldPath); 26 } 27 28 void detectMultilib(string compiler, string msg = "Detecting available multilibs") 29 { 30 startSection(msg); 31 32 auto output = runCollectLog(compiler ~ " --print-multi-lib"); 33 foreach (line; output.lineSplitter) 34 { 35 MultilibEntry entry; 36 auto parts = line.findSplit(";"); 37 failEnforcec(cast(bool) parts, "Invalid format returned from --print-multi-lib", 38 line); 39 entry.gccFolder = parts[0]; 40 entry.args = parts[2].splitter("@").filter!(a => !a.empty).map!(a => "-" ~ a).join(" "); 41 42 auto output2 = runCollectLog(compiler ~ " --print-multi-os-dir " ~ entry.args); 43 entry.osFolder = output2.strip(); 44 build.multilibs ~= entry; 45 } 46 47 if (build.multilibs.length == 1 && build.multilibs[0].isDefaultLib) 48 writeBulletPoint("No multilib support detected"); 49 else 50 { 51 foreach (lib; build.multilibs) 52 { 53 writeBulletPoint( 54 "args='" ~ lib.args ~ "' osDir='" ~ lib.osFolder ~ "' gccDir='" ~ lib.gccFolder 55 ~ "'"); 56 } 57 } 58 endSection(); 59 } 60 61 void buildFinalGCC() 62 { 63 auto comp = build.gcc; 64 if (!comp.mainBuildCommand.matchesBuildType) 65 return; 66 startSection("Building final gcc"); 67 auto saveCWD = comp.prepareBuildDir(); 68 69 // Native builds need the newly build binutils in PATH 70 string oldPath; 71 if (build.type == ToolchainType.native || build.type == ToolchainType.cross) 72 oldPath = updatePathVar(binDir); 73 74 runBuildCommands(comp.mainBuildCommand.commands, ["CONFIGURE" : comp.configureFile.toString()]); 75 76 if (build.type == ToolchainType.native || build.type == ToolchainType.cross) 77 restorePathVar(oldPath); 78 79 if (!keepBuildFiles) 80 rmdirRecurse(comp.buildFolder); 81 endSection(); 82 }