Skip to content

[CompilerRT][ASan] Add new substitutions for tests while using lto to #78523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

usama54321
Copy link
Member

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

@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Usama Hameed (usama54321)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/78523.diff

2 Files Affected:

  • (modified) compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp (+1-1)
  • (modified) compiler-rt/test/asan/lit.cfg.py (+8-2)
diff --git a/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp b/compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp
index 55953d33940a8d7..90c16776a63b13b 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 d93034660212509..4f264d6c434617a 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -101,14 +101,20 @@ 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(

Copy link

github-actions bot commented Jan 17, 2024

✅ With the latest revision this PR passed the Python code formatter.

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
@usama54321 usama54321 force-pushed the fix-odr-lto-swift-ci-failure branch from 2590446 to 60cb669 Compare January 18, 2024 18:46
@usama54321 usama54321 merged commit 911289a into llvm:main Jan 18, 2024
usama54321 added a commit to usama54321/apple-llvm-project that referenced this pull request Jan 22, 2024
…llvm#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
usama54321 added a commit to swiftlang/llvm-project that referenced this pull request Jan 22, 2024
…llvm#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
@usama54321
Copy link
Member Author

/cherry-pick 911289a

@llvmbot
Copy link
Member

llvmbot commented Mar 20, 2024

/cherry-pick 911289a

Error: Command failed due to missing milestone.

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Mar 20, 2024
…llvm#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 911289a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants