[libc-commits] [libc] [libc][docs] Add doc for using containers to test on a different arch (PR #97431)

via libc-commits libc-commits at lists.llvm.org
Tue Jul 2 09:14:43 PDT 2024


https://github.com/overmighty updated https://github.com/llvm/llvm-project/pull/97431

>From 0b68ef11623105aa477c8f9e1a17993b08068714 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Tue, 2 Jul 2024 18:03:59 +0200
Subject: [PATCH 1/2] [libc][docs] Add doc for using containers to test on a
 different arch

---
 libc/docs/build_and_test.rst | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/libc/docs/build_and_test.rst b/libc/docs/build_and_test.rst
index 1571dded96673..629062cba57ac 100644
--- a/libc/docs/build_and_test.rst
+++ b/libc/docs/build_and_test.rst
@@ -79,3 +79,33 @@ Building with Bazel
     $> bazel test --config=generic_clang @llvm-project//libc/...
 
 #. The bazel target layout of `libc` is located at: `utils/bazel/llvm-project-overlay/libc/BUILD.bazel <https://github.com/llvm/llvm-project/tree/main/utils/bazel/llvm-project-overlay/libc/BUILD.bazel>`_.
+
+Building in a container for a different architecture
+====================================================
+
+`Podman <https://podman.io/>`_ can be used together with
+`QEMU <https://www.qemu.org/>`_ to run container images built for architectures
+other than the host's. This can be used to build and test the libc on other
+supported architectures for which you do not have access to hardware. It can
+also be used if the hardware is slower than emulation of its architecture on a
+more powerful machine under a different architecture.
+
+As an example, to build and test in a container for 32-bit Arm:
+
+#. To install the necessary packages on Arch Linux:
+
+   .. code-block:: sh
+
+     $> pacman -S podman qemu-user-static qemu-user-static-binfmt \
+        qemu-system-arm
+
+#. To run Bash interactively in an Ubuntu 22.04 container for 32-bit Arm and
+   bind-mount an existing checkout of llvm-project on the host:
+
+   .. code-block:: sh
+
+     $> podman run -it \
+        -v </host/path/to/llvm-project>/:</container/path/to/llvm-project> \
+        --arch arm docker.io/ubuntu:jammy bash
+
+#. Install necessary packages, invoke CMake, build, and run tests.

>From d52e871bd858895c7fb4f916af57a9381a91f998 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Tue, 2 Jul 2024 18:14:18 +0200
Subject: [PATCH 2/2] fixup! [libc][docs] Add doc for using containers to test
 on a different arch

---
 libc/docs/build_and_test.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/docs/build_and_test.rst b/libc/docs/build_and_test.rst
index 629062cba57ac..22b09b07d9612 100644
--- a/libc/docs/build_and_test.rst
+++ b/libc/docs/build_and_test.rst
@@ -105,7 +105,7 @@ As an example, to build and test in a container for 32-bit Arm:
    .. code-block:: sh
 
      $> podman run -it \
-        -v </host/path/to/llvm-project>/:</container/path/to/llvm-project> \
+        -v </host/path/to/llvm-project>:</container/path/to/llvm-project> \
         --arch arm docker.io/ubuntu:jammy bash
 
 #. Install necessary packages, invoke CMake, build, and run tests.



More information about the libc-commits mailing list