On Wed, May 15, 2019 at 9:28 AM Jim Wilson <
ji...@sifive.com> wrote:
> On Tue, May 14, 2019 at 10:51 PM f laddu <
fkl...@gmail.com> wrote:
> > --> can we Build a Canadian Tool of Linux for Windows?, if yes, then what is it's a procedure
I see in your riscv-gnu-toolchain issue that you specifically want a
riscv-linux targetted compiler. You didn't mention that here, and I
was assuming you wanted a riscv-elf target.
Building a linux compiler from scratch is significantly more difficult
than building an embedded elf compiler from scratch. I wouldn't
recommend it. Use a tool like crosstool-ng instead.
There is a complication with a linux compiler that you really need to
use the same glibc and linux kernel version as the linux that the
target will be running. Otherwise you might end up building
riscv-linux programs that won't run on the riscv-linux target. Using
a tool like crosstool-ng complicates this a bit, as then you need to
tell crosstool-ng which glibc version and linux version is on the
target. But if you already have a target running linux, then there is
another simpler (well, for me at least) way to do this. You can
create a sysroot from the target, where the sysroot contains
everything the compiler needs, e.g. /usr/include, /lib, /usr/lib, and
any target specific directories such as /lib64 for a 64-bit target.
You can then use --with-sysroot= when configuring binutils and gcc to
tell it to use the sysroot you copied from the target. You don't need
to build glibc in this case, since you already gave a copy of it to
gcc. So you can now do this like an embedded elf bulid, where you can
configure build install a windows binutils/gdb/gcc, configure build
install a riscv-linux binutils/gdb/gcc, and then configure build
install the windows-cross-riscv-linux binutils/gdb/gcc. The windows
build still needs to be done with newlib and cygwin dropped into the
gcc source dir, but the two riscv-linux builds use --with-sysroot= for
the library.
Jim