Discussion:
ARM cross compiler on Fedora SE mode
(too old to reply)
Thawra Kadeed
2018-11-11 14:12:26 UTC
Permalink
Hello everyone,

I am using fedora28 64bit as a host machine running on Intel core i5.

I am trying to install arm cross compiler to compile c programs and run
it on Gem5 built for ARM in SE mode.

I did several attempts:

aarch64-linux-gnu-gcc simple.c -o simple1 -static

I got: fatal error: stdio.h: No such file or directory #include
<stdio.h>

x86_64-linux-gnu-gcc simple.c -o simple1 -static
fatal error: stdio.h: No such file or directory #include <stdio.h>

arm-linux-gnu-gcc /home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static

/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status

No package worked for me!

could anyone give me a hint about what would be exactly the right arm
cross compiler I need on Fedora28 to compile sources for Gem5 in SE
mode?

Thanks in advance,
Thawra
Ciro Santilli
2018-11-11 16:41:49 UTC
Permalink
When a problem is not gem5 specific, you are more likely to get help
on the respective project mailing list or Stack Overflow.

I know little about Fodora, but after a quick Googling for error
message and testing in Docker, it appears that it has separate
packages for gcc and glibc, e.g. gcc-arm-linux-gnu and
glibc-arm-linux-gnu exist for arm.

If I install both of them it I can cross compile a hello world successfully.

For aarch64 however, I cannot find the glibc package... so there are
two options:

- compile your own. crosstool-NG is the best method:
https://stackoverflow.com/questions/48959349/how-to-solve-fatal-kernel-too-old-when-running-gem5-in-syscall-emulation-se-m
- come to the light side of Ubuntu where it just works:
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049
Post by Thawra Kadeed
Hello everyone,
I am using fedora28 64bit as a host machine running on Intel core i5.
I am trying to install arm cross compiler to compile c programs and run
it on Gem5 built for ARM in SE mode.
aarch64-linux-gnu-gcc simple.c -o simple1 -static
I got: fatal error: stdio.h: No such file or directory #include
<stdio.h>
x86_64-linux-gnu-gcc simple.c -o simple1 -static
fatal error: stdio.h: No such file or directory #include <stdio.h>
arm-linux-gnu-gcc /home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static
/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status
No package worked for me!
could anyone give me a hint about what would be exactly the right arm
cross compiler I need on Fedora28 to compile sources for Gem5 in SE
mode?
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Thawra Kadeed
2018-11-11 17:01:05 UTC
Permalink
Post by Ciro Santilli
When a problem is not gem5 specific, you are more likely to get help
on the respective project mailing list or Stack Overflow.
I know little about Fodora, but after a quick Googling for error
message and testing in Docker, it appears that it has separate
packages for gcc and glibc, e.g. gcc-arm-linux-gnu and
glibc-arm-linux-gnu exist for arm.
Thanks a lot Ciro for your quick answer!

I installed both on Fedora and then used:

arm-linux-gnu-gcc /home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static

But I got the same error:
/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status


could you please write exactly the command you used to generate binary
hello using these libraries, and then on wich Fedora distribution did
you try that? I am using Fedora28 on intel core i5.

Thanks
Post by Ciro Santilli
If I install both of them it I can cross compile a hello world
successfully.
For aarch64 however, I cannot find the glibc package... so there are
https://stackoverflow.com/questions/48959349/how-to-solve-fatal-kernel-too-old-when-running-gem5-in-syscall-emulation-se-m
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049
Post by Thawra Kadeed
Hello everyone,
I am using fedora28 64bit as a host machine running on Intel core i5.
I am trying to install arm cross compiler to compile c programs and run
it on Gem5 built for ARM in SE mode.
aarch64-linux-gnu-gcc simple.c -o simple1 -static
I got: fatal error: stdio.h: No such file or directory #include
<stdio.h>
x86_64-linux-gnu-gcc simple.c -o simple1 -static
fatal error: stdio.h: No such file or directory #include <stdio.h>
arm-linux-gnu-gcc
/home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static
/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status
No package worked for me!
could anyone give me a hint about what would be exactly the right arm
cross compiler I need on Fedora28 to compile sources for Gem5 in SE
mode?
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Ciro Santilli
2018-11-11 18:30:08 UTC
Permalink
Post by Thawra Kadeed
Post by Ciro Santilli
When a problem is not gem5 specific, you are more likely to get help
on the respective project mailing list or Stack Overflow.
I know little about Fodora, but after a quick Googling for error
message and testing in Docker, it appears that it has separate
packages for gcc and glibc, e.g. gcc-arm-linux-gnu and
glibc-arm-linux-gnu exist for arm.
Thanks a lot Ciro for your quick answer!
arm-linux-gnu-gcc /home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static
/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status
could you please write exactly the command you used to generate binary
hello using these libraries, and then on wich Fedora distribution did
you try that? I am using Fedora28 on intel core i5.
Ah, adding the -static on fedora then it fails with the "when
searching for -lgcc_eh".

