Skip to content

FreeBSD: No availability OS version #83601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 2 additions & 12 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "swift/Basic/Feature.h"
#include "swift/Basic/FunctionBodySkipping.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/Platform.h"
#include "swift/Basic/PlaygroundOption.h"
#include "swift/Basic/Version.h"
#include "swift/Config.h"
Expand Down Expand Up @@ -693,18 +694,7 @@ namespace swift {
/// This is only implemented on certain OSs. If no target has been
/// configured, returns v0.0.0.
llvm::VersionTuple getMinPlatformVersion() const {
if (Target.isMacOSX()) {
llvm::VersionTuple OSVersion;
Target.getMacOSXVersion(OSVersion);
return OSVersion;
} else if (Target.isiOS()) {
return Target.getiOSVersion();
} else if (Target.isWatchOS()) {
return Target.getOSVersion();
} else if (Target.isXROS()) {
return Target.getOSVersion();
}
return llvm::VersionTuple(/*Major=*/0, /*Minor=*/0, /*Subminor=*/0);
return getVersionForTriple(Target);
}

/// Sets an implicit platform condition.
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Basic/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ namespace swift {
/// returned.
StringRef getPlatformNameForTriple(const llvm::Triple &triple);

/// Returns the version tuple for a given target triple
llvm::VersionTuple getVersionForTriple(const llvm::Triple &triple);

/// Returns the platform Kind for Darwin triples.
DarwinPlatformKind getDarwinPlatformKind(const llvm::Triple &triple);

Expand Down
17 changes: 17 additions & 0 deletions lib/Basic/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
llvm_unreachable("unsupported OS");
}

llvm::VersionTuple swift::getVersionForTriple(const llvm::Triple &triple) {
if (triple.isMacOSX()) {
llvm::VersionTuple OSVersion;
triple.getMacOSXVersion(OSVersion);
return OSVersion;
} else if (triple.isiOS()) {
return triple.getiOSVersion();
} else if (triple.isWatchOS()) {
return triple.getOSVersion();
} else if (triple.isXROS()) {
return triple.getOSVersion();
} else if (triple.isOSWindows()) {
return triple.getOSVersion();
}
return llvm::VersionTuple(/*Major=*/0, /*Minor=*/0, /*Subminor=*/0);
}

StringRef swift::getMajorArchitectureName(const llvm::Triple &Triple) {
if (Triple.isOSLinux()) {
switch (Triple.getSubArch()) {
Expand Down
13 changes: 1 addition & 12 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@ swift::CompilerInvocation::CompilerInvocation() {
setTargetTriple(llvm::sys::getDefaultTargetTriple());
}

/// Converts a llvm::Triple to a llvm::VersionTuple.
static llvm::VersionTuple
getVersionTuple(const llvm::Triple &triple) {
if (triple.isMacOSX()) {
llvm::VersionTuple OSVersion;
triple.getMacOSXVersion(OSVersion);
return OSVersion;
}
return triple.getOSVersion();
}

void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
StringRef mainExecutablePath, bool shared,
llvm::SmallVectorImpl<char> &runtimeResourcePath) {
Expand Down Expand Up @@ -1623,7 +1612,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
// First, set up default minimum inlining target versions.
auto getDefaultMinimumInliningTargetVersion =
[&](const llvm::Triple &triple) -> llvm::VersionTuple {
const auto targetVersion = getVersionTuple(triple);
const auto targetVersion = getVersionForTriple(triple);

// In API modules, default to the version when Swift first became available.
if (Opts.LibraryLevel == LibraryLevel::API) {
Expand Down