From b7279ed5b3ae3e7b0fd61e0f08c86fb1958f0b6f Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Thu, 6 Feb 2025 19:00:20 -0500 Subject: [PATCH] [SystemZ][XRay] Make xray work with gcc (#126154) It seems that depending on the platform, gcc acceptts or does not accept `-mvx` without specifying an architecture actually having vector instructions. The solution which seems to work across different versions of gcc and clang is to specify the least architecture which has vector instructions. In addition, initialization of the unused variable CPU prevents a compiler warning from gcc. --- compiler-rt/lib/xray/CMakeLists.txt | 2 +- compiler-rt/lib/xray/xray_tsc.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/xray/CMakeLists.txt b/compiler-rt/lib/xray/CMakeLists.txt index 673091807e34..c79b0b634ddf 100644 --- a/compiler-rt/lib/xray/CMakeLists.txt +++ b/compiler-rt/lib/xray/CMakeLists.txt @@ -111,7 +111,7 @@ set(riscv64_SOURCES xray_trampoline_s390x.S ) # Enable vector instructions in the assembly file. -set_source_files_properties(xray_trampoline_s390x.S PROPERTIES COMPILE_FLAGS -mvx) +set_source_files_properties(xray_trampoline_s390x.S PROPERTIES COMPILE_FLAGS -march=z13) set(XRAY_SOURCE_ARCHS arm diff --git a/compiler-rt/lib/xray/xray_tsc.h b/compiler-rt/lib/xray/xray_tsc.h index 118b6f00e33e..c8a8b2f16fef 100644 --- a/compiler-rt/lib/xray/xray_tsc.h +++ b/compiler-rt/lib/xray/xray_tsc.h @@ -96,6 +96,7 @@ namespace __xray { inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT { return true; } ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT { + CPU = 0; #if __has_builtin(__builtin_readcyclecounter) return __builtin_readcyclecounter(); #else