It has been asked on Stack overflow but no one answered:
https://unix.stackexchange.com/questions/193864/how-to-fix-skipping-incompatible-usr-lib-libc-a
try searching the web further and reporting a bug on the Fedora bug
tracker.

Failure can be reproduced with:

cat << 'EOF' >a.c
#include <stdio.h>

int main(void) {
puts("asdf");
return 0;
}
EOF
sudo docker run -it --name fd28 -w "/host/$(pwd)" -v "/:/host" fedora:28 bash
yum install gcc-arm-linux-gnu glibc-arm-linux-gnu
arm-linux-gnu-gcc -static a.c

So the easy solution is to just replace fedora:28 with ubuntu:18.04 on
the above, image which I have tested thoroughly as explained in the
Stack Overflow answer.

You'll likely want to read a Docker tutorial as well.
Post by Thawra Kadeed
Thanks
Post by Ciro Santilli
If I install both of them it I can cross compile a hello world successfully.
For aarch64 however, I cannot find the glibc package... so there are
https://stackoverflow.com/questions/48959349/how-to-solve-fatal-kernel-too-old-when-running-gem5-in-syscall-emulation-se-m
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049
Post by Thawra Kadeed
Hello everyone,
I am using fedora28 64bit as a host machine running on Intel core i5.
I am trying to install arm cross compiler to compile c programs and run
it on Gem5 built for ARM in SE mode.
aarch64-linux-gnu-gcc simple.c -o simple1 -static
I got: fatal error: stdio.h: No such file or directory #include
<stdio.h>
x86_64-linux-gnu-gcc simple.c -o simple1 -static
fatal error: stdio.h: No such file or directory #include <stdio.h>
arm-linux-gnu-gcc
/home/kadeed/Gem5/tests/test-progs/hello/src/hello.c
-o helloo -static
/usr/bin/arm-linux-gnu-ld: skipping incompatible
/usr/lib/gcc/arm-linux-gnueabi/8/libgcc_eh.a when searching for -lgcc_eh
/usr/bin/arm-linux-gnu-ld: cannot find -lgcc_eh
collect2: error: ld returned 1 exit status
No package worked for me!
could anyone give me a hint about what would be exactly the right arm
cross compiler I need on Fedora28 to compile sources for Gem5 in SE
mode?
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
João Miguel Morgado Pereira Vieira
2018-11-11 19:32:16 UTC
Permalink
Dear Thawra,

I have been working with gem5 and the ARM ISA for some time. I have to tell you that setting up a cross compiler for ARM using SE mode is a tremendous pain, since even when everything compiles correctly, you may still have problems with system calls (some of them are not implemented in SE mode), or the common error “Fatal: kernel is too old”.

However, I succeeded setting up a cross compiler for running a system featuring an ARM in SE mode using gem5. You can find the instructions here: http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5 <http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5>

I hope this helps!

Kind regards,
João Vieira
Post by Thawra Kadeed
Thawra
Ciro Santilli
2018-11-11 19:42:25 UTC
Permalink
On Sun, Nov 11, 2018 at 7:32 PM João Miguel Morgado Pereira Vieira
Post by João Miguel Morgado Pereira Vieira
Dear Thawra,
I have been working with gem5 and the ARM ISA for some time. I have to tell you that setting up a cross compiler for ARM using SE mode is a tremendous pain, since even when everything compiles correctly, you may still have problems with system calls (some of them are not implemented in SE mode), or the common error “Fatal: kernel is too old”.
Note that this problem has been solved on recent gem5 versions as
explained on the Stack Overflow answer I linked to earlier:
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049

