diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -55,7 +55,9 @@ # Try using `-print-runtime-dir`. This is only supported by very new versions of Clang. # so allow failure here. - runtime_dir, clang_cmd = get_path_from_clang(['-print-runtime-dir'], allow_failure=True) + runtime_dir, clang_cmd = get_path_from_clang(shlex.split(config.target_cflags) + + ['-print-runtime-dir'], + allow_failure=True) if runtime_dir: if os.path.exists(runtime_dir): return os.path.realpath(runtime_dir) @@ -123,10 +125,10 @@ # Add compiler ID to the list of available features. config.available_features.add(compiler_id) -# Ask the compiler for the path to libraries it is going to use. If this -# doesn't match config.compiler_rt_libdir then it means we might be testing the -# compiler's own runtime libraries rather than the ones we just built. -# Warn about about this and handle appropriately. +# Ask the compiler for the path to libraries it is going to use. If this doesn't +# match config.compiler_rt_libdir then it means we might either be testing Linux +# multilib (-m32,-m64), or testing the compiler's own runtime libraries rather +# than the ones we just built. Warn about about this and handle appropriately. compiler_libdir = find_compiler_libdir() if compiler_libdir: compiler_rt_libdir_real = os.path.realpath(config.compiler_rt_libdir) @@ -135,7 +137,10 @@ 'Compiler lib dir != compiler-rt lib dir\n' f'Compiler libdir: "{compiler_libdir}"\n' f'compiler-rt libdir: "{compiler_rt_libdir_real}"') - if config.test_standalone_build_libs: + if not config.test_standalone_build_libs or config.target_cflags in ('-m32', '-m64'): + # Use Compiler's resource library directory instead. + config.compiler_rt_libdir = compiler_libdir + else: # Use just built runtime libraries, i.e. the the libraries this built just built. if not config.test_suite_supports_overriding_runtime_lib_path: # Test suite doesn't support this configuration. @@ -149,9 +154,6 @@ 'configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF ' 'to test the runtime libraries included in the compiler instead.' ) - else: - # Use Compiler's resource library directory instead. - config.compiler_rt_libdir = compiler_libdir lit_config.note(f'Testing using libraries in "{config.compiler_rt_libdir}"') # If needed, add cflag for shadow scale.