Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion clang/lib/Driver/ToolChains/Arch/Sparc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "Sparc.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
Expand Down Expand Up @@ -125,7 +126,9 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
return std::string(CPUName);
}

if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
Distro Dist(D.getVFS(), Triple);
if (Triple.getArch() == llvm::Triple::sparc &&
(Triple.isOSSolaris() || Dist.IsDebian() || Dist.IsGentoo()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pardon me for the basic question but why only for Debian and Gentoo and not for all Linux in general?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is the very popular SPARC Leon CPU that is used by ESA among other important customers and that uses V8 as the baseline. And Linux is supported and actively maintained on Leon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly: so far I've just included distros that I know for certain are SPARC V9 only. This can always be augmented if more come up, of course.

return "v9";
return "";
}
Expand Down
7 changes: 5 additions & 2 deletions clang/test/Preprocessor/predefined-arch-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -4131,13 +4131,16 @@

// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target sparc-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARC
// RUN: | FileCheck -match-full-lines %s -check-prefixes=CHECK_SPARC,CHECK_SPARC%if sparc64-distro %{_V9%} %else %{_V8%}
// CHECK_SPARC: #define __BIG_ENDIAN__ 1
// CHECK_SPARC: #define __sparc 1
// CHECK_SPARC: #define __sparc__ 1
// CHECK_SPARC-NOT: #define __sparcv9 1
// CHECK_SPARC-NOT: #define __sparcv9__ 1
// CHECK_SPARC: #define __sparcv8 1
// CHECK_SPARC_V8: #define __sparcv8 1
// CHECK_SPARC_V8-NOT: #define __sparc_v9__ 1
// CHECK_SPARC_V9: #define __sparc_v9__ 1
// CHECK_SPARC_V9-NOT: #define __sparcv8 1
// CHECK_SPARC-NOT: #define __sparcv9 1
// CHECK_SPARC-NOT: #define __sparcv9__ 1

Expand Down
4 changes: 4 additions & 0 deletions clang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def have_host_clang_repl_cuda():
"default-cxx-stdlib={}".format(config.clang_default_cxx_stdlib)
)

# clang -m32 defaults to -mcpu=v9 on Linux/sparc64 distros.
if re.search(r"debian|gentoo", platform.version(), re.I):
config.available_features.add("sparc64-distro")

# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
if platform.system() not in ["FreeBSD"]:
config.available_features.add("crash-recovery")
Expand Down