-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathOr32Toolchain.mw
144 lines (83 loc) · 9.95 KB
/
Or32Toolchain.mw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
== Legacy toolchain ==
The OpenRISC toolchain previously used the or32 prefix instead of or1k. If you encounter any tools starting with or32, this is probably part of the legacy toolchain. No further development is being made on the or32 toolchain, and we recommend that you use the or1k toolchain for all new projects. The or32 toolchain is primarily for projects that for different reasons can't or won't upgrade to the or1k toolchain
=== Precompiled binaries ===
==== Latest version ====
'''Note''': This is not an official release but should still be fine to use.
* [ftp://ocuser:[email protected]/toolchain/openrisc-toolchain-ocsvn-rev789.tar.bz2 for Ubuntu 32-bit] built from SVN rev. 789, also contains [[or1ksim]]
Extract the file under /opt and add the following to your ~/.bashrc (or other shell-appropriate) file. See the [[#1.0rc1|1.0rc1]] section for more detailed instructions regarding the PATH environment variable.
export PATH=$PATH:/opt/openrisc/toolchain/bin:/opt/openrisc/or1ksim/bin
For precompiled versions for other PC architectures see below.
==== 1.0rc1 ====
Pre-compiled binaries are only available for the 1.0rc1 version of the Newlib toolchain. All commands have the prefix or32-elf- (for example or32-elf-gcc). Or1ksim 0.5.1 and newlib 0.18.0 are included.
* [ftp://ocuser:[email protected]/toolchain/or32-elf-1.0rc1-x86.tar.bz2 for Ubuntu x86/i686 (32-bit)]
* [ftp://ocuser:[email protected]/toolchain/or32-elf-1.0rc1-CentOS-x86_64.tar.bz2 for CentOS-5.5 x86_64 (64-bit)]
* [ftp://ocuser:[email protected]/toolchain/or32-elf-1.0rc1-OS_X-10.6.3.tar.bz2 for OS X 10.6 (Snow Leopard)] ('''Note.''' no C++ libraries)
The following commands indicate how to install the toolchain from the download archive. The tools are installed to the /opt path and symbolic links are created to more general path names (which helps with switching to more updated versions of the toolchain later.) The shell's PATH environment variable must be updated so that the tools can be located by the system. Bear in mind that the PATH variable is scanned for matches starting at the beginning and uses the first match it finds. If your system is not finding the correct tools when compiling, you may need to add the or32 tools to the beginning of the PATH and not the end. You may choose to install in any other directory to which you have write access.
cd /opt
tar xjf ''path to downloaded archive''/''archive name''
sudo ln -s or32-elf-1.0rc1 or32-elf
sudo ln -s or1ksim-0.5.1rc1 or1ksim
Having installed the software, add the relevant directories to your PATH.
Under sh or bash use
export PATH=$PATH:/opt/or32-elf/bin:/opt/or1ksim/bin
or, to add the tools to the beginning of the PATH
export PATH=/opt/or32-elf/bin:/opt/or1ksim/bin:$PATH
Under csh or tcsh use:
setenv PATH $PATH:/opt/or32-elf/bin:/opt/or1ksim/bin
or, to add the tools to the beginning of the PATH
setenv PATH /opt/or32-elf/bin:/opt/or1ksim/bin:$PATH
These will typically be added to your .profile, .login, .bashrc, or other shell initialization file as appropriate. Note. If the toolchain was installed in a directory other than /opt, substitute that directory's path for /opt.
=== Building from source ===
Source code for the legacy toolchain can be found in [[http://opencores.org/websvn,listing?repname=openrisc&path=%2Fopenrisc%2Ftrunk%2Fgnu-stable%2F#path_openrisc_trunk_gnu-stable_ OpenCores SVN]]
'''Note''': There has been a recent reorganization of the SVN repository, to reduce the size of the SVN checkout. Rather than a single directory, there are now tree directories, '''gnu-stable''' (for the stable tool chain), '''gnu-old''' (for legacy versions) and '''gnu-dev''' (for experimental versions).
The source for the stable version of the GNU tools and newlib is available under SVN:
svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk/gnu-stable
'''Note''': There is a known problem with SVN timing out. The checkout will seem OK, but not all files are downloaded and no error message is shown. The solution is to repeatedly run the following command until no more files are downloaded.
svn update gnu-stable
The source for uClibc and Linux (needed for the header files for the toolchain) is currently held in a [http://git-scm.com/ git] repository run by [http://southpole.se/ South Pole]. It is best to save the source for these into the gnu-stable path just created when checking out from the OpenCores SVN repository.
cd gnu-stable
git clone git://git.openrisc.net/jonas/uClibc
git clone git://git.openrisc.net/jonas/linux
==== Building ====
'''Warning.''' Before you get here have you installed all the prerequisites, ''including Or1ksim''. See [[#Prerequisites|Prequisites]] for details.
There are two toolchains that can be compiled using different libraries.
* The newlib toolchain, with toolchain executables prefixed by or32-elf- is for compiling applications which will be run on the bare metal, or without an operating system (this includes building the Linux kernel).
* The uClibc toolchain, with toolchain exeutables prefixed by or32-linux- is for compiling software intended to run on Linux, as userspace applications.
The script used to build the toolchains is bld-all.sh and it is found in the gnu-src/ path. It will create a unified build environment when compiling the GNU tools (binutils, GCC, GDB.). For a full list of options provided by the build script, run it with the --help option.
./bld-all.sh --help
The following instructions assume the tools are installed in /opt/openrisc, which is a common choice (/opt/or32 is also popular). Substitute your chosen installation directory in the following instructions. It is assumed that [[Or1ksim]] has been installed in /opt/or1ksim.
To build and install both toolchains from scratch:
./bld-all.sh --force --prefix /opt/openrisc --or1ksim-dir /opt/or1ksim --uclibc-dir uClibc --linux-dir linux
To build and install just the newlib toolchain:
./bld-all.sh --force --prefix /opt/openrisc --or1ksim-dir /opt/or1ksim --no-uclibc --no-or32-linux
To build and install just the uClibc toolchain:
./bld-all.sh --force --prefix /opt/openrisc --or1ksim-dir /opt/or1ksim --uclibc-dir uClibc --linux-dir linux --no-newlib --no-or32-elf
Add the new tools to the path. Under sh or bash
export PATH=$PATH:/opt/openrisc/bin
or, to add the tools to the beginning of the PATH
export PATH=/opt/openrisc/bin:$PATH
Under csh or tcsh
setenv PATH $PATH:/opt/openrisc/bin
or, to add the tools to the beginning of the PATH
setenv PATH /opt/openrisc/bin:$PATH
These commands will typically be added to your .profile, .login, .bashrc, or other shell initialization file.
'''Note.''' Some users have reported problems when rebuilding the uClibc toolchain a second time, due to the existing headers on the search path. The solution is to remove the existing implementation from the PATH variable.
=== Binutils ===
or32 binutils is based on binutils 2.20.1
This version does not support dynamic objects or atomic operations found in the newer version
=== GCC ===
GCC 4.5.1 has been ported to OpenRISC and can be checked out from OpenCores SVN
The key changes since the previous version (4.2.2) are:
* Previous versions of OpenRISC GCC prefixed all global symbols (functions and variables) in the compiled code with an underscore ('_'). Historically this was done to avoid namespace clashes. However with ELF output files it really is no longer needed. GDB struggles with mapping the high level names in the compiled code to the values in the object file symbol table, particularly with STABS debug info.
: Most modern compilers leave global names unchanged for ELF targets. With this version of GCC, we have adopted this convention for OpenRISC. However it will mean that code compiled with the old compiler will not be linkable with code from the new compiler (since the naming convention for globals will be different). Assembler modules which link to global names will also need modifying. This should not cause any problem in practice, since there are not large bodies of pre-compiled library code out there, nor substantial bodies of hand-written assembler.
* Previous versions of OpenRISC GCC generated STABS debugging info by default when -g was used. This is now quite an old, inconsistent and limited format. Most modern compilers generate DWARF2 debugging for -g. DWARF2 offers a richer debugging experience, and is the preferred format for GDB. It is what is generated if you use GCC with -ggdb. With this version of GCC, we have made DWARF2 the default debugging format for OpenRISC GCC. This should not cause compatibility problems. STABS debugging output can still be generated by using -gstabs.
* C++ is supported, but uses only static linking of libraries (since dynamic linking is not currently supported in binutils).
* Function prologues are now much more flexible, being generated by the ''prologue'' pattern in the machine definition.
* The "red zone" is reduced to 128 bytes, but is now actually used (previously it was defined to be 2K, but not used. It is thus essential that interrupt handlers do not use the first 128 bytes of stack. An option -mredzone=''size'' is available to change this, including setting the red zone to zero (which will reduce performance).
* Sibcall optimization is now supported by default.
* The frame pointer is omitted for all optimization levels above -O0.
* Option -maj is no longer supported.
* All regression tests now pass.
* The constants '''OR1K''', '''__or1k__''' and '''__OR1K__''' were not defined in GCC 4.2.2 (they had been in earlier releases). These are now defined.
* GCC 3.4.4. for OpenRISC assumed the availability of hardware multiplication, but not hardware division by default (i.e. -mhard-mul, -msoft-div), which was consistent with the default Verilog configuration. GCC 4.2.2 changed this to assume neither hardware multiplication nor hardware division are present (i.e. -msoft-mul, -msoft-div). The current GCC 4.5.1, has restored the default to -mhard-mul, -msoft-div ofr consistency with the default hardware configuration.
=== Newlib ===