Zircon

摘要:
我自己安装了clang7.0,可以使用它。pt-getinstallclang-7root@cloud:~/zircon2/gn#ls/usr/bin/clang*/usr/bin/cang-7/usr/bin/clag++-7/usr/bin/clang-cpp-7root@cloud:~/zircon2/gn#ln-s/usr/bin/crang-7/usr/bin/clangroot@cloud:~/zircon2/gn#ln-s/usr/bin/crang++-7/usr/bin/clarg++root@cloud:~/zircon2/gn#ln-s/usr/bin/cng-cpp-7/usr/bin/clang-cpproot@cloud:~/锆石2/gn#root@cloud:~/zircon2/gn#clang++--版本clangv7.0.0-3~ubuntu0.18.04.1目标:aarch64未知linux gnuThreadmodel:posixInstalledDir:/usr/binroot@cloud:~/zircon2/gn#编译gn,输入刚下载的gn目录,然后首先执行gn配置脚本/Build/gen。然后在gn目录中执行py:在ninjaOut编译之后,gn程序位于gn/Out目录中。

 zircon代码下载

https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/zircon/

git clone https://github.com/timniederhausen/gn.git

gn的编译需要使用clang编译器,并且gn使用了C++17的语法,所以需要使用较高版本的clang。

我自己安装的是clang 7.0,是可以使用的。

pt-get install clang-7
root@cloud:~/zircon2/gn# ls /usr/bin/clang*
/usr/bin/clang-7  /usr/bin/clang++-7  /usr/bin/clang-cpp-7
root@cloud:~/zircon2/gn# ln -s /usr/bin/clang-7  /usr/bin/clang
root@cloud:~/zircon2/gn# ln -s /usr/bin/clang++-7  /usr/bin/clang++
root@cloud:~/zircon2/gn# ln -s /usr/bin/clang-cpp-7  /usr/bin/clang-cpp
root@cloud:~/zircon2/gn# 
root@cloud:~/zircon2/gn# clang++ --version
clang version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
root@cloud:~/zircon2/gn# 

编译 gn

进入刚才下载的gn目录中,先执行gn的配置脚本。

./build/gen.py

然后在gn目录中执行:

ninja -C out

编译结束后,gn程序就在gn/out目录中。

root@cloud:~/zircon2/gn# cp ./out/gn /usr/bin
root@cloud:~/zircon2/gn# gn --version
1839 (815c8cb7)

 zircon下载

 https://hexang.org/mirrors/fuchsia/-/tree/7eb369f72ffa9f505f56a9168a3b4d6a3ac86de2/zircon

https://hexang.org/mirrors/fuchsia/-/tree/7eb369f72ffa9f505f56a9168a3b4d6a3ac86de2/zircon
root@cloud:~/zircon3# git clone https://hexang.org/mirrors/fuchsia.git
Cloning into 'fuchsia'...
remote: Enumerating objects: 711124, done.
remote: Counting objects: 100% (711124/711124), done.
remote: Compressing objects: 100% (150280/150280), done.
Receiving objects: 100% (711124/711124), 289.00 MiB | 10.71 MiB/s, done.
remote: Total 711124 (delta 531253), reused 711089 (delta 531228), pack-reused 0
Resolving deltas: 100% (531253/531253), done.
Checking out files: 100% (28084/28084), done.
root@cloud:~/zircon3# 
root@cloud:~/zircon3/fuchsia/zircon# gn gen build-zircon
ERROR at //public/gn/toolchain/clang.gni:30:17: Could not read file.
      read_file("$_prebuilt_dir/.versions/clang.cipd_version", "json")
                ^--------------------------------------------
I resolved this to "/root/zircon3/fuchsia/zircon/prebuilt/downloads/clang/.versions/clang.cipd_version".
See //public/gn/toolchain/c_toolchain.gni:6:1: whence it was imported.
import("clang.gni")
^-----------------
See //public/gn/toolchain/environment.gni:6:1: whence it was imported.
import("c_toolchain.gni")
^-----------------------
See //public/gn/toolchain/BUILD.gn:6:1: whence it was imported.
import("environment.gni")
^-----------------------
See //public/gn/toolchain/environment_redirect.gni:263:26: which caused the file to be included.
        public_deps += [ "$label($toolchain_name)" ]
                         ^------------------------
先要运行download-prebuilt
root@cloud:~/zircon3/fuchsia/zircon# ./scripts/download-prebuilt

 路径

readonly URL_PREFIX="https://chrome-infra-packages.appspot.com/dl/fuchsia"

