[clang] 430c9a8 - [Hexagon] Enable linux #defines
Sid Manning via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 19 12:34:07 PDT 2020
Author: Sid Manning
Date: 2020-03-19T14:33:49-05:00
New Revision: 430c9a80c17b00ec65b8254810e3c9e122d13f98
URL: https://github.com/llvm/llvm-project/commit/430c9a80c17b00ec65b8254810e3c9e122d13f98
DIFF: https://github.com/llvm/llvm-project/commit/430c9a80c17b00ec65b8254810e3c9e122d13f98.diff
LOG: [Hexagon] Enable linux #defines
Enable standard linux defines when the triple is Linux and the
environment is musl.
Differential Revision: https://reviews.llvm.org/D76310
Added:
Modified:
clang/lib/Basic/Targets.cpp
clang/test/Preprocessor/hexagon-predefines.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index c063f8ca4472..9181c715085e 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -117,6 +117,9 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new XCoreTargetInfo(Triple, Opts);
case llvm::Triple::hexagon:
+ if (os == llvm::Triple::Linux &&
+ Triple.getEnvironment() == llvm::Triple::Musl)
+ return new LinuxTargetInfo<HexagonTargetInfo>(Triple, Opts);
return new HexagonTargetInfo(Triple, Opts);
case llvm::Triple::lanai:
diff --git a/clang/test/Preprocessor/hexagon-predefines.c b/clang/test/Preprocessor/hexagon-predefines.c
index 5be8b96e290d..54013ceffa64 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -101,3 +101,15 @@
// RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck \
// RUN: %s -check-prefix CHECK-ELF
// CHECK-ELF: #define __ELF__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-LINUX
+// CHECK-LINUX: #define __gnu_linux__ 1
+// CHECK-LINUX: #define __linux 1
+// CHECK-LINUX: #define __linux__ 1
+// CHECK-LINUX: #define __unix 1
+// CHECK-LINUX: #define __unix__ 1
+// CHECK-LINUX: #define linux 1
+// CHECK-LINUX: #define unix 1
More information about the cfe-commits
mailing list