安装 mips 交叉编译器时出现问题
我正在做我的硕士论文,但在配置交叉编译器时遇到问题。我读过很多文章、常见问题解答、教程等,但我仍然认为我错过了一些东西,也许非常愚蠢和基础,但如果没有这些,我就无法对一切有一个清晰的愿景,我也无法让它一切正常……所以请随时向我解释一切。让我们直奔问题吧。
我正在使用 SoClib 设计一个具有许多 MIPS 和许多 RAM 的 NoC,并且我想在每个 RAM 中加载不同的应用程序,以使每个 MIPS 仅从一个 RAM 读取。我设法使用非常简单的应用程序(例如带有中断的 hello word...)来做到这一点,所以现在我试图实现一个 JPEG 解码器以更强烈的方式使用 MIPS。问题是我使用的交叉编译器无法找到基本的 stdio 函数,因此无法编译 mips 的应用程序。所以基本上我没有成功安装一个可以工作的完整交叉编译器。
1) 让我们从随 SoClib 安装的交叉编译器开始: 这是我安装它的指南:http://www.soclib。 fr/trac/dev/wiki/CrossCompiler 现在根据我的阅读,这不是一个完整的交叉编译器。我只安装了第一阶段 gcc,它可以为 mips 生成 elf 代码,但不能使用任何 C 函数。有了这个,我应该编译一个 C 库来创建一个新的交叉编译器。所以它不工作是正常的,尽管这并没有回答这个问题:如果“Hello world”使用 printf 并包含 stdio.h,为什么它可以工作?答案应该是,我已经看到 SoClib 的标头 stdio.h 实现的函数很少(有 printf),所以我无法在该编译器中使用标准 C 库。
2)因此,我决定安装一个完整的交叉编译器,并且我阅读了很多指南,因此我只会发布我在实践中使用过的两个指南: http://www .cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf来自第108页(在解释之前交叉编译的问题) 它使用 EGLIBC。唯一的区别是我使用“mipsel-elf”作为目标。如果我理解正确的话,这个方法需要一个三阶段交叉编译器,因为第一阶段交叉编译器无法完全编译eglibc。现在的问题是我无法使用第一阶段交叉编译器成功安装eglibc(在第122页失败)。我已附上日志。我认为问题开始于它说:“mipsel-elf-gcc:错误:无法识别的选项'-V'”和“mipsel-elf-gcc:致命错误:没有输入文件编译终止”。似乎我的编译器有一些问题,并且所有内容都在不受支持的平台上完成...但它应该可以工作,因为我已经像指南所述复制了eglibc/ports目录...
3)我尝试了另一个使用 newlib 而不是的指南语法: http://www(dot)cygwin(dot) com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf 本指南仅创建一个 2 阶段交叉编译器。我认为这是因为 newlib 可以用第一阶段编译器完全编译……我对吗?无论如何,我遇到了同样的问题。我无法编译 newlib 并且收到类似的错误(附有日志)。
这就是我的问题,在这里我对我是否试图解决它提出了一些疑问。
4)问题可能是target=mipsel-elf吗?我从 gnu 文档中知道配置 gnu 的名称应该是:cpu-manufacturer-os(或 cpu-manufacturer-kernel-os),但我读到 mipsel-elf 被接受。 elf 应该是因为我不想在我的 NoC 平台上加载操作系统,这是第二个疑问……
5) 问题可能是操作系统的问题吗?该指南使用 Linux 内核头文件……也许对于 mipsel-elf 目标,我不应该配置 binutils –with-sysroot?但听起来很奇怪……应该改变什么?
6)又一个可能很愚蠢的问题。 stdio 和一般的 C 函数,不需要操作系统,对吗?因为所有这些问题都让我对基础知识产生怀疑……所以我应该能够使用 mipsel-elf 交叉编译器运行 JPEG 解码 C 应用程序,对吧?
我们将不胜感激每一个考虑、建议和帮助。如果您有关于这些论点的一些文件,请告诉我,我想学习并在这个领域变得更加自信。 感谢
eglibc日志:
configure:2426: $? = 0
configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC)
configure:2437: $? = 0
configure:2444: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:2448: $? = 1
configure:2452: checking for suffix of object files
configure:2478: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5
configure:2482: $? = 0
configure:2507: result: o
configure:2511: checking whether we are using the GNU C compiler
configure:2540: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5
configure:2547: $? = 0
configure:2564: result: yes
configure:2573: checking whether /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc accepts -g
configure:2603: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g conftest.c >&5
configure:2610: $? = 0
configure:2711: result: yes
configure:2728: checking for /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc option to accept ISO C89
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g -O2 conftest.c >&5
conftest.c:9:19: fatal error: stdio.h: No such file or directory
compilation terminated.
configure:2809: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| /* end confdefs.h. */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
| char **p;
| int i;
| {
| return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
| char *s;
| va_list v;
| va_start (v,p);
| s = g (p, va_arg (v,int));
| va_end (v);
| return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
| function prototypes and stuff, but not '\xHH' hex character constants.
| These don't provoke an error unfortunately, instead are silently treated
| as 'x'. The following induces an error, until -std is added to get
| proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
| array size at least. It's necessary to write '\x00'==0 to get something
| that's true only with -std. */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
| inside strings and character constants. */
| #define FOO(x) 'x'
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
| ;
| return 0;
| }
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qlanglvl=extc89 -c -g -O2 conftest.c >&5
mipsel-elf-gcc: error: unrecognized
选项'-qlanglvl = extc89' 配置:2809:$? = 1 个
NEWLIB 日志
configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC)
configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qversion >&5
mipsel-elf-gcc: error: unrecognized option '-qversion'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4069: checking for C compiler default output file name
configure:4091: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc conftest.c >&5
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crti.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtbegin.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtend.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
configure:4095: $? = 1
configure:4132: result:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:4138: error: in `/home/bertone/programmazione/crosscompiler/mips/build/newlib':
configure:4142: error: C compiler cannot create executables
I´m doing my master thesis and I´m having problems configuring the cross compiler. I´ve read lots of articles, faq, tutorial, etc.., but I still think I´m missing something, maybe very stupid and basilar, but without that I can´t have a clear vision of everything and I can´t make it all work…so please feel free to explain me everything. Let´s go to the problem.
I´m using SoClib to design a NoC with many MIPS and many RAMs and I want to load different applications in every RAM, to make every MIPS read from only one RAM. I managed to do that using very simple applications (like hello word with interrupts…) so now I was trying to realize a JPEG decoder to use in a more intense way the MIPS. The problem is that the cross compiler I´m using can´t find the basic stdio functions and so cannot compile the application for the mips. So basically I didn´t managed to install a working full cross compiler.
1) Let´s start with the cross compiler installed with SoClib:
Here there is the guide I´ve followed to install it: http://www.soclib.fr/trac/dev/wiki/CrossCompiler
Now from what I´ve read this is not a full cross compiler. I´ve only installed a first stage gcc that can generate elf code for the mips but that can´t use any C function. With that one, I should compile a C library to create a new cross compiler. So it´s normal that it is not working, although that doesn´t answer to the question: why “Hello world” was working if it uses a printf and includes stdio.h? The answer should be that I´ve seen that SoClib has his header stdio.h with very few function realized (printf is there) so I can´t use the standard C library with that compiler.
2) Because of that I´ve decided to install a full cross compiler and I´ve read so many guides that I will only post the two I´ve used in practice:
http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf from page 108 (before explains the problems with cross compiling)
It uses EGLIBC. The only difference is that I´ve used as target “mipsel-elf”. If I´ve understood correctly, this method requires a 3 stage cross compiler, because eglibc can´t be fully compiled with the first stage cross compiler. Now the problem is that I can´t succeed in installing eglibc with the first stage cross compiler (it fails at page 122). I´have attached the log. I think problems starts when it says: “mipsel-elf-gcc: error: unrecognized option ´-V´” and “mipsel-elf-gcc: fatal error: no input files compilation terminated”. Seems that I´ve some problem with the compiler and all finishes with an unsupported platform…but it should work because I´ve copied the eglibc/ports directory like the guide says…
3) I´ve tried another guide that uses newlib instead of eglibc:
http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf
This guide creates only a 2 stage cross compiler. I think it´s because newlib can be fully compiled with the first stage compiler…am I right? Anyway I get the same problem. I can´t compile newlib and I get similar errors (log attached).
So that´s my problem and here I put some doubt I´ve had trying to resolve it.
4) Can the problem be the target=mipsel-elf? I know from the gnu documentation that the name to configure gnu should be: cpu-manufacturer-os (or cpu-manufacturer-kernel-os) but I´ve read that mipsel-elf is accepted. The elf should be because I don´t want to load an OS on my NoC platform and here the second doubt…
5) Can the problem be the OS thing? The guides uses linux kernel headers…maybe with a mipsel-elf target I shouldn´t configure binutils –with-sysroot? But sounds me strange…what should change?
6) Yet another probably stupid question. The stdio and generally C functions, doesn´t need an OS right? Because all these problems are making me doubt on the basics…so I should be able to run a JPEG decoding C application with a mipsel-elf cross compiler right?
Every consideration, advice and help will be appreciated. If you have some documents about these arguments please let me know, I would like to learn and become more confident in this field.
Thanks
eglibc log:
configure:2426: $? = 0
configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC)
configure:2437: $? = 0
configure:2444: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:2448: $? = 1
configure:2452: checking for suffix of object files
configure:2478: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5
configure:2482: $? = 0
configure:2507: result: o
configure:2511: checking whether we are using the GNU C compiler
configure:2540: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5
configure:2547: $? = 0
configure:2564: result: yes
configure:2573: checking whether /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc accepts -g
configure:2603: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g conftest.c >&5
configure:2610: $? = 0
configure:2711: result: yes
configure:2728: checking for /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc option to accept ISO C89
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g -O2 conftest.c >&5
conftest.c:9:19: fatal error: stdio.h: No such file or directory
compilation terminated.
configure:2809: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| /* end confdefs.h. */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
| char **p;
| int i;
| {
| return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
| char *s;
| va_list v;
| va_start (v,p);
| s = g (p, va_arg (v,int));
| va_end (v);
| return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
| function prototypes and stuff, but not '\xHH' hex character constants.
| These don't provoke an error unfortunately, instead are silently treated
| as 'x'. The following induces an error, until -std is added to get
| proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
| array size at least. It's necessary to write '\x00'==0 to get something
| that's true only with -std. */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
| inside strings and character constants. */
| #define FOO(x) 'x'
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
| ;
| return 0;
| }
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qlanglvl=extc89 -c -g -O2 conftest.c >&5
mipsel-elf-gcc: error: unrecognized
option '-qlanglvl=extc89'
configure:2809: $? = 1
NEWLIB log
configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper
Target: mipsel-elf
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC)
configure:4049: $? = 0
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5
mipsel-elf-gcc: error: unrecognized option '-V'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qversion >&5
mipsel-elf-gcc: error: unrecognized option '-qversion'
mipsel-elf-gcc: fatal error: no input files
compilation terminated.
configure:4049: $? = 1
configure:4069: checking for C compiler default output file name
configure:4091: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc conftest.c >&5
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crti.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtbegin.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtend.o: No such file or directory
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
configure:4095: $? = 1
configure:4132: result:
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:4138: error: in `/home/bertone/programmazione/crosscompiler/mips/build/newlib':
configure:4142: error: C compiler cannot create executables
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要这些 stdio 函数吗?
您可以替换这些 stdio 函数吗?例如,您是否真的需要一个 printf (其中一个更痛苦的),或者您是否愿意用其他东西替换它们,也许是 string_display() 和 hex_display() 函数,也许它们很容易实现和库和系统无关。
这些是文件 I/O 函数吗?我似乎记得一种流行的开源 jpeg 解码器想要为您执行文件 I/O。实现一个 fopen() (只返回任何有效的内容)、一个 fread 有多难,它只是跟踪二进制文件中包含的一些 const 数据中的指针,并进行 mem 复制,而 fwrite 也是如此deal 跟踪数组中的指针并进行内存复制。
我嵌入了 jpeg 解码器、mp3 等来进行系统调用,都通过使用 newlib() 来实现,这使得它更容易一些,但现在构建交叉编译器非常痛苦,并且还用不同的函数或替换系统调用通过实现这些功能的模拟。
如果您使用免费的codesourcery lite(现在称为codebench或其他东西,因为它是导师图形而不是codesourcery)并用模拟的系统调用替换系统调用,您就不必再与编译器混淆了。
我有一些非常简单的 mips 代码,还有一些用于构建我正在谈论的 gnu 交叉编译器的说明(如果您不需要使用系统调用、C 库调用、gcc 库调用,那么效果很好,因为您自己实现了所有内容) 。
https://github.com/dwelch67/pic32_samples
这距离我正在构建的目标并不遥远一个完整的交叉编译器。 Gcc/gnu 不太稳定,您可以从任何版本交叉编译任何版本并使其工作,同样,使用任何版本的任何主机上任何版本的任何目标的交叉编译器也不稳定。有时某个目标的 binutils+gcc+newlib 版本恰好可以工作。例如,在这段时间内/历史上,这在 Linux 上和 Windows 上的 mingw 上都有效。
http://www.dwelch.com/ipod/gccarm.txt
但除非您使用虚拟机(vmware 等)并在其上安装旧的 linux 和足够旧的构建系统,您将无法构建上述内容。
不久前,也许这仍然适用于现代系统。它适用于arm,但也许也适用于mips。
http://www.cowlark.com/2009-07-04-building- gcc/
我认为我没有在没有系统调用或模拟系统调用的情况下使用 mp3 和 zlib 和 jpeg 库发布任何代码,在我可以发布它们的地方。如果您想使用 zlib 作为性能测试或其他东西,一次性压缩或解压缩或两者兼而有之,那么 malloc 对于 zlib 之类的东西很容易实现,不是通用目的,而是一个带有数据输入和数据输出的受控测试环境。对于其他受控环境 jpeg 编码或解码、mp3 编码或解码(它们是有损的,因此您无法将输入与输出进行比较以验证系统产生了正确的结果,尽管与已知的良好系统相比,校验和或 crc 很容易)也是如此/结果)。
如果您检查 newlib 中我清空并稍后替换的文件,您可以看到 newlib 将 stdio 调用分解成什么,然后您将实现每个函数。我有几个旧网站,至少有 dhrystone 示例,它们几乎只想要一个 printf http://www. dwelch.com/ipod/ http://www.dwelch.com/gba/dhry.htm 在这里你可以看到我对 newlib 函数做了什么,大部分只是通过返回一个传递值来中和它们,并弄清楚什么新库当它想要输出到标准输出时执行。
或者用替代函数替换一些 stdio 调用的示例,从而导致某些功能仍然有效。不是说它很漂亮,但你可以玩这个游戏。
https://github.com/dwelch67/stm32f4d/blob/master/adventure/
基本上我读到的是,您已经发现了一个问题,但只追求一条路径,在编译器方面解决它。当您可以通过创建抽象层或垫片,或者完全删除有问题的代码或用不太有问题的代码替换它来解决它时。如果你看一下上面的冒险游戏和类似时代的游戏帝国等的源代码,甚至是小型c编译器和其他已被移植多次的代码,你可以看到他们正是这样做的,他们通过使非-解决了问题语言,大部分代码中的非系统特定调用,最后一英里是在一个或几个系统特定位置实现这些调用。即使您要获得 gcc+newlib 或 gcc+glibc 交叉编译器,您仍然必须用自己的操作系统层替换默认的 stdio。 (这也是编译器方面的内容,一个庞大的抽象层,glibc,newlib 等,您仍然必须实现后端)。
First, off, do you need these stdio functions?
Can you replace these stdio functions. For example do you really really need a printf (one of the more painful ones), or might you be willing to replace those with some thing else, maybe a string_display() and hex_display() functions perhaps that are quite easy to implement and library and system independent.
Are these file I/O functions? I seem to remember one of the popular open source jpeg decoders wanted to do the file I/O for you. How hard is it really to implement an fopen() (just return with anything valid), an fread, which just keeps track of a pointer in some const data you have included in the binary, and does a mem copy, and fwrite, same deal keeps track of a pointer in an array and does a mem copy.
I have embedded jpeg decoders, mp3, etc that make system calls, both by using newlib() which makes it a bit easier but is these days very painful to build a cross compiler with, and also with replacing the system calls with different functions or by implementing simulations of those functions.
If you use the free codesourcery lite (now called codebench or something as it is mentor graphics and not codesourcery anymore) and replace the system calls with simulated ones you dont have to mess with compilers anymore.
I have some very simple mips code, but also some instructions for building the kind of gnu cross compiler I am talking about (works great if you dont have a use for system calls, C library calls, gcc library calls because you implemented everything yourself).
https://github.com/dwelch67/pic32_samples
It is not a far stretch from what I am building to a complete cross compiler. Gcc/gnu is not so stable that you can just cross compile any version from any version and have it work, likewise the cross compilers for any target from any version on any host using any version is not stable. From time to time a version of binutils+gcc+newlib for a target happen to just work. for example, at this period of time/history this worked, both on linux and with mingw on windows.
http://www.dwelch.com/ipod/gccarm.txt
but unless you use a virtual machine (vmware, etc) and install an old linux on it with an old enough build system, you wont be able to build the above.
Not long ago, and perhaps still this worked on a modern system. it is for arm but maybe it will also work for mips.
http://www.cowlark.com/2009-07-04-building-gcc/
I dont think I have any of the code posted with the mp3 and zlib and jpeg libraries used without system calls or with simulated system calls in a place where I can publish them. mallocs are easy to implement for things like zlib if you want to use zlib as a performance test or something, one time compress or decompress or both, not a general purpose thing but a controlled test environment with data in and data out. Same goes for the others controlled environment jpeg encode or decode, mp3 encode or decode (they are lossy so you cant compare input to output necessarily to verify the system produced the right result, a checksum or crc is easy though compared against a known good system/result).
If you examine the files in newlib that I null out and replace later you can see what newlib boils the stdio calls down into, you would then implement each of those functions. I have a couple of old sites that have at least dhrystone examples which pretty much just wanted a printf http://www.dwelch.com/ipod/ http://www.dwelch.com/gba/dhry.htm where you can see what I did with the newlib functions, mostly just neutered them by returning a passing value, and figuring out what newlib does when it wants to output to stdout.
Or an example of replacing some stdio calls with alternate functions resulting in something that still works. not saying it is pretty but you can play the game.
https://github.com/dwelch67/stm32f4d/blob/master/adventure/
Basically what I am reading is that you have identified a problem but are only pursuing one path, solving it on the compiler side. When you could be solving it by creating an abstraction layer or shim, or by removing the offending code completely or replacing it with less offensive code. If you look at the source code for adventure above and similar era games empire, etc, even small c compilers and other code that has been ported a number of times, you can see they did exactly that, they solved the problem by making non-language, non-system specific calls in the bulk of the code, and then the last mile was to implement those calls in one or a few system specific places. Even if you were to get a gcc+newlib or gcc+glibc cross compiler you are still going to have to replace the default stdio to operating system layer with your own. (that is what the compiler side of this is as well, a large bulky abstraction layer, glibc, newlib, etc, that you still have to implement the backend).
为什么不直接下载免费的预构建 GCC Codesourcery Lite MIPS 的交叉编译器工具链?
通常,libc 将 stdio 调用转换为对底层操作系统的系统调用,因此您需要有一个操作系统才能让 stdio 工作。如果您的 JPEG 解码器应用程序不调用任何需要操作系统的内容,则它会正常工作,但您需要创建一种方法来将 NoC 上每个单独的 CPU 的结果传递给外部世界。
Why not just download the free prebuilt GCC Codesourcery Lite cross compiler toolchain for MIPS?
Usually, libc translates stdio calls into system calls to the underlying OS, so you would need to have an OS for stdio to work. Your JPEG decoder application will work fine if it doesn't call anything that needs an OS, but you will need to create a method to get the results from each individual CPU across your NoC to the outside world.