下载完成之后, 在 $ZIRCON 目录下多出来了一个 prebuilt 目录,
从目录中可以看出, 上面的命令下载了以下几个文件.

clang.zip
gcc.zip
qemu.zip
symbolize.zip
sysroot.zi

修改项目工程对clang,gcc的链接路径

clang_tool_dir = "<absolute path to>/clang-install/bin/"
gcc_tool_dir = "<absolute path to>/gcc-install/bin/"
clang_tool_dir = /usr/bin
gcc_tool_dir =/usr/bin
 
root@cloud:~/zircon2/zircon# make build
buildtools/gn gen --export-compile-commands=x64 out
/usr/bin/gn
ERROR at //public/gn/toolchain/clang.gni:89:27: Could not read file.
clang_runtime = read_file(_clang_runtime_file, "json")
                          ^------------------
I resolved this to "/usr/lib/runtime.json".
See //public/gn/toolchain/c_toolchain.gni:6:1: whence it was imported.
import("clang.gni")
^-----------------
See //public/gn/toolchain/environment.gni:6:1: whence it was imported.
import("c_toolchain.gni")
^-----------------------
See //public/gn/toolchain/BUILD.gn:6:1: whence it was imported.
import("environment.gni")
^-----------------------
See //BUILD.gn:35:5: which caused the file to be included.
    group(name) {
    ^------------
Makefile:5: recipe for target 'config' failed
make: *** [config] Error 1

官方CIPD包下载链接如下
下载clang-linux-arm64.zip,解压
public/gn/toolchain/clang.gni
_clang_runtime_file = "/root/zircon2/lib/runtime.json"


make build
buildtools/gn gen --export-compile-commands=x64 out
/usr/bin/gn
Generating compile_commands took 515ms
Done. Made 36734 targets from 1066 files in 6100ms
cd out && ../buildtools/ninja
/usr/bin/gn
ERROR No command specified.
Most commonly you want "gn gen <out_dir>" to make a build dir.
Or try "gn help" for more commands.
Makefile:2: recipe for target 'build' failed
make: *** [build] Error 1
root@cloud:~/zircon2/zircon# grep export-compile-command -rn *
Binary file buildtools/linux-x64/gn matches
Binary file buildtools/mac-x64/gn matches
docs/editors.md:33:gn gen build-zircon --export-compile-commands
Makefile:5:     buildtools/gn gen --export-compile-commands=x64 out
out/build.ninja:4:  command = ../../../../usr/bin/gn --root=./.. -q --export-compile-commands=x64 gen .
root@cloud:~/zircon2/zircon# vi 
root@cloud:~/zircon2/zircon# gn gen build-zircon
ERROR Unresolved dependencies.
//:default(//public/gn/toolchain:stub)
  needs //:ids(//public/gn/toolchain:stub)


Zircon Getting Started
Quick Start Recipes

Checking out the Zircon source code

Note: The Fuchsia source includes Zircon. See Fuchsia's Getting Started doc. Follow this doc to work on only Zircon.

The Zircon Git repository is located at: fuchsia.googlesource.com/zircon

To clone the repository, assuming you setup the $SRC variable in your environment:

git clone https://fuchsia.googlesource.com/zircon $SRC/zircon
复制代码

For the purpose of this document, we will assume that Zircon is checked out in $SRC/zircon and that we will build toolchains, QEMU, etc alongside that. Various ninja invocations are presented with a "-j32" option for parallelization. If that's excessive for the machine you're building on, try -j16 or -j8.

Preparing the build environment

Ubuntu

On Ubuntu this should obtain the necessary pre-reqs:

sudo apt-get install texinfo libglib2.0-dev autoconf libtool bison libsdl-dev build-essential
复制代码

macOS

Install the Xcode Command Line Tools:

xcode-select --install
复制代码

Install the other pre-reqs:

  • Using Homebrew:
brew install wget pkg-config glib autoconf automake libtool
复制代码
  • Using MacPorts:
port install autoconf automake libtool libpixman pkgconfig glib2
复制代码

Install Toolchains and Prebuilts

If you're developing on Linux or macOS, there are prebuilt toolchain binaries available. Just run this script from your Zircon working directory:

./scripts/download-prebuilt
复制代码

If you would like to build the toolchains yourself, follow the instructions later in the document.

Build Zircon

Build results will be in $SRC/zircon/build-zircon.

cd $SRC/zircon
gn gen build-zircon

# for both aarch64 and x64
ninja -C build-zircon

# for aarch64
ninja -C build-zircon arm64

# for x64
ninja -C build-zircon x64
复制代码

Using Clang

To build Zircon using Clang as the target toolchain, set the variants = [ "clang" ] build argument when invoking GN.

cd $SRC/zircon
gn gen build-zircon --args='variants = [ "clang" ]'

# for both aarch64 and x64
ninja -C build-zircon

# for aarch64
ninja -C build-zircon arm64

# for x64
ninja -C build-zircon x64
复制代码

Building Zircon for all targets

# The -r enables release builds as well
./scripts/buildall -r
复制代码

Please build for all targets before submitting to ensure builds work on all architectures.

QEMU

You can skip this if you're only testing on actual hardware, but the emulator is handy for quick local tests and generally worth having around.

See QEMU for information on building and using QEMU with zircon.

Build Toolchains (Optional)

If the prebuilt toolchain binaries do not work for you, you can build your own from vanilla upstream sources.

  • The GCC toolchain is used to build Zircon by default.
  • The Clang toolchain is used to build Zircon if you build with variants = [ "clang" ] or variants = [ "asan" ].
  • The Clang toolchain is also used by default to build host-side code, but any C++14-capable toolchain for your build host should work fine.

Build one or the other or both, as needed for how you want build Zircon.

GCC Toolchain

We use GNU binutils 2.30(*) and GCC 8.2(**), configured with --enable-initfini-array --enable-gold, and with --target=x86_64-elf --enable-targets=x86_64-pep for x86-64 or --target=aarch64-elf for ARM64.

For binutils, we recommend --enable-deterministic-archives but that switch is not necessary to get a working build.

For GCC, it's necessary to pass MAKEOVERRIDES=USE_GCC_STDINT=provide on the make command line. This should ensure that the stdint.h GCC installs is one that works standalone (stdint-gcc.h in the source) rather than one that uses #include_next and expects another stdint.h file installed elsewhere.

Only the C and C++ language support is required and no target libraries other than libgcc are required, so you can use various configure switches to disable other things and make your build of GCC itself go more quickly and use less storage, e.g. --enable-languages=c,c++ --disable-libstdcxx --disable-libssp --disable-libquadmath. See the GCC installation documentation for more details.

You may need various other configure switches or other prerequisites to build on your particular host system. See the GNU documentation.

(*) The binutils 2.30 release has some harmless make check failures in the aarch64-elf and x86_64-elf configurations. These are fixed on the upstream binutils-2_30-branch git branch, which is what we actually build. But the 2.30 release version works fine for building Zircon; it just has some spurious failures in its own test suite.

(**) As of 2008-6-15, GCC 8.2 has not been released yet. There is no released version of GCC that works for building Zircon without backporting some fixes. What we actually use is the upstream gcc-8-branch git branch.

Clang/LLVM Toolchain

We use a trunk snapshot of Clang and update to new snapshots frequently. Any build of recent-enough Clang with support for x86_64 and aarch64 compiled in should work. You'll need a toolchain that also includes the runtime libraries. We normally also use the same build of Clang for the host as well as for the *-fuchsia targets. See here for details on how we build Clang.

Set up build arguments for toolchains

If you're using the prebuilt toolchains, you can skip this step, since the build will find them automatically.

Set the build argument that points to where you installed the toolchains:

# in args.gn or passed to --args
clang_tool_dir = "<absolute path to>/clang-install/bin/"
gcc_tool_dir = "<absolute path to>/gcc-install/bin/"
复制代码

Note that *_tool_dir should have a trailing slash. If the clang or gcc in your PATH works for Zircon, you can just use empty prefixes.

Copying files to and from Zircon

With local link IPv6 configured, the host tool ./build-ARCH/tools/netcp can be used to copy files.

# Copy the file myprogram to Zircon
netcp myprogram :/tmp/myprogram

# Copy the file myprogram back to the host
netcp :/tmp/myprogram myprogram
复制代码

Including Additional Userspace Files

The Zircon build creates a bootfs image containing necessary userspace components for the system to boot (the device manager, some device drivers, etc). The kernel is capable of including a second bootfs image which is provided by QEMU or the bootloader as a ramdisk image.

To create such a bootfs image, use the zbi tool that's generated as part of the build. It can assemble a bootfs image for either source directories (in which case every file in the specified directory and its subdirectories are included) or via a manifest file which specifies on a file-by-file basis which files to include.

$BUILDDIR/tools/zbi -o extra.bootfs @/path/to/directory

echo "issue.txt=/etc/issue" > manifest
echo "etc/hosts=/etc/hosts" >> manifest
$BUILDDIR/tools/zbi -o extra.bootfs manifest
复制代码

On the booted Zircon system, the files in the bootfs will appear under /boot, so in the above manifest example, the "hosts" file would appear at /boot/etc/hosts.

Network Booting

Network booting is supported via two mechanisms: Gigaboot and Zirconboot. Gigaboot is an EFI based bootloader whereas zirconboot is a mechanism that allows a minimal zircon system to serve as a bootloader for zircon.

On systems that boot via EFI (such as Acer and NUC), either option is viable. On other systems, zirconboot may be the only option for network booting.

Via Gigaboot

The GigaBoot20x6 bootloader speaks a simple network boot protocol (over IPV6 UDP) which does not require any special host configuration or privileged access to use.

It does this by taking advantage of IPV6 Link Local Addressing and Multicast, allowing the device being booted to advertise its bootability and the host to find it and send a system image to it.

If you have a device (for example a Broadwell or Skylake Intel NUC) running GigaBoot20x6, first create a USB drive.

$BUILDDIR/tools/bootserver $BUILDDIR/zircon.bin

# if you have an extra bootfs image (see above):
$BUILDDIR/tools/bootserver $BUILDDIR/zircon.bin /path/to/extra.bootfs
复制代码

By default bootserver will continue to run and every time it observes a netboot beacon it will send the kernel (and bootfs if provided) to that device. If you pass the -1 option, bootserver will exit after a successful boot instead.

Via Zirconboot

Zirconboot is a mechanism that allows a zircon system to serve as the bootloader for zircon itself. Zirconboot speaks the same boot protocol as Gigaboot described above.

To use zirconboot, pass the netsvc.netboot=true argument to zircon via the kernel command line. When zirconboot starts, it will attempt to fetch and boot into a zircon system from a bootserver running on the attached host.

Network Log Viewing

The default build of Zircon includes a network log service that multicasts the system log over the link local IPv6 UDP. Please note that this is a quick hack and the protocol will certainly change at some point.

For now, if you're running Zircon on QEMU with the -N flag or running on hardware with a supported ethernet interface (ASIX USB Dongle or Intel Ethernet on NUC), the loglistener tool will observe logs broadcast over the local link:

$BUILDDIR/tools/loglistener
复制代码

Debugging

For random tips on debugging in the zircon environment see debugging.

Contribute changes

免责声明:文章转载自《Zircon》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇nuxt.js怎么写一个全局的自定义指令微软RDLC报表打印下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

再见,Java 8!Java 17 终于免费了,史上最快的 JDK。。

文 | 局长 出品 | OSC开源社区(ID:oschina2013) Java 17 已正式发布,新版本提供了不少新特性和功能增强。不过对于大多数项目而言,往往需要更改代码才能利用到这些新变化,但性能除外 —— 开发者只需要升级 JDK 版本,就能免费获得性能提升。 规划调度引擎 OptaPlanner 项目负责人对 JDK 17、JDK 16 和 JD...

Eclipse 一直不停 building workspace完美解决总结

一、产生这个问题的原因多种1、自动升级 2、未正确关闭3、maven下载lib挂起 等.. 二、解决总结(1)、解决方法方法1.修改eclipse启动文件 eclipse.ini 中添加启动参数参数: -vmargs -Xmx512m方法2.关闭自动构建工作区: project -> build Auto….. 方法3.在eclipse.ini式中添...

Windos Linux(CentOS 7) opencv安装 tar.gz文件安装

前提: 版本为4.4.0 下载地址:https://github.com/opencv/opencv/releases windows 下载.exe 安装之后 复制2个文件: buildjavaopencv-440.jar, buildjavax64opencv_java440.dll 调用列子如下: //windows 版本...

在Mac OSX EI Capitan下安装xgboost的吐血经历

官网上mac的安装并不复杂,但是实际操作下来有够吐血的,试了n多方法折腾到凌晨一点。。。。。。 在此详细记录一下以帮助其他踩坑的同学。 前情回顾: 为啥要安装gcc?为了xgboost能够多线程。。。好吧其实我本意并不在此,主要是最简单的单线程我都安装失败了!!就两步简单的操作为什么会失败呢我也不想的啊。。。。。。但是没有关于失败处理的博客,博客都是关于多...

petalinux2019.2 zcu106 build error

ug1209 1. Create a PetaLinux project using the following command:$petalinux-create -t project -s <path to the directory that hasxilinx-zcu102-v2019.2-final.bsp> petalinux-cr...

kettle 连接Hadoop 遇错

kettle从windows中往hdfs中写文件 One 2016/07/19 14:14:53 - Spoon - 正在开始任务... 2016/07/19 14:14:53 - load_hdfs - 开始执行任务 2016/07/19 14:14:53 - load_hdfs - 开始项[Hadoop Copy Files] 2016/07/19...