[PATCH] D128840: [lit] Pass through QEMU's configuration environmental variables

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 11:10:24 PDT 2022


reames created this revision.
reames added reviewers: beanz, vitalybuka, asavonic.
Herald added subscribers: jsji, luke957, pengfei, s.egerton, PkmX, bollu, simoncook, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: LLVM.

I ran across this when cross building LLVM for riscv64.  I have qemu-riscv64 installed, and can thus run riscv64 binaries on my stock X86 linux system.  However, I need the QEMU_LD_PREFIX set so that dynamic loading works properly.  llvm-lit currently isolates tests from the environment which exists at launch, and thus tests run through LIT were always failing.  This change pulls all of the QEMU configuration variables from the environment and passes them through to the test so that qemu-user can successfully run the binaries.

I do want to note that LIT has a wrapper script mechanism I could have used to solve this instead.  I think taking this change makes sense from a usability perspective as it allows the natural workflow to work, but I don't want to claim we absolutely must take this for cross build testing.

Even with this, ninja check-llvm doesn't yet work.  There's another layer of environmental isolation somewhere that I haven't tracked down.

If we decide this is the right direction, we will need similar changes to other config files (e.g. test suite).  I'll hold off posting them until we've confirmed this is the right direction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128840

Files:
  llvm/test/lit.cfg.py


Index: llvm/test/lit.cfg.py
===================================================================
--- llvm/test/lit.cfg.py
+++ llvm/test/lit.cfg.py
@@ -42,6 +42,15 @@
 llvm_config.with_system_environment(
     ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])
 
+# Pass through environment variables used by QEMU's user mode emulation.
+# This lets us run cross compiled tests when the appropriate qemu-user
+# is installed and configured.
+llvm_config.with_system_environment(
+    ['QEMU_GDB', 'QEMU_LD_PREFIX', 'QEMU_STACK_SIZE', 'QEMU_CPU',
+     'QEMU_SET_ENV', 'QEMU_UNSET_ENV', 'QEMU_ARGV0', 'QEMU_UNAME',
+     'QEMU_GUEST_BASE', 'QEMU_RESERVED_VA', 'QEMU_LOG', 'QEMU_DFILTER',
+     'QEMU_LOG_FILENAME', 'QEMU_PAGESIZE', 'QEMU_SINGLESTEP', 'QEMU_STRACE',
+     'QEMU_RAND_SEED', 'QEMU_TRACE', 'QEMU_VERSION'])
 
 # Set up OCAMLPATH to include newly built OCaml libraries.
 top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128840.441085.patch
Type: text/x-patch
Size: 932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/0a35ce09/attachment.bin>


More information about the llvm-commits mailing list