Free software porting on the Elbrus architecture

栏目: IT技术 · 发布时间: 4年前

内容简介:Unlike most other CPUs available the Elbrus family (E2K) uses aWhile such approach yields better power usage and performance per number of transistors used, it’s side effect is that the only system compiler — theHowever, free software is also used in the c

Unlike most other CPUs available the Elbrus family (E2K) uses a VLIW instruction set (Very Large Instruction Word) and features 25 general instructions per cycle. Such dependency puts much more demands on the system compiler for optimization. Furthermore in order to minimize the silicone usage every high level function possible was moved from the hardware to the compiler, so roughly speaking there is no microcode and microcode-level operations are done during a compile time, not run-time like on x86 family of CPUs.

While such approach yields better power usage and performance per number of transistors used, it’s side effect is that the only system compiler — the LCC — is closed source and will likely stay that way. The LCC tries to mimic GCC by user interface (both supported options and GCC -specific features) but here similarity ends. The LCC is based on EDG frontend and MCST -made multi-layer backend.

However, free software is also used in the compiler toolchain: libstdc++, libatomic, libgcc_s, the C runtime and so on. It was a challenging task to separate all free components from the compiler bundle, build them from the source and package them apart from binary blobs left to form fully functional toolchain meeting the distribution standards ( ALT in our case).

While the Elbrus machine supports running x86 and amd64 instructions using run-time JIT compiler for x86/amd64 assembly, we do not use this mode for both performance and security reasons. This JIT compiler is left for special purposes like running proprietary closed source software without native E2K support.

Most software porting problems rise from the lack of full compatibility with GCC due to various reasons. The main problem is that the EDG frontend — which is responsible for parsing program’s syntax — lags behind the GCC in supported language features, e.g. current production version lcc-1.23 is on par with gcc-5.5. So many code needs backporting to older C++ standard or similar tweaks in order to build on the E2K.

However, there are other cases as well:

  • Sometimes the LCC notices problem which GCC skips like uninitialized variable usage. This causes problem especially in combination with -Werror. Sometimes we fix such problems, sometimes we just disable -Werror.
  • lcc-1.23 implements not all extended data types from gcc-5.5, e.g. __(u)int128_t and _Decimal64. Such problems are usually easily solved by macro definitions.
  • Not all GCC builtins are implemented, some may never be.
  • LCC’s preprocessor assumes input to be C/C++ code and replaces indentation tabs with spaces. This breaks applications which use a compiler’s preprocessor to parse Makefiles and similar tabulation sensitive data.
  • Some software depends on tricky GCC features, e.g. on undocumented VLAIS (variable length array in structure) or on writing C++ code “careful enough” to not to use C++ runtime and to link such code as normal C code. While such tricks work with gcc, they create many problems with other compilers, sample case is libgraphite2. Such problems are solved on case-by-case basis and prone to be painful issues.

For now the LCC supports only C, C++ and Fortran. So it is not possible to build and use on the E2K in native mode software written in languages with their own code generators like Go, Rust and Haskell. This problem should be solved with ongoing effort to create an LLVM backend for the LCC , but ETA is unknown.

Aside from compiler induced issues the E2K has significantly different hardware architecture besides using VLIW . It feature three independent stacks: for data, for function pointers and for function arguments. This way a system is hardware protected from many kinds of buffer overflow and pointer hijacking attacks. But there is price to pay: low-level memory manipulations like garbage collectors or context switching should be rewritten to take into account this stack layout.

Of course system calls and ioctls are also partly different and such difference should be taken into account while porting software using these calls directly. But this is the common rule for all new architectures.

The E2K also supports a tagged memory, but we do not use this mode to build general purpose applications since drastic changes are required to work in strict security environment, e.g. all virtual calls in C++ will be invalidated by design. More details on the E2K hardware architecture and security features may be learned from the MCST official textbook.

Upstreaming software for the Elbrus has its limitations, but is possible. The main obstacle is that both hardware and software are distributed by MCST under NDA for now, thus we cannot publish patches received from them without prior approval. However, we are free to upstream all own code including low-level stuff and assembly. And the ALT team already upstreamed E2K-specific changes to many free software projects like ruby, lxc, gimagereader, imake. More complete list is available at our wiki.

All people are different, upstreams are different as well. Some gladly accept patches, some are not interested and ignore changes, some demand the toolchain to be opened before accepting any changes. With some luck NDA restrictions may be mostly lifted in the future and this beautiful architecture will see a second wind in its development.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python带我起飞

Python带我起飞

李金洪 / 电子工业出版社 / 2018-6 / 79

《Python带我起飞——入门、进阶、商业实战》针对Python 3.5 以上版本,采用“理论+实践”的形式编写,通过大量的实例(共42 个),全面而深入地讲解“Python 基础语法”和“Python 项目应用”两方面内容。书中的实例具有很强的实用性,如对医疗影像数据进行分析、制作爬虫获取股票信息、自动化实例、从一组看似混乱的数据中找出规律、制作人脸识别系统等。 《Python带我起飞——......一起来看看 《Python带我起飞》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具