From 84bbf87bec7f1dc448a4345d2a9b4af0f109704b Mon Sep 17 00:00:00 2001 From: Marconi Jiang Date: Wed, 10 Aug 2022 06:22:54 -0700 Subject: [PATCH 1/2] Improve README.md for installation and issue --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b7909f..4065d42 100644 --- a/README.md +++ b/README.md @@ -56,12 +56,18 @@ Raspberry Pi 2/3/4 with GNU/Linux. ## Prerequisites * Code generator in AMaCC relies on several GNU/Linux behaviors, and it is necessary to have Arm/Linux installed in your build environment. +* Throughout this document, Ubuntu - Debian based Linux - on x86 PC is used as an + example. If other Linux distro is used, Linux shell command needs to be + modified accordingly. For example, changing `apt-get` to `yum` for CentOS. * Install [GNU Toolchain for the A-profile Architecture](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads) - Select `arm-linux-none-gnueabihf` (AArch32 target with hard float) +```shell +$ sudo apt-get install gcc-arm-linux-gnueabihf +``` * Install QEMU for Arm user emulation ```shell -sudo apt-get install qemu-user +$ sudo apt-get install qemu-user ``` ## Running AMaCC @@ -80,6 +86,33 @@ OK Check the messages generated by `make help` to learn more. +## Potential Issues Running AMaCC +There might be issue related to link path setting, error message `/lib/ld-linux-armhf.so.3: No such file or directory` like below. +``` +$ make clean +rm -f amacc amacc-native elf/* elf/* out-gcc/* +$ make + CC+LD amacc + CC+LD amacc-native +$ qemu-arm ./amacc tests/hello.c +/lib/ld-linux-armhf.so.3: No such file or directory +``` + +It can be solved by either of the following options. +``` +# option 1 - using '-L' option +$ qemu-arm -L /usr/arm-linux-gnueabihf/ ./amacc tests/hello.c +hello, world + +# option 2 - set QEMU_LD_PREFIX path +$ export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf +$ echo $QEMU_LD_PREFIX +/usr/arm-linux-gnueabihf +$ qemu-arm ./amacc tests/hello.c +hello, world +``` + + ## Benchmark AMaCC is able to generate machine code really fast and provides 70% of the performance of `gcc -O0`. @@ -106,3 +139,4 @@ AMaCC is based on the infrastructure of [c4](https://github.com/rswier/c4). * [Curated list of awesome resources on Compilers, Interpreters and Runtimes](http://aalhour.com/awesome-compilers/) * [Hacker News discussions](https://news.ycombinator.com/item?id=11411124) * [A Compiler Writing Journey](https://github.com/DoctorWkt/acwj) by Warren Toomey. +* [How to solve "error while loading shared libraries" when trying to run an arm binary with qemu-arm?](https://stackoverflow.com/questions/16158994/how-to-solve-error-while-loading-shared-libraries-when-trying-to-run-an-arm-bi) \ No newline at end of file From 3758eca1d564c465a8163ab5869bbe60abcdf30f Mon Sep 17 00:00:00 2001 From: Marconi Jiang Date: Thu, 11 Aug 2022 23:27:19 -0700 Subject: [PATCH 2/2] Add QEMU_LD_PREFIX path --- README.md | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 4065d42..f5361d1 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ Raspberry Pi 2/3/4 with GNU/Linux. ## Prerequisites * Code generator in AMaCC relies on several GNU/Linux behaviors, and it is necessary to have Arm/Linux installed in your build environment. -* Throughout this document, Ubuntu - Debian based Linux - on x86 PC is used as an - example. If other Linux distro is used, Linux shell command needs to be - modified accordingly. For example, changing `apt-get` to `yum` for CentOS. * Install [GNU Toolchain for the A-profile Architecture](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads) - Select `arm-linux-none-gnueabihf` (AArch32 target with hard float) ```shell $ sudo apt-get install gcc-arm-linux-gnueabihf + +# set QEMU_LD_PREFIX path +$ export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf ``` * Install QEMU for Arm user emulation @@ -86,32 +86,6 @@ OK Check the messages generated by `make help` to learn more. -## Potential Issues Running AMaCC -There might be issue related to link path setting, error message `/lib/ld-linux-armhf.so.3: No such file or directory` like below. -``` -$ make clean -rm -f amacc amacc-native elf/* elf/* out-gcc/* -$ make - CC+LD amacc - CC+LD amacc-native -$ qemu-arm ./amacc tests/hello.c -/lib/ld-linux-armhf.so.3: No such file or directory -``` - -It can be solved by either of the following options. -``` -# option 1 - using '-L' option -$ qemu-arm -L /usr/arm-linux-gnueabihf/ ./amacc tests/hello.c -hello, world - -# option 2 - set QEMU_LD_PREFIX path -$ export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf -$ echo $QEMU_LD_PREFIX -/usr/arm-linux-gnueabihf -$ qemu-arm ./amacc tests/hello.c -hello, world -``` - ## Benchmark AMaCC is able to generate machine code really fast and provides 70% of the performance of `gcc -O0`. @@ -138,5 +112,4 @@ AMaCC is based on the infrastructure of [c4](https://github.com/rswier/c4). ## Related Materials * [Curated list of awesome resources on Compilers, Interpreters and Runtimes](http://aalhour.com/awesome-compilers/) * [Hacker News discussions](https://news.ycombinator.com/item?id=11411124) -* [A Compiler Writing Journey](https://github.com/DoctorWkt/acwj) by Warren Toomey. -* [How to solve "error while loading shared libraries" when trying to run an arm binary with qemu-arm?](https://stackoverflow.com/questions/16158994/how-to-solve-error-while-loading-shared-libraries-when-trying-to-run-an-arm-bi) \ No newline at end of file +* [A Compiler Writing Journey](https://github.com/DoctorWkt/acwj) by Warren Toomey. \ No newline at end of file