gcc_none_toolchains
repository.git clone https://fuchsia.googlesource.com/third_party/gcc_none_toolchains
cd <gcc_none_toolchains-dir> ./do-build \ --host x86_64-fuchsia \ --target x86_64-fuchsia \ --sysroot <path-to-target-sysroot> \ --strip
By default, this will leave the compiler in the x86_64-fuchsia-<gcc-ver>-native
subdirectory of the current directory.
gcc_none_toolchains
repository, build the fuchsia-hosted bare-metal tools:./do-build \ --host x86_64-fuchsia \ --target x86_64-none \ --sysroot <path-to-target-sysroot> \ --strip
By default, this will leave the compiler in the x86_64-elf-<gcc-ver>-Fuchsia-x86_64
subdirectory of the current directory.
git clone https://fuchsia.googlesource.com/third_party/make
The following utilities are required by the build scripts. As long as your build manifest included the sbase project, these should have been installed with your Fuchsia build:
uname
which
tr
find
mv
cmp
sort
basename
sed
Follow standard Zircon/Fuchsia source configuration instructions. Note that you will want a minimum of zircon
and sbase
.
In order for gcc-built executables to run in Fuchsia, we will need the gcc runtime libraries, built for Fuchsia. They were built as part of the Fuchsia native build, but we need them to be installed into one of the standard runtime library locations on the target. One way to do this is to add the libraries to the manifest lines in zircon/kernel/engine.mk
:
USER_MANIFEST_LINES += lib/libgcc_s.so.1=<path-to-gcc>/x86_64-fuchsia-6.3.0-native/lib/libgcc_s.so.1 USER_MANIFEST_LINES += lib/libgcc_s.so=<path-to-gcc>/x86_64-fuchsia-6.3.0-native/lib/libgcc_s.so USER_MANIFEST_LINES += lib/libstdc++.so=<path-to-gcc>/x86_64-fuchsia-6.3.0-native/lib/libstdc++.so
Follow the standard Zircon/Fuchsia build instructions, and run the resulting image on the desired target.
Create a new empty directory in the target environment (for this example, we‘ll use /data). For your own sanity, this should be persistent storage of some sort. For this example, we’ll use the following /data subdirectories:
bin Directory for miscellaneous tools not provided in Fuchsia or Zircon gcc Native gcc installation gcc-bare-metal Fuchsia-hosted bare-metal tools zircon The Zircon source files sysroot The sysroot of the installed Fuchsia
/data/gcc
cd <gcc-install-dir>/x86_64-fuchsia-<gcc-ver>-native for filename in `find . -type f` do echo "Copying $filename" netcp "$filename" ":/data/gcc/$filename" done
/data/gcc-bare-metal
cd <gcc-install-dir>/x86_64-elf-gcc-<gcc-ver>-Fuchsia-x86_64 for filename in `find . -type f` do echo "Copying $filename" netcp "$filename" ":/data/gcc-bare-metal/$filename" done
/data/bin
netcp <make-build-dir>/make :/data/bin
cd <path-to-zircon> for filename in `find . -name .git -prune \ -o -path "./build-*" -prune \ -o -path "./prebuilt*" \ -o -type f -print` do echo "Copying $filename" netcp $filename :/data/zircon/$filename done
/data/sysroot
cd <zircon-sysroot> for filename in `find . -type f` do echo "Copying $filename" netcp $filename :/data/sysroot/$filename done
/data/sysroot/lib
cd <path-to-gcc>/x86_64-fuchsia-<gcc-ver>-native for filename in libstdc++.so libgcc_s.so libgcc_s.so.1 do echo "Copying $filename" netcp lib/$filename :/data/sysroot/lib/$filename done
On the Fuchsia target, add /data/bin
, /data/gcc/bin
, and data/gcc-bare-metal/bin
to your PATH
export PATH="$PATH:/data/bin:/data/gcc/bin:/data/gcc-bare-metal/bin"
cd zircon make \ HOST_SYSROOT=/data/sysroot \ ARCH_x86_64_TOOLCHAIN_PREFIX="x86_64-elf-" \ HOST_TOOLCHAIN_PREFIX=""