[llvm] Fix compiler errors in GVN.h for clang versions older than 15 (PR #107636)

Thomas Fransham via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 13:02:52 PDT 2024


https://github.com/fsfod created https://github.com/llvm/llvm-project/pull/107636

Fix compiler errors in GVN.h from clang versions older than 15 that don't support gnu style attribute on namespaces. @tstellar, @compnerd.

>From b6606c2e6bcb6779f61dddf14ea9d1799bc2a4aa Mon Sep 17 00:00:00 2001
From: Thomas Fransham <tfransham at gmail.com>
Date: Fri, 6 Sep 2024 20:05:40 +0100
Subject: [PATCH] Fix compiler errors from clang versions older than 15 not
 supporting gnu style attributes on namespaces

Fixes errors in GVN.h after changes in #96630 to how LLVM_LIBRARY_VISIBILITY is defined
---
 llvm/include/llvm/Support/Compiler.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index e1d54af7dfcce1..0452f88cbf2c66 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -130,7 +130,12 @@
 
 #if (!(defined(_WIN32) || defined(__CYGWIN__)) ||                              \
      (defined(__MINGW32__) && defined(__clang__)))
+// Clang compilers older then 15 do not support gnu style attributes on namespaces
+#if defined(__clang__) && _clang_major__ < 15
+#define LLVM_LIBRARY_VISIBILITY [[gnu::visibility("hidden")]]
+#else
 #define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
+#endif
 #define LLVM_ALWAYS_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #elif defined(_WIN32)
 #define LLVM_ALWAYS_EXPORT __declspec(dllexport)



More information about the llvm-commits mailing list