[clang] 99be6b6 - Haiku: Enable thread-local storag, disable PIE / enable PIC by default
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 2 23:03:06 PDT 2023
Author: Jerome Duval
Date: 2023-09-03T02:02:51-04:00
New Revision: 99be6b6d598f9ab4f4493b23375fcb87ae8b335d
URL: https://github.com/llvm/llvm-project/commit/99be6b6d598f9ab4f4493b23375fcb87ae8b335d
DIFF: https://github.com/llvm/llvm-project/commit/99be6b6d598f9ab4f4493b23375fcb87ae8b335d.diff
LOG: Haiku: Enable thread-local storag, disable PIE / enable PIC by default
Derived from D49481, but added tests and simplified the diff a bit; isPIEDefault
can just be removed. Also looking through their upstream patches I noticed PIC
is also enabled.
Reviewed By: nielx
Differential Revision: https://reviews.llvm.org/D159390
Added:
Modified:
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Haiku.h
clang/test/Driver/pic.c
clang/test/Sema/tls.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 367defc071417f..f2bd846e670d14 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +268,6 @@ class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public OSTargetInfo<Target> {
this->IntPtrType = TargetInfo::SignedLong;
this->PtrDiffType = TargetInfo::SignedLong;
this->ProcessIDType = TargetInfo::SignedLong;
- this->TLSSupported = false;
switch (Triple.getArch()) {
default:
break;
diff --git a/clang/lib/Driver/ToolChains/Haiku.h b/clang/lib/Driver/ToolChains/Haiku.h
index 80b4dd1945de23..cc7f7eb19091a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.h
+++ b/clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@ class LLVM_LIBRARY_VISIBILITY Haiku : public Generic_ELF {
Haiku(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
- bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
- return getTriple().getArch() == llvm::Triple::x86_64;
- }
+ bool isPICDefault() const override { return true; }
void AddClangSystemIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index f0a6393a5fd334..86b2a3b041d5f9 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
// RUN: -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
// RUN: not %clang -fpic -c --target=arm-arm-none-eabi -mpic-data-is-text-relative %s \
// RUN: -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
diff --git a/clang/test/Sema/tls.c b/clang/test/Sema/tls.c
index e4d0656d1dd612..600a69566a7ebe 100644
--- a/clang/test/Sema/tls.c
+++ b/clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
// RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
// RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
__thread int x;
More information about the cfe-commits
mailing list