Share
Embed
Transcript
71 slides
-
ຊͷͷྲྀΕɾझࢫ • ίϯύΠϥͷʮυϥΠόʯʹ͍ͭͯΔ • swift-driver ͷৄࡉʹ͍ͭͯΔ • ࣮ࡍʹ ίʔυಡ·ͤͳ͕Βਐߦ͠·͢ɻ •
Θ͔Μͳ͘ͳͬͨΒԕྀͤͣɺదٓࢭΊ͍ͯͩ͘͞ 2 -
ʮυϥΠόʯͱʁ • ͏·͘આ໌Ͱ͖ͳ͍ͷͰͱΓ͋͑ͣάάͬͨΒͳΜ͔͍͍ճ ग़͖ͯͨ • What is a driver, for
example, a compiler driver? at Quora • Ken Gregg (Founder and CEO, Bytellect LLC) ͞Μ͕આ໌ 3 -
υϥΠόͷΘ͔Γ͔ͬͨ͢આ໌ at Quora • There are several uses of the
term “driver” in the world of computer so8ware and hardware. • ίϯϐϡʔλͷੈքͱɺϋʔυΣΞͱιϑτΣΞʢ։ ൃʣͷੈքͰҧ͏ΜͰ 4 -
υϥΠόͷΘ͔Γ͔ͬͨ͢આ໌ ϋʔυΣΞฤ • The most common is device driver (some1mes
just shortened to driver), which is a piece of so:ware that allows an opera1ng system to communicate with a hardware device. • େମͷ߹ʮυϥΠόʯͱ͍͏ͱϋʔυΣΞͷੈքΛࢦͯ͠ ͯɺOSͱσόΠεͷΓͱΓΛαϙʔτʢڐՄʣ͢ΔͭͰ • όευϥΠόɾϑΟϧλυϥΠόɾιϑτΣΞυϥΠόʢι ϑτΣΞͷੈքͷઆ໌Ͱͳ͍ʣ... 5 -
υϥΠόͷΘ͔Γ͔ͬͨ͢આ໌ ιϑτΣΞฤ • In so'ware development in general, the term
driver is some6mes used to refer to a piece of so'ware that controls or drives some other piece of so'ware. • ιϑτΣΞ։ൃͷੈքͱҰൠతʹɺυϥΠόͱ͍͏ݴ ༿͍͔ͭ͘ͷύʔπʹͳ͍ͬͯΔιϑτΣΞΛࢀরͨ͠ Γɺݺͼग़ͨ͠Γ͢ΔιϑτΣΞͷ͜ͱΛࢦ͢Ͱ 6 -
υϥΠόͷΘ͔Γ͔ͬͨ͢આ໌ ιϑτΣΞฤ LLVM ͷྫ • For example, the LLVM Compiler
Driver (llvmc) is a tool that can be configured to invoke several compiler development tools and related tools, acAng as a single point of access for users of the LLVM set of tools. • ͨͱ͑ɺLLVM Compiler Driver ͍͔ͭ͘ͷίϯύΠϥʢͱͦͷؔ࿈ʣ πʔϧͷݺͼग़͠Λߏ͢ΔͷͰ • Ϣʔβ͔ΒݟͨΒLLVMͷπʔϧ܈ʹΞΫηεͰ͖ΔɺҰͭͷΞΫηεϙΠ ϯτͱͯ͠ৼΔ͏Ͱ 7 -
llvmc ͷެࣜͷઆ໌ΛಡΉ • The llvmc tool is a configurable compiler
driver. As such, it isn't a compiler, op;mizer, or a linker itself but it drives (invokes) other soAware that perform those tasks. If you are familiar with the GNU Compiler Collec;on's gcc tool, llvmc is very similar. • llvmc ࣗମ ίϯύΠϥɾOp;mizerɾϦϯΧࣗ ͡Όͳ͍Ͱ • llvmc υϥΠόͱͯ͠ ίϯύΠϥɾOp;mizerɾϦϯΧࣗ Λಈ͔͢(drivesɾݺͼग़͢)Ͱ 8 -
gcc ͷྫ • Έͳ͞Μ͕ίϯύΠϥͩͱࢥ͍ͬͯΔ gccɺ ࣮ɺίϯύΠϥυϥΠό (compiler driver)ͱݺΕΔϓϩάϥϜͰ͋Γɺ CͳͲͷϓϩάϥϛϯάݴޠͰ ॻ͔ΕͨιʔεϓϩάϥϜ͔Β࣮ߦܗࣜΛ
࡞Γग़ͨ͢ΊͷॲཧΛߦ͏ɻ • gccɺʮඞཁʹԠͯ͡ίϯύΠϥ ΞηϯϒϥɺϦϯέʔδΤσΟλͳͲͷ ϓϩάϥϜΛݺͼग़͢ʯͱ͍͏ ॲཧΛߦ͍ͬͯΔɻgccίϚϯυࣗମ͕ί ϯύΠϧΛߦ͍ͬͯΔΘ͚Ͱͳ͍ɻ • ʮίϯύΠϧʯͱݺΕ͍ͯΔॲཧ cc1 ͱ͍͏ผͷίϚϯυ͕͍ͬͯΔ 9 -
Swi$ͷυϥΠόʹ͍ͭͯ • swift-frontend ίϚϯυ͔ΒγϯϘϦοΫϦϯΫͰ swift ͱ swiftc Λ࡞͍ͬͯΔ • ͷͪͷͪɺͱ͋ΔذͰ͜ͷγϯϘϦοΫϦϯΫͷ໊લ͕υϥΠόͱ͠
ͯͷڍಈͷذʹͳΔ͕ޙड़ • ͪͳΈʹɺυϥΠό͕ݺͼग़͢ࣄͷ୯ҐʢϦϯΫͳͲʣΛδϣϒ ͱݺ ΕΔ • main/lib/Driver ʹυϥΠόͷίʔυ͕༗Δ 11 -
swift-driver ͷSwi%PMͰͷϝϦοτ • ΞϗΈ͍ͨͳ࣭͡Όͳ͍ͰɻҰͭͷେ͖ͳརɺ͜ͷυϥΠόSwi%PMͷ֎ଆͷϏϧυγεςϜ͔Βෆಁ໌ͳɺΠϯΫϦϝϯλϧϏϧυͷͨ Ίͷ෦ϏϧυγεςϜΛඋ͍͑ͯΔͰ • leading to oversubscribing the
machine when (say) building lots of targets in parallel. ͕Α͘Θ͔ΒΜ 17 -
swift-driver ͷڥߏஙʹඞཁͳͷ • Xcode 12 (ࢼͨ͠ڥ) • swift-driver ͷίʔυ •
h-ps:/ /github.com/apple/swi<-driver • ͳΔ͘৽͠Ίͷ Swi< Trunk ToolChain(SnapShot) • h-ps:/ /swi<.org/download/#snapshots 22 -
swift-driver ΛϏϧυ͢Δ (swift build) • swift build ͰϏϧυ͢Δ # swift-driver
ʹͯ $ swift build 24 -
swift-driver ΛϏϧυ͢Δ (swift build) • Ϗϧυ͞Εͨ swift-driver Λ swift swiftc
ͱ͍͏໊લͰ γϯϘϦοΫϦϯΫΛషΔ $ ln -s .build/debug/swift-driver swift $ ln -s .build/debug/swift-driver swiftc 25 -
swift-driver Λىಈ͢Δ (swift build) • ࢼ͠ʹ swift Λಈ͔͢ $ ./swift
error: failed to retrieve frontend target info • ಈ͔ͳ͍ 26 -
swift-driver Λىಈ͢Δ (swift build) • ಈ͔͢ʹ swi&-frontend ͷใ͕ඞཁ $ /Library/Developer/Toolchains/{ઌఔΠϯετʔϧͨ͠ToolChainͷύε}/usr/bin/swift-frontend
-frontend -print-target-info { "compilerVersion": "Apple Swift version 5.3-dev (LLVM 2685951d827b16e, Swift ec72db1d8ab63fa)", "target": { "triple": "x86_64-apple-macosx10.15", "unversionedTriple": "x86_64-apple-macosx", "moduleTriple": "x86_64-apple-macos", "swiftRuntimeCompatibilityVersion": "5.1", "compatibilityLibraries": [ { "libraryName": "swiftCompatibility51", "filter": "all" } ], "librariesRequireRPath": false }, "paths": { "runtimeLibraryPaths": [ "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift/macosx", "/usr/lib/swift" ], "runtimeLibraryImportPaths": [ "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift/macosx" ], "runtimeResourcePath": "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift" } } 27 -
swi$-frontend ͷใ • Xcode 12 ಉ෧ͷ Swi- ͩͱɺswift -frontend -print-
target-info Ͱಉ༷ͷͷ͕ग़ͯ͘Δ • ͨͩ͠ɺͪ͜Β swift-driver Ͱಈ͔ͳ͍ 28 -
swift-driver Λىಈ͢Δ (swift build) • ಈ͔͢ʹ swift-frontend ͷใ͕ඞཁ • ->
ڥม SWIFT_DRIVER_SWIFT_FRONTEND_EXEC Ͱઌఔ ͷ swift-frontend Λࢦఆͯ͠ run ͢Εྑ͍ 29 -
swift-driver Λىಈ͢Δ (swift build) $ export SWIFT_DRIVER_SWIFT_FRONTEND_EXEC=/Library/Developer/Toolchains/{ToolChainͷύε}/usr/bin/swift-frontend $ ./swift Type
:help for assistance. 1> • ͜ΕͰREPL͕ىಈ͢Δ • swiftc ಈ͘ $ ./swift test.swift 30 -
swift-driver Λ Debug ͢Δ • Package.swi, Λ։͍ͯ࡞ۀͯ͠ɺͳ͔ͥ Break Point ͕
main.swift ͚ͩޮ͔ͳ͍ • ͷڥ͚͔ͩΕͳ͍ɾɾɾɾ • ͜ΕͰແཧͩͬͨɻଞͷؔͰߦ͚Δ • swift package generate-xcodeprojͰ xcodeproj ্Ͱ࡞ۀ + ্هઃఆͩͱ͏·͘ޮ͘ 31 -
swift-frontend ͳͥඞཁʁ • ग़ྗ͞Εͨͷͷ͏ͪɺpathsͷใʹϑΥʔΧεͯ͠ΈΔ { "runtimeLibraryPaths": [ "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift/macosx", "/usr/lib/swift" ],
"runtimeLibraryImportPaths": [ "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift/macosx" ], "runtimeResourcePath": "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-09-22-a.xctoolchain/usr/lib/swift" } 32 -
swift-frontend ͳͥඞཁʁ • ཁ͢ΔʹɺCoreGraphics ͱ͔ Founda2on ͱ͔ͷ dylib ͷύε ΛूΊͨΓ͍ͯ͠Δ
• ϦϯΧͱ͔ͷδϣϒΛੜ͢Δͱ͖ʹɺదٓҾ͖͢ • LinkJob.swi9 ͷͱ͖ʹઆ໌ 34 -
swift-driver ͷδϣϒʹ͍ͭͯ • ࠓݟΔͷ ... • Job.swi* • LinkJob.swi* •
Planning.swi* 36 -
Planning.swi* • υϥΠό (Driver ܕ) ͷঢ়ଶ͔Βɺదͳδϣϒ܈Λฦ͢ planBuild() ͷ࣮͕͋Δ • Driver
ͷ extension • ***Job.swi- ͷதͷؔΛదٓݺͼग़ͯ͠JobΛ࡞ͬͨΓ 39 -
͜͜·Ͱͷ·ͱΊ • planBuild() ͕ؔ Driver ͷঢ়ଶ͔Βదͳδϣϒ܈Λฦ ͢ • Job ํɺδϣϒΛද͢ߏମ͕ఆٛ͞Ε͍ͯΔ
• ***Job.swi+ ͱ͍͏ϑΝΠϧ͍͍ͩͨͦͷδϣϒΛฦؔ͢ͷ ࣮ 40 -
main.swift import SwiftDriverExecution import SwiftDriver import TSCLibc import TSCBasic import
TSCUtility var intHandler: InterruptHandler? let diagnosticsEngine = DiagnosticsEngine(handlers: [Driver.stderrDiagnosticsHandler]) do { let processSet = ProcessSet() intHandler = try InterruptHandler { processSet.terminate() } let (mode, arguments) = try Driver.invocationRunMode(forArgs: CommandLine.arguments) if case .subcommand(let subcommand) = mode { // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as. // If we didn't find the tool there, let the OS search for it. let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: subcommand) ?? Process.findExecutable(subcommand) if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) { fatalError("cannot find subcommand executable '\(subcommand)'") } // Execute the subcommand. try exec(path: subcommandPath?.pathString ?? "", args: arguments) } let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine, processSet: processSet, fileSystem: localFileSystem, env: ProcessEnv.vars) var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } let jobs = try driver.planBuild() try driver.run(jobs: jobs) if driver.diagnosticEngine.hasErrors { exit(EXIT_FAILURE) } } catch Diagnostics.fatalError { exit(EXIT_FAILURE) } catch let diagnosticData as DiagnosticData { diagnosticsEngine.emit(.error(diagnosticData)) exit(EXIT_FAILURE) } catch { print("error: \(error)") exit(EXIT_FAILURE) } 43 -
main.swift • ·ͣ͡Ί͔Β var intHandler: InterruptHandler? let diagnosticsEngine = DiagnosticsEngine(handlers:
[Driver.stderrDiagnosticsHandler]) do { let processSet = ProcessSet() intHandler = try InterruptHandler { processSet.terminate() } ... 45 -
DiagnosticsEngine var intHandler: InterruptHandler? let diagnosticsEngine = DiagnosticsEngine(handlers: [Driver.stderrDiagnosticsHandler]) //
͜Ε do { let processSet = ProcessSet() intHandler = try InterruptHandler { processSet.terminate() } ... • DiagnosticsEngine • ݟͨײ͡ɺerror warning ͱ͍ͬͨஅͷ݁ՌΛϋϯυϦϯά͢Δ • main.swift ͩͱ Driver.stderrDiagnosticsHandler Λ͍ͯ͠Δ • swift-driver ͷίʔυͰͳ͘ɺapple/swi/-tools-support-core ͷίʔυ 46 -
Driver.stderrDiagnosticsHandler public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
let stream = stderrStream if !(diagnostic.location is UnknownLocation) { stream <<< diagnostic.location.description <<< ": " } switch diagnostic.message.behavior { case .error: stream <<< "error: " case .warning: stream <<< "warning: " ... • error ͱ͔ warning Λ ඪ४Τϥʔग़ྗͱͯ͠ग़͢Α͏ʹϋϯυϦ ϯά͍ͯ͠Δ 47 -
ProcessSet ͱ InterruptHandler var intHandler: InterruptHandler? // ͜Ε let diagnosticsEngine
= DiagnosticsEngine(handlers: [Driver.stderrDiagnosticsHandler]) do { let processSet = ProcessSet() intHandler = try InterruptHandler { // ͜Ε processSet.terminate() } ... • InterruptHandler • ׂΓࠐΈγάφϧ (Ctrl + C) ͷγάφϧ͕ͬͨͱ͖ͷϋϯυϥ • main.swift Ͱ ProcessSet Λ terminate ͢ΔΑ͏ʹϋϯυϧ͍ͯ͠Δ • swift-driver ͷίʔυͰͳ͘ɺapple/swi1-tools-support-core ͷίʔυ 48 -
ProcessSet ͱ InterruptHandler var intHandler: InterruptHandler? let diagnosticsEngine = DiagnosticsEngine(handlers:
[Driver.stderrDiagnosticsHandler]) do { let processSet = ProcessSet() // ͜Ε intHandler = try InterruptHandler { processSet.terminate() // ͜Ε } ... • ProcessSet • ؆୯ʹݴ͑ϓϩηεͷίϨΫγϣϯ • Job ࠷ऴతʹ͜ͷίϨΫγϣϯʹϓϩηεͱͯ͠ొ͞ΕΔ • swift-driver ͷίʔυͰͳ͘ɺapple/swi+-tools-support-core ͷίʔυ 49 -
Driver.invocationRunMode ~ try exec(... • ͔࣍͜͜ΒಡΉ ... let (mode, arguments)
= try Driver.invocationRunMode(forArgs: CommandLine.arguments) if case .subcommand(let subcommand) = mode { // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as. // If we didn't find the tool there, let the OS search for it. let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: subcommand) ?? Process.findExecutable(subcommand) if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) { fatalError("cannot find subcommand executable '\(subcommand)'") } // Execute the subcommand. try exec(path: subcommandPath?.pathString ?? "", args: arguments) } ... 51 -
Driver.invocationRunMode(forArgs:) ... let (mode, arguments) = try Driver.invocationRunMode(forArgs: CommandLine.arguments) //
͜͜ if case .subcommand(let subcommand) = mode { // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as. // If we didn't find the tool there, let the OS search for it. let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: subcommand) ?? Process.findExecutable(subcommand) if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) { fatalError("cannot find subcommand executable '\(subcommand)'") } // Execute the subcommand. try exec(path: subcommandPath?.pathString ?? "", args: arguments) } ... 52 -
Driver.invocationRunMode(forArgs:) • swift ͔ swiftc Ͱݺͼग़͍ͯ͠Δͷ͔ɺͲΜͳΦϓγϣϯ͕ ͍͍ͯΔ͔ɺͳͲͰ Driver ͷϞʔυΛมԽ •
ྫ͑ɺ͜͜Ͱ REPL ͔Ͳ͏͔ఆ͍ͯ͠Δ • αϒίϚϯυΛݟΔϞʔυΛฦ͢͜ͱ͋Δ • ྫ) swift build ͱ͔αϒίϚϯυΛݟΔରʹͳΔ 53 -
if case .subcommand(let subcommand) = ... ... let (mode, arguments)
= try Driver.invocationRunMode(forArgs: CommandLine.arguments) if case .subcommand(let subcommand) = mode { // ͜͜ // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as. // If we didn't find the tool there, let the OS search for it. let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: subcommand) ?? Process.findExecutable(subcommand) if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) { fatalError("cannot find subcommand executable '\(subcommand)'") } // Execute the subcommand. try exec(path: subcommandPath?.pathString ?? "", args: arguments) } ... 54 -
if case .subcommand(let subcommand) = ... • αϒίϚϯυΛ୳ࡧ͢Δɻ • ݟ͔ͭΒͳ͚Ε
error • fatalError("cannot find subcommand ... • ݟ͔ͭͬͨΒαϒίϚϯυΛݺͼग़͢ • try exec(path:, args:) 55 -
͜͜·Ͱͷ·ͱΊ • swift-driver ͕ͲͷΑ͏ʹݺΕΔ͔ௐΔ • swift or swiftc or swift
+ αϒίϚϯυ • αϒίϚϯυ͕͋ΕɺͦͷαϒίϚϯυΛ୳ͯ͠ݺͼग़͢ 56 -
࠷ޙͷ͜͜ͷ෦ ... let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine, processSet: processSet,
fileSystem: localFileSystem, env: ProcessEnv.vars) var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } let jobs = try driver.planBuild() try driver.run(jobs: jobs) ... 57 -
࠷ޙͷ͜͜ͷ෦ ... // ͜͜ let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine,
processSet: processSet, fileSystem: localFileSystem, env: ProcessEnv.vars) var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } let jobs = try driver.planBuild() try driver.run(jobs: jobs) ... 58 -
SwiftDriverExecutor • DriverExecutor ϓϩτίϧʹ४ڌͯ͠Δ • δϣϒΛಈ͔͢͜ͱ͕ϝΠϯͷಇ͖ • ͖ͬ͞ͷ ProcessSet ͱ͔
DiagnosticsEngineɺڥมͷ σʔλͳͲΛ͍ͯ͠Δ • δϣϒΛϓϩηεʹͯ͠ ProcessSet ʹͨ͠Γɺerror Λ DiagnosticsEngine Ͱ ϋϯυϦϯάͨ͠Γ͍ͯ͠ΔͬΆ͍ 59 -
࠷ޙͷ͜͜ͷ෦ ... let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine, processSet: processSet,
fileSystem: localFileSystem, env: ProcessEnv.vars) // ͜͜ var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } let jobs = try driver.planBuild() try driver.run(jobs: jobs) ... 60 -
Driver • ݴΘ͕ͣͳυϥΠόຊମ • ΠχγϟϥΠβͰɺδϣϒ࣮ߦʹඞཁͳ ProcessSet error ϋϯυϦϯάͷͨΊͷ DiagnosticsEngine
Λ͢ • υϥΠόʹ͞ΕͨΦϓγϣϯ͢ (arguments) 61 -
࠷ޙͷ͜͜ͷ෦ ... let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine, processSet: processSet,
fileSystem: localFileSystem, env: ProcessEnv.vars) var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } // ͜͜ let jobs = try driver.planBuild() try driver.run(jobs: jobs) ... 62 -
࠷ޙͷ͜͜ͷ෦ ... let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine, processSet: processSet,
fileSystem: localFileSystem, env: ProcessEnv.vars) var driver = try Driver(args: arguments, diagnosticsEngine: diagnosticsEngine, executor: executor) // FIXME: The following check should be at the end of Driver.init, but current // usage of the DiagnosticVerifier in tests makes this difficult. guard !driver.diagnosticEngine.hasErrors else { throw Diagnostics.fatalError } let jobs = try driver.planBuild() // ͜͜ try driver.run(jobs: jobs) ... 64 -
main.swift ΄΅શ෦ಡΊͨʂ if driver.diagnosticEngine.hasErrors { exit(EXIT_FAILURE) } } catch Diagnostics.fatalError
{ exit(EXIT_FAILURE) } catch let diagnosticData as DiagnosticData { diagnosticsEngine.emit(.error(diagnosticData)) exit(EXIT_FAILURE) } catch { print("error: \(error)") exit(EXIT_FAILURE) } • ޙ try catch ͷΤϥʔϋϯυϦϯά͚ͩͰ͢ • આ໌͠ͳ͍͍ͯͩͨ͘Θ͔Δͱࢥ͍·͢ 67 -
ࢀߟจݙ • What is a driver, for example, a compiler
driver? - Quora • h9ps:/ /www.quora.com/What-is-a-driver-for-example-a-compiler-driver • IntroducAon - The LLVM Compiler Driver (llvmc) • h9ps:/ /releases.llvm.org/1.8/docs/CompilerDriver.html • ίϯύΠϥԿΛ͍ͯ͠Δͷ͔ - େ୍ ݚڀࣨ Ἒେֶ • h9p:/ /nenya.cis.ibaraki.ac.jp/TIPS/compiler.html 70 -
ࢀߟจݙ • apple/swi*-driver • h0ps:/ /github.com/apple/swi*-driver • Harlan Haskins -
Twi0er • h0ps:/ /twi0er.com/harlanhaskins/status/1182325909220556800 • Javi - Twi0er • h0ps:/ /twi0er.com/Javi/status/1260793917563256834 71