[llvm-branch-commits] [compiler-rt] release/17.x: [CompilerRT][ASan] Add new substitutions for tests while using lto to (#78523) (PR #86026)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Mar 20 15:48:05 PDT 2024
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/86026
Backport 911289a
Requested by: @usama54321
>From 0a386241fa51a85618ba3a23b1d80d97efbeb319 Mon Sep 17 00:00:00 2001
From: Usama Hameed <u_hameed at apple.com>
Date: Thu, 18 Jan 2024 11:13:56 -0800
Subject: [PATCH] [CompilerRT][ASan] Add new substitutions for tests while
using lto to (#78523)
explicitly pass libLTO path. This fixes a failure in swift-ci where
libLTO was being picked from the system instead which was an older
version and caused issues.
rdar://117474861
(cherry picked from commit 911289a62be068e56a934e069e8e03112a804542)
---
compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp | 2 +-
compiler-rt/test/asan/lit.cfg.py | 14 ++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp b/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp
index 55953d33940a8d..90c16776a63b13 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp
@@ -5,7 +5,7 @@
// RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto -mllvm -asan-use-private-alias
// RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto -mllvm -asan-use-private-alias
-// RUN: %clangxx_asan %t-1.o %t-2.o -o %t -flto -mlinker-version=133
+// RUN: %clangxx_asan_lto %t-1.o %t-2.o -o %t -flto -mlinker-version=133
// RUN: %run %t 2>&1 | FileCheck %s
#include <stdio.h>
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index d9303466021250..83b3cbe789cacc 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -101,14 +101,24 @@ def get_required_attr(config, attr_name):
config.available_features.add(win_runtime_feature)
-def build_invocation(compile_flags):
- return " " + " ".join([config.clang] + compile_flags) + " "
+def build_invocation(compile_flags, with_lto=False):
+ lto_flags = []
+ if with_lto and config.lto_supported:
+ lto_flags += config.lto_flags
+
+ return " " + " ".join([config.clang] + lto_flags + compile_flags) + " "
config.substitutions.append(("%clang ", build_invocation(target_cflags)))
config.substitutions.append(("%clangxx ", build_invocation(target_cxxflags)))
config.substitutions.append(("%clang_asan ", build_invocation(clang_asan_cflags)))
config.substitutions.append(("%clangxx_asan ", build_invocation(clang_asan_cxxflags)))
+config.substitutions.append(
+ ("%clang_asan_lto ", build_invocation(clang_asan_cflags, True))
+)
+config.substitutions.append(
+ ("%clangxx_asan_lto ", build_invocation(clang_asan_cxxflags, True))
+)
if config.asan_dynamic:
if config.host_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
shared_libasan_path = os.path.join(
More information about the llvm-branch-commits
mailing list