Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __aarch64__ support #54

Merged
merged 3 commits into from
Aug 9, 2023
Merged

Conversation

mmxsrup
Copy link
Contributor

@mmxsrup mmxsrup commented Aug 8, 2023

I am trying to run rp inside a Docker container on an arm64 host (Apple M1), but rp fails to build with the following error.

#6 9.803 /usr/bin/c++ -DBEA_ENGINE_STATIC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_ARM64 -DCAPSTONE_USE_SYS_DYN_MEM -DFMT_HEADER_ONLY -I/rp/src/third_party/fmt/include -I/rp/src/third_party/beaengine/include -I/rp/src/third_party/capstone/include -I/rp/src/third_party/CLI11 -O3 -DNDEBUG -flto -fno-fat-lto-objects -std=gnu++20 -MD -MT CMakeFiles/rp-lin.dir/rp/program.cpp.o -MF CMakeFiles/rp-lin.dir/rp/program.cpp.o.d -o CMakeFiles/rp-lin.dir/rp/program.cpp.o -c /rp/src/rp/program.cpp
#6 9.803 In file included from /rp/src/rp/coloshell.hpp:4,
#6 9.803                  from /rp/src/rp/elf_struct.hpp:4,
#6 9.803                  from /rp/src/rp/elf.hpp:8,
#6 9.803                  from /rp/src/rp/program.hpp:8,
#6 9.803                  from /rp/src/rp/program.cpp:2:
#6 9.803 /rp/src/rp/platform.h:11:2: error: #error Platform not supported.
#6 9.803    11 | #error Platform not supported.
#6 9.803       |  ^~~~~
#6 10.08 [19/21] Building CXX object CMakeFiles/rp-lin.dir/rp/toolbox.cpp.o
#6 10.08 FAILED: CMakeFiles/rp-lin.dir/rp/toolbox.cpp.o 
#6 10.08 /usr/bin/c++ -DBEA_ENGINE_STATIC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_ARM64 -DCAPSTONE_USE_SYS_DYN_MEM -DFMT_HEADER_ONLY -I/rp/src/third_party/fmt/include -I/rp/src/third_party/beaengine/include -I/rp/src/third_party/capstone/include -I/rp/src/third_party/CLI11 -O3 -DNDEBUG -flto -fno-fat-lto-objects -std=gnu++20 -MD -MT CMakeFiles/rp-lin.dir/rp/toolbox.cpp.o -MF CMakeFiles/rp-lin.dir/rp/toolbox.cpp.o.d -o CMakeFiles/rp-lin.dir/rp/toolbox.cpp.o -c /rp/src/rp/toolbox.cpp
#6 10.08 In file included from /rp/src/rp/coloshell.hpp:4,
#6 10.08                  from /rp/src/rp/elf_struct.hpp:4,
#6 10.08                  from /rp/src/rp/elf.hpp:8,
#6 10.08                  from /rp/src/rp/toolbox.cpp:3:
#6 10.08 /rp/src/rp/platform.h:11:2: error: #error Platform not supported.
#6 10.08    11 | #error Platform not supported.
#6 10.08       |  ^~~~~
#6 10.56 [20/21] Building CXX object CMakeFiles/rp-lin.dir/rp/main.cpp.o
#6 10.56 FAILED: CMakeFiles/rp-lin.dir/rp/main.cpp.o 
#6 10.56 /usr/bin/c++ -DBEA_ENGINE_STATIC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_ARM64 -DCAPSTONE_USE_SYS_DYN_MEM -DFMT_HEADER_ONLY -I/rp/src/third_party/fmt/include -I/rp/src/third_party/beaengine/include -I/rp/src/third_party/capstone/include -I/rp/src/third_party/CLI11 -O3 -DNDEBUG -flto -fno-fat-lto-objects -std=gnu++20 -MD -MT CMakeFiles/rp-lin.dir/rp/main.cpp.o -MF CMakeFiles/rp-lin.dir/rp/main.cpp.o.d -o CMakeFiles/rp-lin.dir/rp/main.cpp.o -c /rp/src/rp/main.cpp
#6 10.56 In file included from /rp/src/rp/coloshell.hpp:4,
#6 10.56                  from /rp/src/rp/main.cpp:2:
#6 10.56 /rp/src/rp/platform.h:11:2: error: #error Platform not supported.
#6 10.56    11 | #error Platform not supported.
#6 10.56       |  ^~~~~
#6 10.56 ninja: build stopped: subcommand failed.
------
executor failed running [/bin/sh -c git clone https://github.com/0vercl0k/rp.git &&     cd rp &&     git checkout 7d8e61f &&     cd src/build &&     chmod u+x ./build-release.sh && ./build-release.sh]: exit code: 1

The Dockerfile for the test environment is below.

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get -y install --no-install-recommends \
	build-essential ca-certificates cmake git nano ninja-build && \
    rm -rf /var/lib/apt/lists/*

# Failed
RUN git clone https://github.com/0vercl0k/rp.git && \
    cd rp && \
    git checkout 7d8e61f && \
    cd src/build && \
    chmod u+x ./build-release.sh && ./build-release.sh

Operation on the arm64 host machine was supported by #44, but the result of the uname -m (arch is an alias) command is slightly different when the environment is different, and it seems that it does not work.

In this PR, I changed the code to treat it as ARM64 when the result of the uname -m command is aarch64. The test environment can be built successfully with the following Dockerfile.

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get -y install --no-install-recommends \
	build-essential ca-certificates cmake git nano ninja-build && \
    rm -rf /var/lib/apt/lists/*

# Successed
 RUN git clone https://github.com/mmxsrup/rp.git && \
     cd rp && \
     git checkout add-aarch64-support && \
     cd src/build && \
     chmod u+x ./build-release.sh && ./build-release.sh

For reference, when running the uname -m command inside a Docker container on an arm64 host (Apple M1), the result is as follows:

aarch64

@0vercl0k
Copy link
Owner

0vercl0k commented Aug 8, 2023

Looks awesome, thank a lot for sending this in 🙏🏽

Would you mind updating the two following lines to clang-16 by any chance https://github.com/0vercl0k/rp/blob/master/.github/workflows/rp.yml#L76-L77 ? If you don't have the bandwidth, no worries I can push the changes on your branch; let me know!

Cheers

@0vercl0k
Copy link
Owner

0vercl0k commented Aug 9, 2023

Ugh sorry something is broken, let me figure it out 🫡

@0vercl0k 0vercl0k merged commit b24e7f5 into 0vercl0k:master Aug 9, 2023
5 checks passed
@0vercl0k
Copy link
Owner

0vercl0k commented Aug 9, 2023

Booyah, merged 👏🏽

@mmxsrup
Copy link
Contributor Author

mmxsrup commented Aug 9, 2023

Thank you for merging!

@0vercl0k
Copy link
Owner

0vercl0k commented Aug 9, 2023

Thank YOU for contributing :)

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants