[llvm] [Hashing] Remove Clang<=11 -fno-pic workaround (PR #110952)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 20:44:59 PDT 2024


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/110952

If the LLVM build and an API user have different
`(!defined(__clang__) || __clang_major__ > 11)` values, we will have a non-benign ODR violation and some users prefer a clear error to silent breakage.

The Clang<=11 -fno-pic x86-64 workaround is likely not useful anyway because builds are mostly PIC (`POSITION_INDEPENDENT_CODE` or LLVM_ENABLE_PIC).

>From 905f9ce02c37d5e54b077bc8650fe07336a01a81 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 2 Oct 2024 20:33:50 -0700
Subject: [PATCH] [Hashing] Remove Clang<=11 -fno-pic workaround

If the LLVM build and an API user have different
`(!defined(__clang__) || __clang_major__ > 11)` values, we will have a
non-benign ODR violation and some users prefer a clear error to silent
breakage.

The Clang<=11 -fno-pic x86-64 workaround is likely not useful anyway
because builds are mostly PIC (`POSITION_INDEPENDENT_CODE` or
LLVM_ENABLE_PIC).
---
 llvm/include/llvm/ADT/Hashing.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 109966257b51c0..17dcf31c616aa7 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -311,10 +311,7 @@ struct hash_state {
 /// depend on the particular hash values. On platforms without ASLR, this is
 /// still likely non-deterministic per build.
 inline uint64_t get_execution_seed() {
-  // Work around x86-64 negative offset folding for old Clang -fno-pic
-  // https://reviews.llvm.org/D93931
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS &&                                         \
-    (!defined(__clang__) || __clang_major__ > 11)
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   return static_cast<uint64_t>(
       reinterpret_cast<uintptr_t>(&install_fatal_error_handler));
 #else



More information about the llvm-commits mailing list