diff --git a/analyzer/codechecker_analyzer/analyzer_context.py b/analyzer/codechecker_analyzer/analyzer_context.py index 16babf7b89..87648741df 100644 --- a/analyzer/codechecker_analyzer/analyzer_context.py +++ b/analyzer/codechecker_analyzer/analyzer_context.py @@ -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 diff --git a/analyzer/tools/build-logger/tests/unit/__init__.py b/analyzer/tools/build-logger/tests/unit/__init__.py index e87a409252..57c55c5d07 100644 --- a/analyzer/tools/build-logger/tests/unit/__init__.py +++ b/analyzer/tools/build-logger/tests/unit/__init__.py @@ -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,