I am writing this blog for my own reference. I am novice to open source development and this is a learning process for me. My documentation may be wrong/stupid/complete BS. If u find any mistakes, pls post it. I will correct it.
I dont know whether I will complete this or not. Lets see.....
Found this project on Freebsd ideas page. This involves porting Freebsd to openrisc platform. First step is to build toolchain for Freebsd.
This document explains how to add a new OS to GNU toolchain
http://wiki.osdev.org/OS_Specific_Toolchain#Binutils
This page contains details on OPENRISC toolchain building steps
http://openrisc.net/toolchain-build.html
Building Binutils:
I got the source from github and started building binutils which is the first step
1. No need to edit config.sub since Freebsd is already added
2. Next bfd/config.bfd says there is no support for this TARGET
So I edited the file and added the following lines after or1k-linux
or1k-*-elf | or1k-*-freebsd*)
targ_defvec=bfd_elf32_or1k_vec
;;
or1knd-*-elf | or1knd-*-freebsd*)
targ_defvec=bfd_elf32_or1k_vec
;;
3. ran configure and got the error that some file in doc folder (binutils.tex)is missing
found the solution to run with "--enable-maintainer-mode" option in configure script
4. configure succeeded
5. Now running make command
6. make failed with following error
I dont know whether I will complete this or not. Lets see.....
Found this project on Freebsd ideas page. This involves porting Freebsd to openrisc platform. First step is to build toolchain for Freebsd.
This document explains how to add a new OS to GNU toolchain
http://wiki.osdev.org/OS_Specific_Toolchain#Binutils
This page contains details on OPENRISC toolchain building steps
http://openrisc.net/toolchain-build.html
Building Binutils:
I got the source from github and started building binutils which is the first step
1. No need to edit config.sub since Freebsd is already added
2. Next bfd/config.bfd says there is no support for this TARGET
So I edited the file and added the following lines after or1k-linux
or1k-*-elf | or1k-*-freebsd*)
targ_defvec=bfd_elf32_or1k_vec
;;
or1knd-*-elf | or1knd-*-freebsd*)
targ_defvec=bfd_elf32_or1k_vec
;;
3. ran configure and got the error that some file in doc folder (binutils.tex)is missing
found the solution to run with "--enable-maintainer-mode" option in configure script
4. configure succeeded
5. Now running make command
6. make failed with following error
configure.in:21: error: Please use exactly Autoconf 2.64 instead of 2.69.
../config/override.m4:12: _GCC_AUTOCONF_VERSION_CHECK is expanded from...
configure.in:21: the top level
to fix this i edited override.m4 file and change version 2.64 to 2.69
7. struck at
Makefile.am (bfdver.h): Substitute report_bugs_to. Also create doc/bfdver.texi. in make
apparently there is rule to create this file in Makefile.am. Unfortunately it is not run.
8. found that it is enough to run configure script in the src directory directly.
9. ran ./configure --target=or1k-freebsd
it completed
the make failed ld
10. adding the option to ld
added this, line ld/configure.tgt
or1k-*-freebsd* | or1knd-*-freebsd*) targ_emul=elf32or1k ;;
other bsd targets had _fbsd extension. It throwed some error when configured like that.
so leaving as elf as used by rtems. need to revisit
11. ld compiled and faced error with libiberty apparrently lacking -fPIC flag.
Error is
relocation R_X86_64_32S against `ro_data' can not be used when making a
shared object; recompile with -fPIC
to fix this I manually added -fPIC to PICFLAG if libiberty/Makefile.
libiberty is newly created in pic directory
after this I manually executed "make command" that created the binaries
12. Then running make, continued for some time
13 Now struck at
relocation R_X86_64_32S against `_sch_istable'
can not be used when making a shared object; recompile with -fPIC
Its 1 AM in the night. I will carry on tomo
14. I recompiled with -fPIC. Added it in the makefile.am
15. After that struck at, or1ksim.h not found. Apparently you need to build the simulator
library (-lsim) before building toolchain. I did not do this. If you compile or1ksim,
you will get this file and -lsim library.
source is found at https://github.com/openrisc/or1ksim
16. after building or1ksim, build succeeded. But it is not linked properly and got undefined
reference errors (or1ksim_init). to fix this I added the installed library path to
makefile. Make clean is needed. Lets see hwo it goes
17. You need to install or1ksim in this specific directory otherwise gdb compilation failed
"/opt/or1ksim". this can be done when u give configure just add the prefix to
this directory
18. After this too gdb failed. Apparently because -lsim is not included.
To fix this, I edit the make file to include -lsim later
19. After this compiling rda directory failed saying c compiler not working. This seems
to be because it expects gcc for freebsd already exists. I copied the rda directory to
or1k-freebsd directory and ran the following commands
cd or1k-freebsd/rda/ 1584 ./configure --prefix=$PREFIX --target=$TARGET 1585 make 1586 make install
20. after this make succeeded
21. make install installed binaries on the path specified by PREFIX
next step is to compile GCC
GCC compilation steps
1. Follow the osdev wiki on adding new target os to add the required platform
in specific files. ex, edit gcc/config.gcc and libgcc/config.guess and add your platform
2. Apparently you need to give freebsd9 or freebsd10 while mentioning target because this
is must or else build will fail complaining that "FBSD_MAJOR" is not define
3. It is better to follow linux implementation and add whatever is needed
4. Now it says SYSROOT directory is not present I mkdir the directory, after this build proceeded.
5. Now it says freebsd-unwind.h is not present
This error came because I added "md_unwind_header" to or1k-freebsd target.
This is not needed and default "no-unwind.h" will be used
6. Now fatal error: sys/_types.h: No such file or directory error is seen
0 comments:
Post a Comment