llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: aokblast <details> <summary>Changes</summary> OSes like FreeBSD support clang-rapl but doesn't provide emutls implementation. In this case, the test fails to run. To fix it, we detect thread local and set a new flag. --- Full diff: https://github.com/llvm/llvm-project/pull/235229.diff 2 Files Affected: - (modified) clang/test/Interpreter/emulated-tls.cpp (+4) - (modified) clang/test/lit.cfg.py (+32) ``````````diff diff --git a/clang/test/Interpreter/emulated-tls.cpp b/clang/test/Interpreter/emulated-tls.cpp index bd80b65957ee3..f258864494b1a 100644 --- a/clang/test/Interpreter/emulated-tls.cpp +++ b/clang/test/Interpreter/emulated-tls.cpp @@ -4,6 +4,10 @@ // Emulated TLS is not supported by the LoongArch backend. // UNSUPPORTED: target=loongarch{{.*}} // +// Some hosts have no __emutls_get_address at all (its compiler runtime does not +// ship one), so no thread_local can execute in clang-repl there. +// REQUIRES: host-supports-jit-thread-local +// // An inline function that odr-uses a non-zero-initialized thread_local is // emitted as a weak (linkonce_odr) definition into every PartialTranslationUnit // that references it. With emulated TLS that set includes an __emutls_t.<var> diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index af3144f3ddcf9..d4942471baa43 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -194,6 +194,34 @@ def run_clang_repl(args): def have_host_jit_feature_support(feature_name): return "true" in run_clang_repl("--host-supports-" + feature_name) + +def have_host_clang_repl_thread_local(): + clang_repl_exe = lit.util.which("clang-repl", config.clang_tools_dir) + + if not clang_repl_exe: + return False + + testcode = b"\n".join( + [ + b'extern "C" int puts(const char *s);', + b"thread_local int tl = 42;", + b'puts(tl == 42 ? "success" : "failure");', + b"%quit", + ] + ) + try: + clang_repl_cmd = subprocess.run( + [clang_repl_exe], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + input=testcode, + ) + except OSError: + return False + + return clang_repl_cmd.returncode == 0 and b"success" in clang_repl_cmd.stdout + + def have_host_clang_repl_cuda(): clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir) @@ -234,6 +262,10 @@ def have_host_clang_repl_cuda(): if have_host_clang_repl_cuda(): config.available_features.add('host-supports-cuda') + + if have_host_clang_repl_thread_local(): + config.available_features.add("host-supports-jit-thread-local") + hosttriple = run_clang_repl("--host-jit-triple") config.available_features.add("host-jit-triple=" + hosttriple.strip()) config.substitutions.append(("%host-jit-triple", hosttriple.strip())) `````````` </details> https://github.com/llvm/llvm-project/pull/235229 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
