美文网首页
swiftc:强大的命令行工具

swiftc:强大的命令行工具

作者: Travelcolor | 来源:发表于2019-11-28 22:08 被阅读0次
    编译过程1
    1. C和OC通过Clang编译器前端编译成LLVM IR中间层表示
    2. Swift会先编译成Swift AST,通过swiftc命令行参数编译成Swift IL(Swift的中间语言),最后编译成LLVM IR,通过LLVM compiler在x86和ARM架构的机器上运行.o可执行文件

    编译过程2
    //命令行:
    swiftc -o main.out main.swift //输入.out可执行文件
    Swift Abstract Syntax Tree (AST)  swiftc main.swift -dump-ast
    Swift Intermediate Language (SIL)  swiftc main.swift -emit-sil
    LLVM Intermediate Representation (LLVM IR) 
     swiftc main.swift -emit-ir
    Assembly Language  swiftc main.swift -emit-assembly //汇编语言
    
    // case
    func addTwoNumber(num1: Int, num2: Int) -> Int {
        return num1 +num2
    }
    
    let sum = addTwoNumber(num1:1, num2:2)
    print(sum)
    

    相关文章

      网友评论

          本文标题:swiftc:强大的命令行工具

          本文链接:https://www.haomeiwen.com/subject/piuiwctx.html