The Ubuntu toolchain just works out of thee box now, and likely the
Fedora one would likely also work if we were able to use it in the
fist place.
Post by João Miguel Morgado Pereira Vieira
However, I succeeded setting up a cross compiler for running a system featuring an ARM in SE mode using gem5. You can find the instructions here: http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5
I hope this helps!
Kind regards,
João Vieira
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
João Miguel Morgado Pereira Vieira
2018-11-11 19:54:26 UTC
Permalink
On Sun, Nov 11, 2018 at 7:32 PM João Miguel Morgado Pereira Vieira
Post by João Miguel Morgado Pereira Vieira
Dear Thawra,
I have been working with gem5 and the ARM ISA for some time. I have to tell you that setting up a cross compiler for ARM using SE mode is a tremendous pain, since even when everything compiles correctly, you may still have problems with system calls (some of them are not implemented in SE mode), or the common error “Fatal: kernel is too old”.
Note that this problem has been solved on recent gem5 versions as
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049 <https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049>
Solved? I don’t think so. This obligates users either to implement system calls that are not implemented in SE mode or to transform them into warnings. Besides, the cross compiler I suggested works perfectly, since it is conceived to compile applications to run in bare-metal systems. It costs nothing but the installation of a toolkit. Simpler, don’t you think?
The Ubuntu toolchain just works out of thee box now, and likely the
Fedora one would likely also work if we were able to use it in the
fist place.
Well, judging by the fact that CentOS’ doesn’t, I doubt it...
Post by João Miguel Morgado Pereira Vieira
However, I succeeded setting up a cross compiler for running a system featuring an ARM in SE mode using gem5. You can find the instructions here: http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5
I hope this helps!
Kind regards,
João Vieira
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Kind regards,
João Vieira
Ciro Santilli
2018-11-11 20:21:15 UTC
Permalink
On Sun, Nov 11, 2018 at 7:54 PM João Miguel Morgado Pereira Vieira
Post by Ciro Santilli
On Sun, Nov 11, 2018 at 7:32 PM João Miguel Morgado Pereira Vieira
Dear Thawra,
I have been working with gem5 and the ARM ISA for some time. I have to tell you that setting up a cross compiler for ARM using SE mode is a tremendous pain, since even when everything compiles correctly, you may still have problems with system calls (some of them are not implemented in SE mode), or the common error “Fatal: kernel is too old”.
Note that this problem has been solved on recent gem5 versions as
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049
Solved? I don’t think so. This obligates users either to implement system calls that are not implemented in SE mode or to transform them into warnings. Besides, the cross compiler I suggested works perfectly, since it is conceived to compile applications to run in bare-metal systems. It costs nothing but the installation of a toolkit. Simpler, don’t you think?
Yes as you say, the error was "bypassed", since fully implementing all
system calls is very hard.

But if a program needs a system call, I don't see an alternative to
actually implementing it and merging back.

Does such baremetal allow doing system calls? Is that compiler fully
open source and does Vivado document exactly how they've built it?
Post by Ciro Santilli
The Ubuntu toolchain just works out of thee box now, and likely the
Fedora one would likely also work if we were able to use it in the
fist place.
Well, judging by the fact that CentOS’ doesn’t, I doubt it...
However, I succeeded setting up a cross compiler for running a system featuring an ARM in SE mode using gem5. You can find the instructions here: http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5
I hope this helps!
Kind regards,
João Vieira
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Kind regards,
João Vieira
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
João Miguel Morgado Pereira Vieira
2018-11-11 20:46:14 UTC
Permalink
On Sun, Nov 11, 2018 at 7:54 PM João Miguel Morgado Pereira Vieira
On Sun, Nov 11, 2018 at 7:32 PM João Miguel Morgado Pereira Vieira
Dear Thawra,
I have been working with gem5 and the ARM ISA for some time. I have to tell you that setting up a cross compiler for ARM using SE mode is a tremendous pain, since even when everything compiles correctly, you may still have problems with system calls (some of them are not implemented in SE mode), or the common error “Fatal: kernel is too old”.
Note that this problem has been solved on recent gem5 versions as
https://stackoverflow.com/questions/53085048/how-to-compile-and-run-an-executable-in-gem5-syscall-emulation-mode-with-se-py/53085049#53085049
Solved? I don’t think so. This obligates users either to implement system calls that are not implemented in SE mode or to transform them into warnings. Besides, the cross compiler I suggested works perfectly, since it is conceived to compile applications to run in bare-metal systems. It costs nothing but the installation of a toolkit. Simpler, don’t you think?
Yes as you say, the error was "bypassed", since fully implementing all
system calls is very hard.
But if a program needs a system call, I don't see an alternative to
actually implementing it and merging back.
Does such baremetal allow doing system calls? Is that compiler fully
open source and does Vivado document exactly how they've built it?
Well, I don’t think that doing system calls in bare-metal systems makes any sense, does it? My guess is that they are not implemented at all.

The cross-compiler that ships with Vivado (arm-linux-gnueabihf-gcc) is based on gcc (so it is probably open source). My guess is that it belongs to some legacy toolkit, so luckily it works for gem5. In order to use it, you don’t even have to activate Vivado. My point is: it works out of the box; it doesn’t give you any pain, and so far I compiled fairly complex programs and ran them in gem5 without any issue.
The Ubuntu toolchain just works out of thee box now, and likely the
Fedora one would likely also work if we were able to use it in the
fist place.
Well, judging by the fact that CentOS’ doesn’t, I doubt it...
However, I succeeded setting up a cross compiler for running a system featuring an ARM in SE mode using gem5. You can find the instructions here: http://web.tecnico.ulisboa.pt/~joaomiguelvieira/thesis/doku.php?id=setup_arm_cross-compiler_for_gem5
I hope this helps!
Kind regards,
João Vieira
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Kind regards,
João Vieira
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users <http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users>
Kind regards,
João Vieira

Loading...