mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-28 01:01:09 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
83f71117c6
@ -1,10 +1,11 @@
|
|||||||
Python 函数式编程 —— 不可变数据结构
|
Python 函数式编程:不可变数据结构
|
||||||
======
|
======
|
||||||
不可变性可以帮助我们更好地理解我们的代码。下面我将讲述如何在不牺牲性能的条件下来实现它。
|
|
||||||
|
> 不可变性可以帮助我们更好地理解我们的代码。下面我将讲述如何在不牺牲性能的条件下来实现它。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
在这个由两篇文章构成的系列中,我将讨论如何将函数式编程方法论中的观点引入至 Python 中,来充分发挥这两个领域的优势。
|
在这个由两篇文章构成的系列中,我将讨论如何将函数式编程方法论中的思想引入至 Python 中,来充分发挥这两个领域的优势。
|
||||||
|
|
||||||
本文(也就是第一篇文章)中,我们将探讨不可变数据结构的优势。第二部分会探讨如何在 `toolz` 库的帮助下,用 Python 实现高层次的函数式编程理念。
|
本文(也就是第一篇文章)中,我们将探讨不可变数据结构的优势。第二部分会探讨如何在 `toolz` 库的帮助下,用 Python 实现高层次的函数式编程理念。
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ class IRectangle(Interface):
|
|||||||
|
|
||||||
这似乎像是个学术问题 —— 直到我们认为正方形和矩形可以在某种意义上看做一个容器的侧面。在理解了这个例子以后,我们会处理更传统的容器,以解决更现实的案例。比如,考虑一下随机存取数组。
|
这似乎像是个学术问题 —— 直到我们认为正方形和矩形可以在某种意义上看做一个容器的侧面。在理解了这个例子以后,我们会处理更传统的容器,以解决更现实的案例。比如,考虑一下随机存取数组。
|
||||||
|
|
||||||
我们现在有 `ISquare` 和 `IRectangle`,`ISequere` 是 `IRectangle` 的子类。
|
我们现在有 `ISquare` 和 `IRectangle`,而且 `ISequere` 是 `IRectangle` 的子类。
|
||||||
|
|
||||||
我们希望把矩形放进随机存取数组中:
|
我们希望把矩形放进随机存取数组中:
|
||||||
|
|
||||||
@ -133,8 +134,7 @@ b = a.set(1, "hello")
|
|||||||
|
|
||||||
尽管 `b` 不是一个由整数构成的向量,但没有什么能够改变 `a` 只由整数构成的性质。
|
尽管 `b` 不是一个由整数构成的向量,但没有什么能够改变 `a` 只由整数构成的性质。
|
||||||
|
|
||||||
如果 `a` 有一百万个元素呢?`b` 会将其中的 999999 个元素复制一遍吗?`Pyrsistent` 包含“大 O”性能保证:所有操作的时间复杂度都是 `O(log n)`. 它还带有一个可选的 C 语言扩展,以提高大 O 之外的性能。
|
如果 `a` 有一百万个元素呢?`b` 会将其中的 999999 个元素复制一遍吗?`Pyrsistent` 具有“大 O”性能保证:所有操作的时间复杂度都是 `O(log n)`. 它还带有一个可选的 C 语言扩展,以在“大 O”性能之上进行提升。
|
||||||
|
|
||||||
|
|
||||||
修改嵌套对象时,会涉及到“变换器”的概念:
|
修改嵌套对象时,会涉及到“变换器”的概念:
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ def silly_sum(a, b, extra=v(1, 2)):
|
|||||||
return sum(extra)
|
return sum(extra)
|
||||||
```
|
```
|
||||||
|
|
||||||
在本文中,我们了解了为什么不可变性有助于我们来思考我们的代码,以及如何在不带来过大性能代价的条件下实现它。下一篇,我们将学习如何借助不可变对象来实现强大的程序结构。
|
在本文中,我们了解了为什么不可变性有助于我们来思考我们的代码,以及如何在不带来过大性能负担的条件下实现它。下一篇,我们将学习如何借助不可变对象来实现强大的程序结构。
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ via: https://opensource.com/article/18/10/functional-programming-python-immutabl
|
|||||||
作者:[Moshe Zadka][a]
|
作者:[Moshe Zadka][a]
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
译者:[StdioA](https://github.com/StdioA)
|
译者:[StdioA](https://github.com/StdioA)
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
校对:[wxy](https://github.com/wxy)
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
@ -1,27 +1,26 @@
|
|||||||
KRS:一个收集 Kubernetes 资源统计数据的新工具
|
KRS:一个收集 Kubernetes 资源统计数据的新工具
|
||||||
======
|
======
|
||||||
零配置工具简化了信息收集,例如在某个命名空间中运行了多少个 pod。
|
|
||||||
|
> 零配置工具简化了信息收集,例如在某个命名空间中运行了多少个 pod。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
最近我在纽约的 O'Reilly Velocity 就 [Kubernetes 应用故障排除][1]的主题发表了演讲,并且在积极的反馈和讨论的推动下,我决定重新审视这个领域的工具。结果,除了 [kubernetes-incubator/spartakus][2] 和 [kubernetes/kube-state-metrics][3] 之外,我们还没有太多的轻量级工具来收集资源统计数据(例如命名空间中的 pod 或服务)。所以,我在回家的路上开始编写一个小工具 - 创造性地命名为 **krs**,它是 Kubernetes Resource Stats 的简称 ,它允许你收集这些统计数据。
|
最近我在纽约的 O'Reilly Velocity 就 [Kubernetes 应用故障排除][1]的主题发表了演讲,并且在积极的反馈和讨论的推动下,我决定重新审视这个领域的工具。结果,除了 [kubernetes-incubator/spartakus][2] 和 [kubernetes/kube-state-metrics][3] 之外,我们还没有太多的轻量级工具来收集资源统计数据(例如命名空间中的 pod 或服务的数量)。所以,我在回家的路上开始编写一个小工具 —— 创造性地命名为 `krs`,它是 Kubernetes Resource Stats 的简称 ,它允许你收集这些统计数据。
|
||||||
|
|
||||||
你可以通过两种方式使用 [mhausenblas/krs][5]:
|
你可以通过两种方式使用 [mhausenblas/krs][5]:
|
||||||
|
|
||||||
* 直接在命令行(有 Linux、Windows 和 MacOS 的二进制文件),以及
|
* 直接在命令行(有 Linux、Windows 和 MacOS 的二进制文件),以及
|
||||||
* 在集群中使用 [launch.sh][4] 脚本部署,该脚本动态创建适当的基于角色的访问控制 (RBAC) 权限。
|
* 在集群中使用 [launch.sh][4] 脚本部署,该脚本动态创建适当的基于角色的访问控制(RBAC) 权限。
|
||||||
|
|
||||||
|
提醒你,它还在早期,并且还在开发中。但是,`krs` 的 0.1 版本提供以下功能:
|
||||||
|
|
||||||
提醒你,它还在早期,并且还在开发中。但是,**krs** 的 0.1 版本提供以下功能:
|
* 在每个命名空间的基础上,它定期收集资源统计信息(支持 pod、部署和服务)。
|
||||||
|
* 它以 [OpenMetrics 格式][6]公开这些统计。
|
||||||
|
* 它可以直接通过二进制文件使用,也可以在包含所有依赖项的容器化设置中使用。
|
||||||
|
|
||||||
* 在每个命名空间的基础上,它定期收集资源统计信息(支持 pod、部署和服务)。
|
目前,你需要安装并配置 `kubectl`,因为 `krs` 依赖于执行 `kubectl get all` 命令来收集统计数据。(另一方面,谁会使用 Kubernetes 但没有安装 `kubectl` 呢?)
|
||||||
* 它以 [OpenMetrics 格式][6]公开这些统计。
|
|
||||||
* 它可以直接通过二进制文件使用,也可以在包含所有依赖项的容器化设置中使用。
|
|
||||||
|
|
||||||
|
使用 `krs` 很简单。[下载][7]适合你平台的二进制文件,并按如下方式执行:
|
||||||
|
|
||||||
目前,你需要安装并配置 **kubectl**,因为 **krs** 依赖于执行 **kubectl get all** 命令来收集统计数据。(另一方面,谁会使用 Kubernetes 但没有安装 **kubectl**?)
|
|
||||||
|
|
||||||
使用 **krs** 很简单。[下载][7]适合你平台的二进制文件,并按如下方式执行:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ krs thenamespacetowatch
|
$ krs thenamespacetowatch
|
||||||
@ -36,15 +35,15 @@ deployments{namespace="thenamespacetowatch"} 6
|
|||||||
services{namespace="thenamespacetowatch"} 4
|
services{namespace="thenamespacetowatch"} 4
|
||||||
```
|
```
|
||||||
|
|
||||||
这将在前台启动 **krs**,从名称空间 **thenamespacetowatch** 收集资源统计信息,并分别在**标准输出**中以 OpenMetrics 格式输出它们,以供你进一步处理。
|
这将在前台启动 `krs`,从名称空间 `thenamespacetowatch` 收集资源统计信息,并分别在标准输出中以 OpenMetrics 格式输出它们,以供你进一步处理。
|
||||||
|
|
||||||
![krs screenshot][9]
|
![krs screenshot][9]
|
||||||
|
|
||||||
krs 实战截屏
|
*krs 实战截屏*
|
||||||
|
|
||||||
也许你会问,Michael,为什么不做一些有用的事(例如将指标存储在 S3 中)?因为 [Unix 哲学][10]
|
也许你会问,Michael,为什么它不能做一些有用的事(例如将指标存储在 S3 中)?因为 [Unix 哲学][10]。
|
||||||
|
|
||||||
对于那些想知道他们是否可以直接使用 Prometheus 或 [kubernetes/kube-state-metrics][3] 来完成这项任务的人:是的,你可以,为什么不行呢? **krs** 的重点是作为已有工具的轻量级且易于使用的替代品 - 甚至可能在某些方面略微互补。
|
对于那些想知道他们是否可以直接使用 Prometheus 或 [kubernetes/kube-state-metrics][3] 来完成这项任务的人:是的,你可以,为什么不行呢? `krs` 的重点是作为已有工具的轻量级且易于使用的替代品 —— 甚至可能在某些方面略微互补。
|
||||||
|
|
||||||
本文最初发表在 [Medium 的 ITNext][11] 上,并获得授权转载。
|
本文最初发表在 [Medium 的 ITNext][11] 上,并获得授权转载。
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ via: https://opensource.com/article/18/11/kubernetes-resource-statistics
|
|||||||
作者:[Michael Hausenblas][a]
|
作者:[Michael Hausenblas][a]
|
||||||
选题:[lujun9972][b]
|
选题:[lujun9972][b]
|
||||||
译者:[geekpi](https://github.com/geekpi)
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
校对:[wxy](https://github.com/wxy)
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
@ -1,4 +1,3 @@
|
|||||||
Translating by ranchong
|
|
||||||
How technology changes the rules for doing agile
|
How technology changes the rules for doing agile
|
||||||
======
|
======
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
translating---geekpi
|
||||||
|
|
||||||
IssueHunt: A New Bounty Hunting Platform for Open Source Software
|
IssueHunt: A New Bounty Hunting Platform for Open Source Software
|
||||||
======
|
======
|
||||||
One of the issues that many open-source developers and companies struggle with is funding. There is an assumption, an expectation even, among the community that Free and Open Source Software must be provided free of cost. But even FOSS needs funding for continued development. How can we keep expecting better quality software if we don’t create systems that enable continued development?
|
One of the issues that many open-source developers and companies struggle with is funding. There is an assumption, an expectation even, among the community that Free and Open Source Software must be provided free of cost. But even FOSS needs funding for continued development. How can we keep expecting better quality software if we don’t create systems that enable continued development?
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
**translating by [ivo-wang](https://github.com/ivo-wang)**
|
|
||||||
|
|
||||||
|
|
||||||
10 keys to quick game development
|
10 keys to quick game development
|
||||||
======
|
======
|
||||||

|

|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
translating---geekpi
|
|
||||||
|
|
||||||
A single-user, lightweight OS for your next home project | Opensource.com
|
|
||||||
======
|
|
||||||

|
|
||||||
|
|
||||||
What on earth is RISC OS? Well, it's not a new kind of Linux. And it's not someone's take on Windows. In fact, released in 1987, it's older than either of these. But you wouldn't necessarily realize it by looking at it.
|
|
||||||
|
|
||||||
The point-and-click graphic user interface features a pinboard and an icon bar across the bottom for your active applications. So, it looks eerily like Windows 95, eight years before it happened.
|
|
||||||
|
|
||||||
This OS was originally written for the [Acorn Archimedes][1] . The Acorn RISC Machines CPU in this computer was completely new hardware that needed completely new software to run on it. This was the original operating system for the ARM chip, long before anyone had thought of Android or [Armbian][2]
|
|
||||||
|
|
||||||
And while the Acorn desktop eventually faded to obscurity, the ARM chip went on to conquer the world. And here, RISC OS has always had a niche—often in embedded devices, where you'd never actually know it was there. RISC OS was, for a long time, a completely proprietary operating system. But in recent years, the owners have started releasing the source code to a project called [RISC OS Open][3].
|
|
||||||
|
|
||||||
### 1\. You can install it on your Raspberry Pi
|
|
||||||
|
|
||||||
The Raspberry Pi's official operating system, [Raspbian][4], is actually pretty great (but if you aren't interested in tinkering with novel and different things in tech, you probably wouldn't be fiddling with a Raspberry Pi in the first place). Because RISC OS is written specifically for ARM, it can run on all kinds of small-board computers, including every model of Raspberry Pi.
|
|
||||||
|
|
||||||
### 2\. It's super lightweight
|
|
||||||
|
|
||||||
The RISC OS installation on my Raspberry Pi takes up a few hundred megabytes—and that's after I've loaded dozens of utilities and games. Most of these are well under a megabyte.
|
|
||||||
|
|
||||||
If you're really on a diet, the RISC OS Pico will fit on a 16MB SD card. This is perfect if you're hacking something to go in an embedded system or IoT project. Of course, 16MB is actually a fair bit more than the 512KB ROM chip squeezed into the old Archimedes. But I guess with 30 years of progress in memory technology, it's okay to stretch your legs just a little a bit.
|
|
||||||
|
|
||||||
### 3\. It's excellent for retro gaming
|
|
||||||
|
|
||||||
When the Archimedes was in its prime, the ARM CPU was several times faster than the Motorola 68000 in the Apple Macintosh and Commodore Amiga, and it totally smoked that new 386, too. This made it an attractive platform for game developers who wanted to strut their stuff with the most powerful desktop computer on the planet.
|
|
||||||
|
|
||||||
Many of the rights holders to these games have been generous enough to give permission for hobbyists to download their old work for free. And while RISC OS and the hardware has moved on, with a very small amount of fiddling you can get them to run.
|
|
||||||
|
|
||||||
If you're interested in exploring this, [here's a guide][5] to getting these games working on your Raspberry Pi.
|
|
||||||
|
|
||||||
### 4\. It's got BBC BASIC
|
|
||||||
|
|
||||||
Press F12 to go to the command line, type `*BASIC`, and you get a full BBC BASIC interpreter, just like the old days.
|
|
||||||
|
|
||||||
For those who weren't around for it in the 80s, let me explain: BBC BASIC was the first ever programming language for so many of us back in the day, for the excellent reason that it was specifically designed to teach children how to code. There were mountains of books and magazine articles that taught us to code our own simple but highly playable games.
|
|
||||||
|
|
||||||
Decades later, coding your own game in BBC BASIC is still a great project for a technically minded kid who wants something to do during school holidays. But few kids have a BBC micro at home anymore. So what should they run it on?
|
|
||||||
|
|
||||||
Well, there are interpreters you can run on just about every home computer, but that's not helpful when someone else needs to use it. So why not a Raspberry Pi with RISC OS installed?
|
|
||||||
|
|
||||||
### 5\. It's a simple, single-user operating system
|
|
||||||
|
|
||||||
RISC OS is not like Linux, with its user and superuser access. It has one user who has full access to the whole machine. So it's probably not the best daily driver to deploy across an enterprise, or even to give to granddad to do his banking. But if you're looking for something to hack and tinker with, it's absolutely fantastic. There isn't all that much between you and the bare metal, so you can just tuck right in.
|
|
||||||
|
|
||||||
### Further reading
|
|
||||||
|
|
||||||
If you want to learn more about this operating system, check out [RISC OS Open][3], or just flash an image to a card and start using it.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/18/7/gentle-intro-risc-os
|
|
||||||
|
|
||||||
作者:[James Mawson][a]
|
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:https://opensource.com/users/dxmjames
|
|
||||||
[1]:https://en.wikipedia.org/wiki/Acorn_Archimedes
|
|
||||||
[2]:https://www.armbian.com/
|
|
||||||
[3]:https://www.riscosopen.org/content/
|
|
||||||
[4]:https://www.raspbian.org/
|
|
||||||
[5]:https://www.riscosopen.org/wiki/documentation/show/Introduction%20to%20RISC%20OS
|
|
@ -1,248 +0,0 @@
|
|||||||
Translating by qhwdw
|
|
||||||
Tools Used in 6.828
|
|
||||||
======
|
|
||||||
### Tools Used in 6.828
|
|
||||||
|
|
||||||
You'll use two sets of tools in this class: an x86 emulator, QEMU, for running your kernel; and a compiler toolchain, including assembler, linker, C compiler, and debugger, for compiling and testing your kernel. This page has the information you'll need to download and install your own copies. This class assumes familiarity with Unix commands throughout.
|
|
||||||
|
|
||||||
We highly recommend using a Debathena machine, such as athena.dialup.mit.edu, to work on the labs. If you use the MIT Athena machines that run Linux, then all the software tools you will need for this course are located in the 6.828 locker: just type 'add -f 6.828' to get access to them.
|
|
||||||
|
|
||||||
If you don't have access to a Debathena machine, we recommend you use a virtual machine with Linux. If you really want to, you can build and install the tools on your own machine. We have instructions below for Linux and MacOS computers.
|
|
||||||
|
|
||||||
It should be possible to get this development environment running under windows with the help of [Cygwin][1]. Install cygwin, and be sure to install the flex and bison packages (they are under the development header).
|
|
||||||
|
|
||||||
For an overview of useful commands in the tools used in 6.828, see the [lab tools guide][2].
|
|
||||||
|
|
||||||
#### Compiler Toolchain
|
|
||||||
|
|
||||||
A "compiler toolchain" is the set of programs, including a C compiler, assemblers, and linkers, that turn code into executable binaries. You'll need a compiler toolchain that generates code for 32-bit Intel architectures ("x86" architectures) in the ELF binary format.
|
|
||||||
|
|
||||||
##### Test Your Compiler Toolchain
|
|
||||||
|
|
||||||
Modern Linux and BSD UNIX distributions already provide a toolchain suitable for 6.828. To test your distribution, try the following commands:
|
|
||||||
|
|
||||||
```
|
|
||||||
% objdump -i
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The second line should say `elf32-i386`.
|
|
||||||
|
|
||||||
```
|
|
||||||
% gcc -m32 -print-libgcc-file-name
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The command should print something like `/usr/lib/gcc/i486-linux-gnu/version/libgcc.a` or `/usr/lib/gcc/x86_64-linux-gnu/version/32/libgcc.a`
|
|
||||||
|
|
||||||
If both these commands succeed, you're all set, and don't need to compile your own toolchain.
|
|
||||||
|
|
||||||
If the gcc command fails, you may need to install a development environment. On Ubuntu Linux, try this:
|
|
||||||
|
|
||||||
```
|
|
||||||
% sudo apt-get install -y build-essential gdb
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
On 64-bit machines, you may need to install a 32-bit support library. The symptom is that linking fails with error messages like "`__udivdi3` not found" and "`__muldi3` not found". On Ubuntu Linux, try this to fix the problem:
|
|
||||||
|
|
||||||
```
|
|
||||||
% sudo apt-get install gcc-multilib
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Using a Virtual Machine
|
|
||||||
|
|
||||||
Otherwise, the easiest way to get a compatible toolchain is to install a modern Linux distribution on your computer. With platform virtualization, Linux can cohabitate with your normal computing environment. Installing a Linux virtual machine is a two step process. First, you download the virtualization platform.
|
|
||||||
|
|
||||||
* [**VirtualBox**][3] (free for Mac, Linux, Windows) — [Download page][3]
|
|
||||||
* [VMware Player][4] (free for Linux and Windows, registration required)
|
|
||||||
* [VMware Fusion][5] (Downloadable from IS&T for free).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VirtualBox is a little slower and less flexible, but free!
|
|
||||||
|
|
||||||
Once the virtualization platform is installed, download a boot disk image for the Linux distribution of your choice.
|
|
||||||
|
|
||||||
* [Ubuntu Desktop][6] is what we use.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This will download a file named something like `ubuntu-10.04.1-desktop-i386.iso`. Start up your virtualization platform and create a new (32-bit) virtual machine. Use the downloaded Ubuntu image as a boot disk; the procedure differs among VMs but is pretty simple. Type `objdump -i`, as above, to verify that your toolchain is now set up. You will do your work inside the VM.
|
|
||||||
|
|
||||||
##### Building Your Own Compiler Toolchain
|
|
||||||
|
|
||||||
This will take longer to set up, but give slightly better performance than a virtual machine, and lets you work in your own familiar environment (Unix/MacOS). Fast-forward to the end for MacOS instructions.
|
|
||||||
|
|
||||||
###### Linux
|
|
||||||
|
|
||||||
You can use your own tool chain by adding the following line to `conf/env.mk`:
|
|
||||||
|
|
||||||
```
|
|
||||||
GCCPREFIX=
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
We assume that you are installing the toolchain into `/usr/local`. You will need a fair amount of disk space to compile the tools (around 1GiB). If you don't have that much space, delete each directory after its `make install` step.
|
|
||||||
|
|
||||||
Download the following packages:
|
|
||||||
|
|
||||||
+ ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
|
|
||||||
+ https://www.mpfr.org/mpfr-3.1.2/mpfr-3.1.2.tar.bz2
|
|
||||||
+ http://www.multiprecision.org/downloads/mpc-0.9.tar.gz
|
|
||||||
+ http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2
|
|
||||||
+ http://ftpmirror.gnu.org/gcc/gcc-4.6.4/gcc-core-4.6.4.tar.bz2
|
|
||||||
+ http://ftpmirror.gnu.org/gdb/gdb-7.3.1.tar.bz2
|
|
||||||
|
|
||||||
(You may also use newer versions of these packages.) Unpack and build the packages. The `green bold` text shows you how to install into `/usr/local`, which is what we recommend. To install into a different directory, $PFX, note the differences in lighter type ([hide][7]). If you have problems, see below.
|
|
||||||
|
|
||||||
```
|
|
||||||
export PATH=$PFX/bin:$PATH
|
|
||||||
export LD_LIBRARY_PATH=$PFX/lib:$LD_LIBRARY_PATH
|
|
||||||
|
|
||||||
tar xjf gmp-5.0.2.tar.bz2
|
|
||||||
cd gmp-5.0.2
|
|
||||||
./configure --prefix=$PFX
|
|
||||||
make
|
|
||||||
make install # This step may require privilege (sudo make install)
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
tar xjf mpfr-3.1.2.tar.bz2
|
|
||||||
cd mpfr-3.1.2
|
|
||||||
./configure --prefix=$PFX --with-gmp=$PFX
|
|
||||||
make
|
|
||||||
make install # This step may require privilege (sudo make install)
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
tar xzf mpc-0.9.tar.gz
|
|
||||||
cd mpc-0.9
|
|
||||||
./configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX
|
|
||||||
make
|
|
||||||
make install # This step may require privilege (sudo make install)
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
|
|
||||||
tar xjf binutils-2.21.1.tar.bz2
|
|
||||||
cd binutils-2.21.1
|
|
||||||
./configure --prefix=$PFX --target=i386-jos-elf --disable-werror
|
|
||||||
make
|
|
||||||
make install # This step may require privilege (sudo make install)
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
i386-jos-elf-objdump -i
|
|
||||||
# Should produce output like:
|
|
||||||
# BFD header file version (GNU Binutils) 2.21.1
|
|
||||||
# elf32-i386
|
|
||||||
# (header little endian, data little endian)
|
|
||||||
# i386...
|
|
||||||
|
|
||||||
|
|
||||||
tar xjf gcc-core-4.6.4.tar.bz2
|
|
||||||
cd gcc-4.6.4
|
|
||||||
mkdir build # GCC will not compile correctly unless you build in a separate directory
|
|
||||||
cd build
|
|
||||||
../configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX \
|
|
||||||
--target=i386-jos-elf --disable-werror \
|
|
||||||
--disable-libssp --disable-libmudflap --with-newlib \
|
|
||||||
--without-headers --enable-languages=c MAKEINFO=missing
|
|
||||||
make all-gcc
|
|
||||||
make install-gcc # This step may require privilege (sudo make install-gcc)
|
|
||||||
make all-target-libgcc
|
|
||||||
make install-target-libgcc # This step may require privilege (sudo make install-target-libgcc)
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
i386-jos-elf-gcc -v
|
|
||||||
# Should produce output like:
|
|
||||||
# Using built-in specs.
|
|
||||||
# COLLECT_GCC=i386-jos-elf-gcc
|
|
||||||
# COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.4/lto-wrapper
|
|
||||||
# Target: i386-jos-elf
|
|
||||||
|
|
||||||
|
|
||||||
tar xjf gdb-7.3.1.tar.bz2
|
|
||||||
cd gdb-7.3.1
|
|
||||||
./configure --prefix=$PFX --target=i386-jos-elf --program-prefix=i386-jos-elf- \
|
|
||||||
--disable-werror
|
|
||||||
make all
|
|
||||||
make install # This step may require privilege (sudo make install)
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Linux troubleshooting
|
|
||||||
|
|
||||||
* Q. I can't run `make install` because I don't have root permission on this machine.
|
|
||||||
A. Our instructions assume you are installing into the `/usr/local` directory. However, this may not be allowed in your environment. If you can only install code into your home directory, that's OK. In the instructions above, replace `--prefix=/usr/local` with `--prefix=$HOME` (and [click here][7] to update the instructions further). You will also need to change your `PATH` and `LD_LIBRARY_PATH` environment variables, to inform your shell where to find the tools. For example:
|
|
||||||
```
|
|
||||||
export PATH=$HOME/bin:$PATH
|
|
||||||
export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
|
|
||||||
```
|
|
||||||
|
|
||||||
Enter these lines in your `~/.bashrc` file so you don't need to type them every time you log in.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Q. My build fails with an inscrutable message about "library not found".
|
|
||||||
A. You need to set your `LD_LIBRARY_PATH`. The environment variable must include the `PREFIX/lib` directory (for instance, `/usr/local/lib`).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### MacOS
|
|
||||||
|
|
||||||
First begin by installing developer tools on Mac OSX:
|
|
||||||
`xcode-select --install`
|
|
||||||
|
|
||||||
First begin by installing developer tools on Mac OSX:
|
|
||||||
|
|
||||||
You can install the qemu dependencies from homebrew, however do not install qemu itself as you will need the 6.828 patched version.
|
|
||||||
|
|
||||||
`brew install $(brew deps qemu)`
|
|
||||||
|
|
||||||
The gettext utility does not add installed binaries to the path, so you will need to run
|
|
||||||
|
|
||||||
`PATH=${PATH}:/usr/local/opt/gettext/bin make install`
|
|
||||||
|
|
||||||
when installing qemu below.
|
|
||||||
|
|
||||||
### QEMU Emulator
|
|
||||||
|
|
||||||
[QEMU][8] is a modern and fast PC emulator. QEMU version 2.3.0 is set up on Athena for x86 machines in the 6.828 locker (`add -f 6.828`)
|
|
||||||
|
|
||||||
Unfortunately, QEMU's debugging facilities, while powerful, are somewhat immature, so we highly recommend you use our patched version of QEMU instead of the stock version that may come with your distribution. The version installed on Athena is already patched. To build your own patched version of QEMU:
|
|
||||||
|
|
||||||
1. Clone the IAP 6.828 QEMU git repository `git clone https://github.com/mit-pdos/6.828-qemu.git qemu`
|
|
||||||
2. On Linux, you may need to install several libraries. We have successfully built 6.828 QEMU on Debian/Ubuntu 16.04 after installing the following packages: libsdl1.2-dev, libtool-bin, libglib2.0-dev, libz-dev, and libpixman-1-dev.
|
|
||||||
3. Configure the source code (optional arguments are shown in square brackets; replace PFX with a path of your choice)
|
|
||||||
1. Linux: `./configure --disable-kvm --disable-werror [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]`
|
|
||||||
2. OS X: `./configure --disable-kvm --disable-werror --disable-sdl [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]` The `prefix` argument specifies where to install QEMU; without it QEMU will install to `/usr/local` by default. The `target-list` argument simply slims down the architectures QEMU will build support for.
|
|
||||||
4. Run `make && make install`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://pdos.csail.mit.edu/6.828/2018/tools.html
|
|
||||||
|
|
||||||
作者:[csail.mit][a]
|
|
||||||
选题:[lujun9972][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://pdos.csail.mit.edu
|
|
||||||
[b]: https://github.com/lujun9972
|
|
||||||
[1]: http://www.cygwin.com
|
|
||||||
[2]: labguide.html
|
|
||||||
[3]: http://www.oracle.com/us/technologies/virtualization/oraclevm/
|
|
||||||
[4]: http://www.vmware.com/products/player/
|
|
||||||
[5]: http://www.vmware.com/products/fusion/
|
|
||||||
[6]: http://www.ubuntu.com/download/desktop
|
|
||||||
[7]:
|
|
||||||
[8]: http://www.nongnu.org/qemu/
|
|
||||||
[9]: mailto:6828-staff@lists.csail.mit.edu
|
|
||||||
[10]: https://i.creativecommons.org/l/by/3.0/us/88x31.png
|
|
||||||
[11]: https://creativecommons.org/licenses/by/3.0/us/
|
|
||||||
[12]: https://pdos.csail.mit.edu/6.828/2018/index.html
|
|
@ -0,0 +1,65 @@
|
|||||||
|
适用于你下一个家庭项目的单用户轻量级操作系统| Opensource.com
|
||||||
|
======
|
||||||
|

|
||||||
|
|
||||||
|
究竟什么是 RISC OS?嗯,它不是一种新的 Linux。它也不是有些人认为的 Windows。事实上,在 1987 年发布,它比其中任何一个都要老。但你看到它不一定会意识到这一点。
|
||||||
|
|
||||||
|
点击式图形用户界面在活动程序的底部有一个固定板和一个图标栏。因此,它看起来像 Windows 95,并且比它早了 8 年。
|
||||||
|
|
||||||
|
这个操作系统最初是为 [Acorn Archimedes][1] 编写的。这台机器中的 Acorn RISC Machines CPU 是全新的硬件,因此需要在其上运行全新的软件。这是最早的 ARM 芯片上的系统,早于任何人想到的 Android 或 [Armbian][2] 之前。
|
||||||
|
|
||||||
|
虽然 Acorn 桌面最终消失了,但 ARM 芯片继续征服世界。在这里,RISC OS 一直有一个优点 - 通常在嵌入式设备中,你从来没有真正地意识到它。RISC OS 过去长期以来一直是一个完全专有的操作系统。但近年来,所有人已经开始将源代码发布到一个名为 [RISC OS Open][3] 的项目中。
|
||||||
|
|
||||||
|
### 1\. 你可以将它安装在树莓派上
|
||||||
|
|
||||||
|
树莓派的官方操作系统 [Raspbian][4] 实际上非常棒(但如果你对摆弄不同技术上新奇的东西不敢兴趣,那么你可能最初也不会选择树莓派)。由于 RISC OS 是专门为 ARM 编写的,因此它可以在各种小型计算机上运行,包括树莓派的各个型号。
|
||||||
|
|
||||||
|
### 2\. 它超轻量级
|
||||||
|
|
||||||
|
我的树莓派上安装的 RISC 系统占用了几百兆 - 就是在我加载了数十个程序和游戏之后。其中大多数时候不大于 1 兆。
|
||||||
|
|
||||||
|
如果你真的节俭,RISC OS Pico 可用在 16MB SD 卡上。如果你在嵌入式系统或物联网项目中 hack 某些东西,这是很完美的。当然,16MB 实际上比压缩到 512KB 的老 Archimedes 的 ROM 要多得多。但我想 30 年间内存的发展,我们可以稍微放宽一下了。
|
||||||
|
|
||||||
|
### 3\. 它非常适合复古游戏
|
||||||
|
|
||||||
|
当 Archimedes 处于鼎盛时期时,ARM CPU 的速度比 Apple Macintosh 和 Commodore Amiga 中的 Motorola 68000 要快几倍,它也完全吸了新的 386。这使得它成为对游戏开发者有吸引力的一个平台,他们希望用这个星球上最强大的桌面计算机来支撑他们的东西。
|
||||||
|
|
||||||
|
这些游戏的许多拥有者都非常慷慨,允许业余爱好者免费下载他们的老作品。虽然 RISC OS 和硬件已经发展了,但只需要进行少量的调整就可以让它们运行起来。
|
||||||
|
|
||||||
|
如果你有兴趣探索这个,[这里有一个指南][5]让这些游戏在你的树莓派上运行。
|
||||||
|
|
||||||
|
### 4\. 它有 BBC BASIC
|
||||||
|
|
||||||
|
就像过去一样,按下 F12 进入命令行,输入 `*BASIC`,就可以看到一个完整的 BBC BASIC 解释器。
|
||||||
|
|
||||||
|
对于那些在 80 年代没有接触过的人,请让我解释一下:BBC BASIC 是当时我们很多人的第一个编程语言,因为它专门教孩子如何编码。当时有大量的书籍和杂志文章教我们编写自己的简单但高度可玩的游戏。
|
||||||
|
|
||||||
|
几十年后,对于一个想要在学校假期做点什么的有技术头脑的孩子而言,在 BBC BASIC 上编写自己的游戏仍然是一个很棒的项目。但很少有孩子在家里有 BBC micro。那么他们应该怎么做呢?
|
||||||
|
|
||||||
|
没问题,你可以在每台家用电脑上运行解释器,但是当别人需要使用它时就不能用了。那么为什么不使用装有 RISC OS 的树莓派呢?
|
||||||
|
|
||||||
|
### 5\. 它是一个简单的单用户操作系统
|
||||||
|
|
||||||
|
RISC OS 不像 Linux 一样有自己的用户和超级用户访问权限。它有一个用户并可以完全访问整个机器。因此,它可能不是跨企业部署的最佳日常驱动,甚至不适合给爷爷做银行业务。但是,如果你正在寻找可以用来修改和 hack 的东西,那绝对是太棒了。你和机器之间没有那么多,所以你可以直接进去。
|
||||||
|
|
||||||
|
### 扩展阅读
|
||||||
|
|
||||||
|
如果你想了解有关此操作系统的更多信息,请查看 [RISC OS Open][3],或者将镜像烧到闪存到卡上并开始使用它。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/7/gentle-intro-risc-os
|
||||||
|
|
||||||
|
作者:[James Mawson][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/dxmjames
|
||||||
|
[1]:https://en.wikipedia.org/wiki/Acorn_Archimedes
|
||||||
|
[2]:https://www.armbian.com/
|
||||||
|
[3]:https://www.riscosopen.org/content/
|
||||||
|
[4]:https://www.raspbian.org/
|
||||||
|
[5]:https://www.riscosopen.org/wiki/documentation/show/Introduction%20to%20RISC%20OS
|
243
translated/tech/20180911 Tools Used in 6.828.md
Normal file
243
translated/tech/20180911 Tools Used in 6.828.md
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
6.828 中使用的工具
|
||||||
|
======
|
||||||
|
### 6.828 中使用的工具
|
||||||
|
|
||||||
|
在这个课程中你将使用两套工具:一个是 x86 模拟器 QEMU,它用来运行你的内核;另一个是编译器工具链,包括汇编器、链接器、C 编译器、以及调试器,它们用来编译和测试你的内核。本文有你需要去下载和安装你自己的副本相关信息。本课程假定你熟悉所有出现的 Unix 命令的用法。
|
||||||
|
|
||||||
|
我们强烈推荐你使用一个 Debathena 机器,比如 athena.dialup.mit.edu,去做你的实验。如果你使用 MIT 的运行在 Linux 上的 Athena 机器,那么本课程所需要的所有软件工具都在 6.828 的存储中:只需要输入 'add -f 6.828' 就可以访问它们。
|
||||||
|
|
||||||
|
如果你不使用一个 Debathena 机器,我们建议你使用一台 Linux 虚拟机。如果是这样,你可以在你的 Linux 虚拟机上构建和安装工具。我们将在下面介绍如何在 Linux 和 MacOS 计算上来构建和安装工具。
|
||||||
|
|
||||||
|
在 [Cygwin][1] 的帮助下,在窗口中运行这个开发环境也是可行的。安装 cygwin,并确保安装了 flex 和 bison 包(它们在开发头下面)。
|
||||||
|
|
||||||
|
对于 6.828 中使用的工具中的有用的命令,请参考[实验工具指南][2]。
|
||||||
|
|
||||||
|
#### 编译器工具链
|
||||||
|
|
||||||
|
一个 “编译器工具链“ 是一套程序,包括一个 C 编译器、汇编器、和链接器,使用它们来将代码转换成可运行的二进制文件。你需要一个能够生成在 32 位 Intel 架构(x86 架构)上运行的 ELF 二进制格式程序的编译器工具链。
|
||||||
|
|
||||||
|
##### 测试你的编译器工具链
|
||||||
|
|
||||||
|
现代的 Linux 和 BSD UNIX 发行版已经为 6.828 提供了一个合适的工具链。去测试你的发行版,可以输入如下的命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
% objdump -i
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
第二行应该是 `elf32-i386`。
|
||||||
|
|
||||||
|
```
|
||||||
|
% gcc -m32 -print-libgcc-file-name
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
这个命令应该会输出如 `/usr/lib/gcc/i486-linux-gnu/version/libgcc.a` 或 `/usr/lib/gcc/x86_64-linux-gnu/version/32/libgcc.a` 这样的东西。
|
||||||
|
|
||||||
|
如果这些命令都运行成功,说明你的工具链都已安装,你不需要去编译你自己的工具链。
|
||||||
|
|
||||||
|
如果 gcc 命令失败,你可能需要去安装一个开发环境。在 Ubuntu Linux 上,输入如下的命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
% sudo apt-get install -y build-essential gdb
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
在 64 位的机器上,你可能需要去安装一个 32 位的支持库。链接失败的表现是有一个类似于 "`__udivdi3` not found" 和 "`__muldi3` not found” 的错误信息。在 Ubuntu Linux 上,输入如下的命令去尝试修复这个问题:
|
||||||
|
|
||||||
|
```
|
||||||
|
% sudo apt-get install gcc-multilib
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 使用一个虚拟机
|
||||||
|
|
||||||
|
获得一个兼容的工具链的最容易的另外的方法是,在你的计算机上安装一个现代的 Linux 发行版。使用虚拟化平台,Linux 可以与你正常的计算环境和平共处。安装一个 Linux 虚拟机共有两步。首先,去下载一个虚拟化平台。
|
||||||
|
|
||||||
|
* [**VirtualBox**][3](对 Mac、Linux、Windows 免费)— [下载地址][3]
|
||||||
|
* [VMware Player][4](对 Linux 和 Windows 免费,但要求注册)
|
||||||
|
* [VMware Fusion][5](可以从 IS&T 免费下载)。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VirtualBox 有点慢并且灵活性欠佳,但它免费!
|
||||||
|
|
||||||
|
虚拟化平台安装完成后,下载一个你选择的 Linux 发行版的引导磁盘镜像。
|
||||||
|
|
||||||
|
* 我们使用的是 [Ubuntu 桌面版][6]。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
这将下载一个命名类似于 `ubuntu-10.04.1-desktop-i386.iso` 的文件。启动你的虚拟化平台并创建一个新(32 位)的虚拟机。使用下载的 Ubuntu 镜像作为一个引导磁盘;安装过程在不同的虚拟机上有所不同,但都很简单。就像上面一样输入 `objdump -i`,去验证你的工具是否已安装。你将在虚拟机中完成你的工作。
|
||||||
|
|
||||||
|
##### 构建你自己的编译器工具链
|
||||||
|
|
||||||
|
在设置上你将花一些时间,但是比起一个虚拟机来说,它的性能要稍好一些,并且让你工作在你熟悉的环境中(Unix/MacOS)。对于 MacOS 命令,你可以快进到文章的末尾部分去看。
|
||||||
|
|
||||||
|
###### Linux
|
||||||
|
|
||||||
|
通过将下列行添加到 `conf/env.mk` 中去使用你自己的工具链:
|
||||||
|
|
||||||
|
```
|
||||||
|
GCCPREFIX=
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
我们假设你将工具链安装到了 `/usr/local` 中。你将需要大量的空间(大约 1 GB)去编译工具。如果你空间不足,在它的 `make install` 步骤之后删除它们的目录。
|
||||||
|
|
||||||
|
下载下列包:
|
||||||
|
|
||||||
|
+ ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
|
||||||
|
+ https://www.mpfr.org/mpfr-3.1.2/mpfr-3.1.2.tar.bz2
|
||||||
|
+ http://www.multiprecision.org/downloads/mpc-0.9.tar.gz
|
||||||
|
+ http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2
|
||||||
|
+ http://ftpmirror.gnu.org/gcc/gcc-4.6.4/gcc-core-4.6.4.tar.bz2
|
||||||
|
+ http://ftpmirror.gnu.org/gdb/gdb-7.3.1.tar.bz2
|
||||||
|
|
||||||
|
(你可能也在使用这些包的最新版本。)解包并构建。绿色粗体文本显示如何安装到 `/usr/local` 中,它是我们建议的。要安装到不同的目录,$PFX,注意高亮输入处的不同。如果有问题,可以看下面。
|
||||||
|
|
||||||
|
```c
|
||||||
|
export PATH=$PFX/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=$PFX/lib:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
tar xjf gmp-5.0.2.tar.bz2
|
||||||
|
cd gmp-5.0.2
|
||||||
|
./configure --prefix=$PFX
|
||||||
|
make
|
||||||
|
make install # This step may require privilege (sudo make install)
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
tar xjf mpfr-3.1.2.tar.bz2
|
||||||
|
cd mpfr-3.1.2
|
||||||
|
./configure --prefix=$PFX --with-gmp=$PFX
|
||||||
|
make
|
||||||
|
make install # This step may require privilege (sudo make install)
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
tar xzf mpc-0.9.tar.gz
|
||||||
|
cd mpc-0.9
|
||||||
|
./configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX
|
||||||
|
make
|
||||||
|
make install # This step may require privilege (sudo make install)
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
|
||||||
|
tar xjf binutils-2.21.1.tar.bz2
|
||||||
|
cd binutils-2.21.1
|
||||||
|
./configure --prefix=$PFX --target=i386-jos-elf --disable-werror
|
||||||
|
make
|
||||||
|
make install # This step may require privilege (sudo make install)
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
i386-jos-elf-objdump -i
|
||||||
|
# Should produce output like:
|
||||||
|
# BFD header file version (GNU Binutils) 2.21.1
|
||||||
|
# elf32-i386
|
||||||
|
# (header little endian, data little endian)
|
||||||
|
# i386...
|
||||||
|
|
||||||
|
|
||||||
|
tar xjf gcc-core-4.6.4.tar.bz2
|
||||||
|
cd gcc-4.6.4
|
||||||
|
mkdir build # GCC will not compile correctly unless you build in a separate directory
|
||||||
|
cd build
|
||||||
|
../configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX \
|
||||||
|
--target=i386-jos-elf --disable-werror \
|
||||||
|
--disable-libssp --disable-libmudflap --with-newlib \
|
||||||
|
--without-headers --enable-languages=c MAKEINFO=missing
|
||||||
|
make all-gcc
|
||||||
|
make install-gcc # This step may require privilege (sudo make install-gcc)
|
||||||
|
make all-target-libgcc
|
||||||
|
make install-target-libgcc # This step may require privilege (sudo make install-target-libgcc)
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
i386-jos-elf-gcc -v
|
||||||
|
# Should produce output like:
|
||||||
|
# Using built-in specs.
|
||||||
|
# COLLECT_GCC=i386-jos-elf-gcc
|
||||||
|
# COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.4/lto-wrapper
|
||||||
|
# Target: i386-jos-elf
|
||||||
|
|
||||||
|
|
||||||
|
tar xjf gdb-7.3.1.tar.bz2
|
||||||
|
cd gdb-7.3.1
|
||||||
|
./configure --prefix=$PFX --target=i386-jos-elf --program-prefix=i386-jos-elf- \
|
||||||
|
--disable-werror
|
||||||
|
make all
|
||||||
|
make install # This step may require privilege (sudo make install)
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Linux 排错
|
||||||
|
|
||||||
|
* Q:我不能运行 `make install`,因为我在这台机器上没有 root 权限。
|
||||||
|
A:我们的指令假定你是安装到了 `/usr/local` 目录中。但是,在你的环境中可能并不是这样做的。如果你仅能够在你的 home 目录中安装代码。那么在上面的命令中,使用 `--prefix=$HOME`(并[点击这里][7] 去更新后面的命令)去替换 `--prefix=/usr/local`。你也需要修改你的 `PATH` 和 `LD_LIBRARY_PATH` 环境变量,以通知你的 shell 这个工具的位置。例如:
|
||||||
|
```
|
||||||
|
export PATH=$HOME/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
在你的 `~/.bashrc` 文件中输入这些行,以便于你登入后不需要每次都输入它们。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Q:我构建失败了,错误信息是 "library not found”。
|
||||||
|
A:你需要去设置你的 `LD_LIBRARY_PATH`。环境变量必须包含 `PREFIX/lib` 目录(例如 `/usr/local/lib`)。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### MacOS
|
||||||
|
|
||||||
|
首先从 Mac OSX 上安装开发工具开始:
|
||||||
|
`xcode-select --install`
|
||||||
|
|
||||||
|
你可以从 homebrew 上安装 qemu 的依赖,但是不能去安装 qemu,因为我们需要安装打了 6.828 补丁的 qemu。
|
||||||
|
|
||||||
|
`brew install $(brew deps qemu)`
|
||||||
|
|
||||||
|
gettext 工具并不能把已安装的二进制文件添加到路径中,因此你需要去运行:
|
||||||
|
|
||||||
|
`PATH=${PATH}:/usr/local/opt/gettext/bin make install`
|
||||||
|
|
||||||
|
完成后,开始安装 qemu。
|
||||||
|
|
||||||
|
### QEMU 模拟器
|
||||||
|
|
||||||
|
[QEMU][8] 是一个现代化的、并且速度非常快的 PC 模拟器。QEMU 的 2.3.0 版本是设置在 Athena 上的 6.828 中的 x86 机器存储中的(`add -f 6.828`)。
|
||||||
|
|
||||||
|
不幸的是,QEMU 的调试功能虽然很强大,但是有点不成熟,因此我们强烈建议你使用我们打过 6.828 补丁的版本,而不是发行版自带的版本。这个安装在 Athena 上的 QEMU 版本已经打过补丁了。构建你自己的、打 6.828 补丁的 QEMU 版本的过程如下:
|
||||||
|
|
||||||
|
1. 克隆 IAP 6.828 QEMU 的 git 仓库:`git clone https://github.com/mit-pdos/6.828-qemu.git qemu`。
|
||||||
|
2. 在 Linux 上,你或许需要安装几个库。我们成功地在 Debian/Ubuntu 16.04 上构建 6.828 版的 QEMU 需要安装下列的库:libsdl1.2-dev、libtool-bin、libglib2.0-dev、libz-dev、和 libpixman-1-dev。
|
||||||
|
3. 配置源代码(方括号中是可选参考;用你自己的真实路径替换 PFX)
|
||||||
|
1. Linux:`./configure --disable-kvm --disable-werror [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]`。
|
||||||
|
2. OS X:`./configure --disable-kvm --disable-werror --disable-sdl [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]`。`prefix` 参数指定安装 QEMU 的位置;如果不指定,将缺省安装 QEMU 到 `/usr/local` 目录中。`target-list` 参数将简单地简化 QEMU 所支持的架构。
|
||||||
|
4. 运行 `make && make install`。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://pdos.csail.mit.edu/6.828/2018/tools.html
|
||||||
|
|
||||||
|
作者:[csail.mit][a]
|
||||||
|
选题:[lujun9972][b]
|
||||||
|
译者:[qhwdw](https://github.com/qhwdw)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://pdos.csail.mit.edu
|
||||||
|
[b]: https://github.com/lujun9972
|
||||||
|
[1]: http://www.cygwin.com
|
||||||
|
[2]: labguide.html
|
||||||
|
[3]: http://www.oracle.com/us/technologies/virtualization/oraclevm/
|
||||||
|
[4]: http://www.vmware.com/products/player/
|
||||||
|
[5]: http://www.vmware.com/products/fusion/
|
||||||
|
[6]: http://www.ubuntu.com/download/desktop
|
||||||
|
[8]: http://www.nongnu.org/qemu/
|
||||||
|
[9]: mailto:6828-staff@lists.csail.mit.edu
|
||||||
|
[10]: https://i.creativecommons.org/l/by/3.0/us/88x31.png
|
||||||
|
[11]: https://creativecommons.org/licenses/by/3.0/us/
|
||||||
|
[12]: https://pdos.csail.mit.edu/6.828/2018/index.html
|
Loading…
Reference in New Issue
Block a user