douba05167 2016-11-11 11:17
浏览 81
已采纳

编译器如何交叉编译为不同的OS和体系结构?

I'm very intrigued by the fact that Go (since v1.5) has in-built cross compilation options. But how is it possible to compile for a different OS and architecture? I mean that would require knowing (and probably behaving like) the target machine language and platform.

  • 写回答

1条回答 默认 最新

  • doushi5752 2016-11-11 11:33
    关注

    I mean that would require knowing (and probably behaving like) the target machine language and platform.

    Yes, the Go compiler has to know how the target operating system works, but it doesn't need to behave like the target OS, as the Go compiler will not run the compiled executable binary, it just needs to produce it.

    All the Go tools need to know is the binary formats of the different Operating Systems, and OS and architectural details (such as the instruction set, word size, endianness, alignment, available registers etc.; more info on this). And this knowledge is built into the Go tools.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器