spirv-llvm-translator-16.0.0-ld_library_path.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From c2133b18cb48b9bb9c47897b16d64c5f0547cde6 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
  3. Date: Thu, 4 May 2023 08:44:25 +0200
  4. Subject: [PATCH] [test] Use LD_LIBRARY_PATH to ensure that a new lib is used
  5. (#1989)
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Add the library `BINARY_DIR` to `LD_LIBRARY_PATH` to ensure that
  10. the freshly built `libLLVMSPIRVLib.so` is tested. Otherwise, llvm-spirv
  11. spawned by the test suite may use the previously installed
  12. `libLLVMSPIRVLib.so`.
  13. I have noticed the problem after rebuilding LLVM with
  14. `-DLLVM_ENABLE_ASSSERTIONS=ON`. This meant that the previous version
  15. of `libLLVMSPIRVLib.so` now crashed, effectively causing the test suite
  16. to fail incorrectly.
  17. Signed-off-by: Michał Górny <mgorny@gentoo.org>
  18. ---
  19. test/CMakeLists.txt | 1 +
  20. test/lit.cfg.py | 3 ++-
  21. test/lit.site.cfg.py.in | 1 +
  22. 3 files changed, 4 insertions(+), 1 deletion(-)
  23. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
  24. index 235f6d0a0..355baffb8 100644
  25. --- a/test/CMakeLists.txt
  26. +++ b/test/CMakeLists.txt
  27. @@ -3,6 +3,7 @@ llvm_canonicalize_cmake_booleans(SPIRV_SKIP_DEBUG_INFO_TESTS)
  28. # required by lit.site.cfg.py.in
  29. get_target_property(LLVM_SPIRV_DIR llvm-spirv BINARY_DIR)
  30. +get_target_property(LLVM_SPIRV_LIB_DIR LLVMSPIRVLib BINARY_DIR)
  31. set(LLVM_SPIRV_TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  32. if(SPIRV_TOOLS_FOUND AND NOT SPIRV-Tools-tools_FOUND)
  33. diff --git a/test/lit.cfg.py b/test/lit.cfg.py
  34. index 4b66412c3..fd8d3f94c 100644
  35. --- a/test/lit.cfg.py
  36. +++ b/test/lit.cfg.py
  37. @@ -76,6 +76,7 @@
  38. else:
  39. config.substitutions.append(('spirv-val', ':'))
  40. +llvm_config.with_system_environment('LD_LIBRARY_PATH')
  41. if using_spirv_tools:
  42. - llvm_config.with_system_environment('LD_LIBRARY_PATH')
  43. llvm_config.with_environment('LD_LIBRARY_PATH', config.spirv_tools_lib_dir, append_path=True)
  44. +llvm_config.with_environment('LD_LIBRARY_PATH', config.llvm_spirv_lib_dir, append_path=True)
  45. diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
  46. index a01f2bb34..fdc4f4319 100644
  47. --- a/test/lit.site.cfg.py.in
  48. +++ b/test/lit.site.cfg.py.in
  49. @@ -6,6 +6,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
  50. config.llvm_obj_root = "@LLVM_BINARY_DIR@"
  51. config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
  52. config.llvm_spirv_dir = "@LLVM_SPIRV_DIR@"
  53. +config.llvm_spirv_lib_dir = "@LLVM_SPIRV_LIB_DIR@"
  54. config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
  55. config.llvm_shlib_dir = "@SHLIBDIR@"
  56. config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"