-
Notifications
You must be signed in to change notification settings - Fork 562
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
Build issues on an arm32v7 docker container on an AArch64 host #3381
Comments
Some further tests: ~$ uname -a
Linux hostname 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) aarch64 GNU/Linux
~$ linux32 uname -a
Linux hostname 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) armv8l GNU/Linux
~$ gcc -dumpmachine
aarch64-linux-gnu
#---
~$ docker run --rm arm64v8/ubuntu:bionic bash -c "uname -a"
Linux bad16824d258 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) aarch64 aarch64 aarch64 GNU/Linux
~$ docker run --rm arm64v8/ubuntu:bionic bash -c "linux32 uname -a"
Linux 52b74bb1d08c 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) armv8l armv8l armv8l GNU/Linux
~$ docker run --rm arm64v8/ubuntu:bionic bash -c "apt update && apt install -y gcc && gcc -dumpmachine"
aarch64-linux-gnu
#---
~$ docker run --rm arm32v7/ubuntu:bionic bash -c "uname -a"
Linux 4783d8df2a45 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) aarch64 aarch64 aarch64 GNU/Linux
~$ docker run --rm arm32v7/ubuntu:bionic bash -c "linux32 uname -a"
Linux b2d6209dcbda 4.9.0-8-arm64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) armv8l armv8l armv8l GNU/Linux
~$ docker run --rm arm32v7/ubuntu:bionic bash -c "apt update && apt install -y gcc && gcc -dumpmachine"
arm-linux-gnueabihf
|
This is likely to be related to DynamoRIO/drmemory#2017<DynamoRIO/drmemory#2017>. So, I tried replacing the last line in the dockerfile with && linux32 cmake ../dynamorio && make -j:
Shouldn't this be "&& linux32 cmake ../dynamiorio && linux32 make -j"?
(It's possible that the make stage is also personality-sensitive.)
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
|
Certainly, I think that neither of them should be required. Furthermore, they do not produce the expected result. As shown in my second comment above, For the record, I successfully built beehive-lab/mambo on arm32v7 containers on armv8 hosts, with either raspbian (armv6) or debian (aarch64) as host OSs. MAMBO uses Anyway, I now tried |
Certainly, I think that neither of them should be required.
Yes, ideally, but I'm not sure whose job it should be to set the personality correctly. The Docker daemon's?
It would be interesting to take a look at the corresponding situation on Intel. Does Docker change the personality to 32 bits in that case?
Furthermore, they do not produce the expected result. As shown in my second comment above, linux32 uname -a returns armv8l, but I am expecting armv7, armv7l or armhf, because it is being executed in an arm32v7 docker container.
I don't think the Linux personality can be expected to degrade the architecture version like that: with "linux32" you switch into Armv8's 32-bit state, not into Armv7, so I think "armv8l" is correct, and I think I've seen it working with "armv8l" in a chroot (rather than a Docker container).
I think it would be worth investigating the PTRACE_GETFPXREGS problem a bit more. It might just be that you need another set of header files installed, or your tool chain is too modern, or something else not related to 32/64 bits. It sounds somehow familiar to me, but I might be mixing it up with a different ptrace-related thing I once had to patch.
Edmund
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
|
AFAIK, docker uses the kernel on the host, which is an armv8. Therefore, it is ok that queries to the kernel return aarch64 or armv8l, since those are the architectures supported by the host.
The behaviour is the same. E.g., on a Win10 host: # winpty docker run --rm -it i386/ubuntu:bionic bash
root@d262ae1c99fa:/# uname -a
Linux d262ae1c99fa 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@d262ae1c99fa:/# linux32 uname -a
Linux d262ae1c99fa 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 i686 i686 i686 GNU/Linux
# winpty docker run --rm -it ubuntu:bionic bash
root@e80195e855f2:/# uname -a
Linux e80195e855f2 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@e80195e855f2:/# linux32 uname -a
Linux e80195e855f2 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 i686 i686 i686 GNU/Linux
I think I didn't word it correctly. I am not expecting IMHO, using
I am using GCC 6, because the build would fail with either GCC 7 (on aarch64) or GCC 8 (on x86-64). I will investigate the PTRACE_GETFPXREGS problem. Nonetheless, as commented above, this will be a fix for |
I found a workaround. After commenting core/unix/injector.c#L865-L868, Therefore, it seems that |
I tried to build DynamoRIO natively on a PYNQ board. I got the same
Therefore, the use case of this issue is still unresolved: how to build for EDIT This is the output when I try to execute the binaries built inside a container (for ./bin32/drrun /bin/ls
ERROR: unable to inject: exec of |(null)| failed |
This worked for me (with 13 test failures):
There are problems with As mentioned elsewhere, if you want to build with GCC 7, replace |
Hi @egrimley! I can successfully build DynamoRIO in multiple contexts and with different versions of GCC. As commented above, this issue is not about building DynamoRIO, but about how to tell cmake which architecture to build for. Precisely:
The last case is not consistent with how You can try what I mean by pushing the image you built (based on Don't take me wrong, I am interested on finding the bugs with different versions of the compiler on different platforms. But I wouldn't like this issue to focus on that. It is just casual that I stumbled upon those while trying different alternatives.
On the one hand, I don't need to use DynamoRIO on neither i686 nor i386. On the other hand, I don't have any device which can only execute i386, so I cannot test it. But, if I had it, I believe that the result would be the same because (as commented above): # winpty docker run --rm -it i386/ubuntu:bionic bash -c "uname -m"
x86_64
# winpty docker run --rm -it i386/ubuntu:bionic bash -c "linux32 uname -m"
i686
# winpty docker run --rm -it i386/ubuntu:bionic bash -c "apt update; apt-get install gcc; gcc -dumpmachine"
(...)
i686-linux-gnu
# winpty docker run --rm -it i386/ubuntu:bionic bash -c "apt update; apt-get install clang; clang -dumpmachine"
(...)
i686-pc-linux-gnu |
There are these lines in
So perhaps one should be running There is plenty of online discussion of "cmake detect architecture", for example: https://stackoverflow.com/questions/11944060/how-to-detect-target-architecture-using-cmake |
Thanks! That's a great hint. Unfortunately, it does not work because
Since the use case is quite specific, I am ok with setting the processor/arch explicitly. So, it is not necessary for cmake to support it. EDIT Although I will copy the artifacts to a PYNQ board later, in order to verify that the target is armv7 and not armv8. |
I have now tested it and it works. I can build the following docker image on an armv8 host, which can then be pushed to dockerhub and pulled to armv7 devices. FROM arm32v7/ubuntu:bionic
RUN apt update
RUN apt-get install -y --no-install-recommends ca-certificates cmake g++-6 gcc git make python
RUN rm -rf /usr/bin/gcc \
&& ln -s /usr/bin/gcc-6 /usr/bin/gcc \
&& ln -s /usr/bin/g++-6 /usr/bin/g++ \
&& git clone -b fix-ptrace-fpxregs https://github.com/umarcor/dynamorio \
&& cd dynamorio && mkdir build && cd build \
&& cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm .. \
&& make -j4 Notes:
FROM arm32v7/ubuntu:bionic
RUN apt update && apt-get install -y --no-install-recommends ca-certificates cmake g++ gcc git make python
RUN git clone https://github.com/DynamoRIO/dynamorio \
&& mkdir dynamorio/build && cd dynamorio/build \
&& cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=armv7 .. \
&& make -j4 I'm closing this because the issue about how to properly set the target processor is already solved and tested. Thanks a lot @egrimley! |
Just an additional note. Setting |
The following docker image is successfully built on an AArch64 host:
$ docker build -t dr/test .
However, if the first line is replaced with
FROM arm32v7/ubuntu:bionic
, the following errors are shown: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
: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.The text was updated successfully, but these errors were encountered: