简体   繁体   English

是否可以在没有操作系统的情况下在没有内置库的情况下编译go代码

[英]Is it possible to compile go code without builtin library that can run on a machine without operating system

Like C compile flags -fno-pic -O -nostdinc -c -static -fno-builtin -fno-strict-aliasing -m32 -fno-stack-protector can compile codes into pure ELF without library rely on unique system. 像C编译标志一样, -fno-pic -O -nostdinc -c -static -fno-builtin -fno-strict-aliasing -m32 -fno-stack-protector可以将代码编译为纯ELF,而无需库依赖唯一的系统。 Is there a possible way GO can do that? GO可以做到这一点吗?

Simple answer is no. 简单的答案是没有。 Go relies on the operating system (Windows, linux, macOS, BSD). Go依赖于操作系统(Windows,Linux,macOS,BSD)。 Go has a runtime designed to work on specific environments https://github.com/golang/go/wiki/MinimumRequirements . Go的运行时旨在在特定环境下工作https://github.com/golang/go/wiki/MinimumRequirements

There are some open source projects that will help you achieve it, but I wouldn't put them in production as they support a limited number of hardware chips and they are not supported in the same way as the standard library. 有一些开源项目可以帮助您实现这一目标,但是我不会将它们投入生产,因为它们支持数量有限的硬件芯片,并且它们与标准库的支持方式不同。 Some examples are: 一些例子是:

https://github.com/ziutek/emgo https://github.com/ziutek/emgo

https://github.com/tinygo-org/tinygo https://github.com/tinygo-org/tinygo

These frameworks/libraries will help you run Go code on bare metal. 这些框架/库将帮助您在裸机上运行Go代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM