📄 install-old.texi
字号:
is used to form the configuration file names.
Thus, if you specify @samp{m68k-local}, configuration uses
files @file{m68k.md}, @file{local.h}, @file{m68k.c},
@file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the
directory @file{config/m68k}.
Here is a list of configurations that have special treatment or special
things you must know:
@table @samp
@item vax-dec-vms
See @ref{VMS Install}, for details on how to install GNU CC on VMS.
@end table
@node Cross-Compiler
@section Building and Installing a Cross-Compiler
@cindex cross-compiler, installation
GNU CC can function as a cross-compiler for many machines, but not all.
@itemize @bullet
@item
Cross-compilers for the Mips as target using the Mips assembler
currently do not work, because the auxiliary programs
@file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on
anything but a Mips. It does work to cross compile for a Mips
if you use the GNU assembler and linker.
@item
Cross-compilers between machines with different floating point formats
have not all been made to work. GNU CC now has a floating point
emulator with which these can work, but each target machine description
needs to be updated to take advantage of it.
@item
Cross-compilation between machines of different word sizes is
somewhat problematic and sometimes does not work.
@end itemize
Since GNU CC generates assembler code, you probably need a
cross-assembler that GNU CC can run, in order to produce object files.
If you want to link on other than the target machine, you need a
cross-linker as well. You also need header files and libraries suitable
for the target machine that you can install on the host machine.
@menu
* Steps of Cross:: Using a cross-compiler involves several steps
that may be carried out on different machines.
* Configure Cross:: Configuring a cross-compiler.
* Tools and Libraries:: Where to put the linker and assembler, and the C library.
* Cross Headers:: Finding and installing header files
for a cross-compiler.
* Build Cross:: Actually compiling the cross-compiler.
@end menu
@node Steps of Cross
@subsection Steps of Cross-Compilation
To compile and run a program using a cross-compiler involves several
steps:
@itemize @bullet
@item
Run the cross-compiler on the host machine to produce assembler files
for the target machine. This requires header files for the target
machine.
@item
Assemble the files produced by the cross-compiler. You can do this
either with an assembler on the target machine, or with a
cross-assembler on the host machine.
@item
Link those files to make an executable. You can do this either with a
linker on the target machine, or with a cross-linker on the host
machine. Whichever machine you use, you need libraries and certain
startup files (typically @file{crt@dots{}.o}) for the target machine.
@end itemize
It is most convenient to do all of these steps on the same host machine,
since then you can do it all with a single invocation of GNU CC. This
requires a suitable cross-assembler and cross-linker. For some targets,
the GNU assembler and linker are available.
@node Configure Cross
@subsection Configuring a Cross-Compiler
To build GNU CC as a cross-compiler, you start out by running
@file{configure}. Use the @option{--target=@var{target}} to specify the
target type. If @file{configure} was unable to correctly identify the
system you are running on, also specify the @option{--build=@var{build}}
option. For example, here is how to configure for a cross-compiler that
produces code for an HP 68030 system running BSD on a system that
@file{configure} can correctly identify:
@smallexample
./configure --target=m68k-hp-bsd4.3
@end smallexample
@node Tools and Libraries
@subsection Tools and Libraries for a Cross-Compiler
If you have a cross-assembler and cross-linker available, you should
install them now. Put them in the directory
@file{/usr/local/@var{target}/bin}. Here is a table of the tools
you should put in this directory:
@table @file
@item as
This should be the cross-assembler.
@item ld
This should be the cross-linker.
@item ar
This should be the cross-archiver: a program which can manipulate
archive files (linker libraries) in the target machine's format.
@item ranlib
This should be a program to construct a symbol table in an archive file.
@end table
The installation of GNU CC will find these programs in that directory,
and copy or link them to the proper place to for the cross-compiler to
find them when run later.
The easiest way to provide these files is to build the Binutils package
and GAS. Configure them with the same @option{--host} and @option{--target}
options that you use for configuring GNU CC, then build and install
them. They install their executables automatically into the proper
directory. Alas, they do not support all the targets that GNU CC
supports.
If you want to install libraries to use with the cross-compiler, such as
a standard C library, put them in the directory
@file{/usr/local/@var{target}/lib}; installation of GNU CC copies
all the files in that subdirectory into the proper place for GNU CC to
find them and link with them. Here's an example of copying some
libraries from a target machine:
@example
ftp @var{target-machine}
lcd /usr/local/@var{target}/lib
cd /lib
get libc.a
cd /usr/lib
get libg.a
get libm.a
quit
@end example
@noindent
The precise set of libraries you'll need, and their locations on
the target machine, vary depending on its operating system.
@cindex start files
Many targets require ``start files'' such as @file{crt0.o} and
@file{crtn.o} which are linked into each executable; these too should be
placed in @file{/usr/local/@var{target}/lib}. There may be several
alternatives for @file{crt0.o}, for use with profiling or other
compilation options. Check your target's definition of
@code{STARTFILE_SPEC} to find out what start files it uses.
Here's an example of copying these files from a target machine:
@example
ftp @var{target-machine}
lcd /usr/local/@var{target}/lib
prompt
cd /lib
mget *crt*.o
cd /usr/lib
mget *crt*.o
quit
@end example
@node Cross Headers
@subsection Cross-Compilers and Header Files
If you are cross-compiling a standalone program or a program for an
embedded system, then you may not need any header files except the few
that are part of GNU CC (and those of your program). However, if you
intend to link your program with a standard C library such as
@file{libc.a}, then you probably need to compile with the header files
that go with the library you use.
The GNU C compiler does not come with these files, because (1) they are
system-specific, and (2) they belong in a C library, not in a compiler.
If the GNU C library supports your target machine, then you can get the
header files from there (assuming you actually use the GNU library when
you link your program).
If your target machine comes with a C compiler, it probably comes with
suitable header files also. If you make these files accessible from the host
machine, the cross-compiler can use them also.
Otherwise, you're on your own in finding header files to use when
cross-compiling.
When you have found suitable header files, put them in the directory
@file{/usr/local/@var{target}/include}, before building the cross
compiler. Then installation will run fixincludes properly and install
the corrected versions of the header files where the compiler will use
them.
Provide the header files before you build the cross-compiler, because
the build stage actually runs the cross-compiler to produce parts of
@file{libgcc.a}. (These are the parts that @emph{can} be compiled with
GNU CC.) Some of them need suitable header files.
Here's an example showing how to copy the header files from a target
machine. On the target machine, do this:
@example
(cd /usr/include; tar cf - .) > tarfile
@end example
Then, on the host machine, do this:
@example
ftp @var{target-machine}
lcd /usr/local/@var{target}/include
get tarfile
quit
tar xf tarfile
@end example
@node Build Cross
@subsection Actually Building the Cross-Compiler
Now you can proceed just as for compiling a single-machine compiler
through the step of building stage 1.
If your target is exotic, you may need to provide the header file
@file{float.h}.One way to do this is to compile @file{enquire} and run
it on your target machine. The job of @file{enquire} is to run on the
target machine and figure out by experiment the nature of its floating
point representation. @file{enquire} records its findings in the header
file @file{float.h}. If you can't produce this file by running
@file{enquire} on the target machine, then you will need to come up with
a suitable @file{float.h} in some other way (or else, avoid using it in
your programs).
Do not try to build stage 2 for a cross-compiler. It doesn't work to
rebuild GNU CC as a cross-compiler using the cross-compiler, because
that would produce a program that runs on the target machine, not on the
host. For example, if you compile a 386-to-68030 cross-compiler with
itself, the result will not be right either for the 386 (because it was
compiled into 68030 code) or for the 68030 (because it was configured
for a 386 as the host). If you want to compile GNU CC into 68030 code,
whether you compile it on a 68030 or with a cross-compiler on a 386, you
must specify a 68030 as the host when you configure it.
To install the cross-compiler, use @samp{make install}, as usual.
@node VMS Install
@section Installing GNU CC on VMS
@cindex VMS installation
@cindex installing GNU CC on VMS
The VMS version of GNU CC is distributed in a backup saveset containing
both source code and precompiled binaries.
To install the @file{gcc} command so you can use the compiler easily, in
the same manner as you use the VMS C compiler, you must install the VMS CLD
file for GNU CC as follows:
@enumerate
@item
Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
to point to the directories where the GNU CC executables
(@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are
kept respectively. This should be done with the commands:@refill
@smallexample
$ assign /system /translation=concealed -
disk:[gcc.] gnu_cc
$ assign /system /translation=concealed -
disk:[gcc.include.] gnu_cc_include
@end smallexample
@noindent
with the appropriate disk and directory names. These commands can be
placed in your system startup file so they will be executed whenever
the machine is rebooted. You may, if you choose, do this via the
@file{GCC_INSTALL.COM} script in the @file{[GCC]} directory.
@item
Install the @file{GCC} command with the command line:
@smallexample
$ set command /table=sys$common:[syslib]dcltables -
/output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc
$ install replace sys$common:[syslib]dcltables
@end smallexample
@item
To install the help file, do the following:
@smallexample
$ library/help sys$library:helplib.hlb gcc.hlp
@end smallexample
@noindent
Now you can invoke the compiler with a command like @samp{gcc /verbose
file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -