Skip to content

Commit

Permalink
[analyzer] Include arch subdirectories in LD_LIBRARY_PATH for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gamesh411 committed Dec 2, 2024
1 parent d084d79 commit 50e5258
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 12 additions & 5 deletions analyzer/codechecker_analyzer/analyzer_context.py
Original file line number Diff line number Diff line change
@@ -71,13 +71,20 @@ def __init__(self):
# Original caller environment of CodeChecker for external binaries
self.__original_env = None

self.logger_lib_dir_path = os.path.join(
self._data_files_dir_path, 'ld_logger', 'lib')

if not os.path.exists(self.logger_lib_dir_path):
self.logger_lib_dir_path = os.path.join(
# Find the path which has the architectures for the built ld_logger
# shared objects.
ld_logger_path = Path(self._data_files_dir_path, 'ld_logger', 'lib')
if not ld_logger_path.is_dir():
ld_logger_path = Path(
self._lib_dir_path, 'codechecker_analyzer', 'ld_logger', 'lib')

# Add the ld_logger_path and all children (architecture) paths to be
# later used in the LD_LIBRARY_PATH environment variable during
# logging of compiler invocations.
self.logger_lib_dir_path = ':'.join(
[str(ld_logger_path)] +
[str(arch) for arch in ld_logger_path.iterdir() if arch.is_dir()])

self.logger_bin = None
self.logger_file = None
self.logger_compilers = None
6 changes: 5 additions & 1 deletion analyzer/tools/build-logger/tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -106,10 +106,14 @@ def read_actual_json(self) -> str:
return fd.read()

def get_envvars(self) -> Mapping[str, str]:
libdir = os.path.join(LOGGER_DIR, "lib")
return {
"PATH": os.getenv("PATH"),
"LD_PRELOAD": "ldlogger.so",
"LD_LIBRARY_PATH": os.path.join(LOGGER_DIR, "lib"),
"LD_LIBRARY_PATH": ':'.join([libdir] +
[arch for arch in
os.listdir(libdir)
if os.path.isdir(arch)]),
"CC_LOGGER_GCC_LIKE": "gcc:g++:clang:clang++:/cc:c++",
"CC_LOGGER_FILE": self.logger_file,
"CC_LOGGER_DEBUG_FILE": self.logger_debug_file,

0 comments on commit 50e5258

Please sign in to comment.