Build issues on an arm32v7 docker container on an AArch64 host
Created by: umarcor
The following docker image is successfully built on an AArch64 host:
FROM arm64v8/ubuntu:bionic
RUN apt update \
&& DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
ca-certificates \
cmake \
doxygen \
g++-6 \
gcc \
git \
ghostscript \
imagemagick \
make \
python3 \
transfig \
&& apt autoclean && apt clean && apt -y autoremove \
&& update-ca-certificates \
&& rm /usr/bin/gcc \
&& ln -s /usr/bin/g++-6 /usr/bin/g++ \
&& ln -s /usr/bin/gcc-6 /usr/bin/gcc \
&& git clone https://github.com/DynamoRIO/dynamorio \
&& mkdir build && cd build \
&& cmake ../dynamorio && make -j
$ docker build -t dr/test .
However, if the first line is replaced with FROM arm32v7/ubuntu:bionic
, the following errors are shown:
[ 1%] Building CXX object clients/drcachesim/CMakeFiles/drmemtrace_simulator.dir/simulator/cache.cpp.o
g++: error: unrecognized command line option '-mpreferred-stack-boundary=2'; did you mean '-mstructure-size-boundary='?
clients/drcpusim/CMakeFiles/drcpusim_ops.dir/build.make:86: recipe for target 'clients/drcpusim/CMakeFiles/drcpusim_ops.dir/options.cpp.o' failed
make[2]: *** [clients/drcpusim/CMakeFiles/drcpusim_ops.dir/options.cpp.o] Error 1
...
[ 3%] Building C object tools/CMakeFiles/runstats.dir/runstats.c.o
g++: error: unrecognized command line option '-mpreferred-stack-boundary=2'; did you mean '-mstructure-size-boundary='?
clients/drcachesim/CMakeFiles/drcachesim_ops.dir/build.make:86: recipe for target 'clients/drcachesim/CMakeFiles/drcachesim_ops.dir/common/options.cpp.o' failed
make[2]: *** [clients/drcachesim/CMakeFiles/drcachesim_ops.dir/common/options.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
...
[ 7%] Building C object core/CMakeFiles/drhelper.dir/lib/dr_helper.c.o
In file included from /dynamorio/core/arch/asm_shared.asm:37:0:
/dynamorio/core/arch/asm_defines.asm:65:3: error: #error ARM is only 32-bit; AARCH64 is 64-bit
# error ARM is only 32-bit; AARCH64 is 64-bit
This is likely to be related to DynamoRIO/drmemory#2017. So, I tried replacing the last line in the dockerfile with && linux32 cmake ../dynamorio && make -j
:
[ 64%] Building C object core/CMakeFiles/drinjectlib.dir/config.c.o
/dynamorio/core/unix/injector.c:866:50: error: 'PTRACE_GETFPXREGS' undeclared here (not in a function)
{ PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
^~~~~~~~~~~~~~~~~
/dynamorio/core/unix/injector.c:867:50: error: 'PTRACE_SETFPXREGS' undeclared here (not in a function)
{ PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
^~~~~~~~~~~~~~~~~
make[2]: *** [core/CMakeFiles/drinjectlib.dir/unix/injector.c.o] Error 1
Than, according to Cross-Compiling for ARM on Linux, I tried cmake -DCMAKE_TOOLCHAIN_FILE=../dynamorio/make/toolchain-arm32.cmake ../dynamorio
:
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:105 (enable_language):
The CMAKE_CXX_COMPILER:
arm-linux-gnueabihf-g++
is not a full path and was not found in the PATH.
So, I added ln -s /usr/bin/arm-linux-gnueabihf-g++-6 /usr/bin/arm-linux-gnueabihf-g++
to the dockerfile, and I tried to build it again:
-- Performing Test no_pie_avail - Success
CMake Error at CMakeLists.txt:1624 (message):
cannot find required libs m, dl, and/or pthread
-- Configuring incomplete, errors occurred!
What is the correct approach to build DynamoRIO on an arm32v7 docker container on an AArch64 host? I would expect the configuration to detect the environtment as armv7
and proceed with a native compilation., since this is what happens with most tools.