Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
teocns committed Nov 2, 2023
1 parent 5e1b71f commit 8517f3b
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions wrapper/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@

#include "compat.h"

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <strings.h>
#include <cstdlib>
#include <climits>
#include <cassert>
#include <sys/stat.h>
#include <unistd.h>
#include <vector>

#include "tools.h"
#include "target.h"
#include "tools.h"

namespace target {

Expand Down Expand Up @@ -140,7 +140,8 @@ void Target::overrideDefaultSDKPath(const char *SDKSearchDir) {
}
}

bool Target::getSDKPath(std::string &path, bool MacOSX10_16Fix, bool majorVersionOnly) const {
bool Target::getSDKPath(std::string &path, bool MacOSX10_16Fix,
bool majorVersionOnly) const {
OSVersion SDKVer = getSDKOSNum();

if (SDK) {
Expand Down Expand Up @@ -168,8 +169,7 @@ bool Target::getSDKPath(std::string &path, bool MacOSX10_16Fix, bool majorVersio
if (SDKVer.minor == 0 && !majorVersionOnly)
return getSDKPath(path, false, true);

err << "cannot find macOS SDK (expected in: " << path << ")"
<< err.endl();
err << "cannot find macOS SDK (expected in: " << path << ")" << err.endl();

return false;
}
Expand Down Expand Up @@ -267,13 +267,11 @@ bool Target::isGCH() {
if (!language)
return false;

return !strcmp(language, "c-header") ||
!strcmp(language, "c++-header") ||
return !strcmp(language, "c-header") || !strcmp(language, "c++-header") ||
!strcmp(language, "objective-c-header") ||
!strcmp(language, "objective-c++-header");
}


bool Target::isClang() const {
return (compiler == Compiler::CLANG || compiler == Compiler::CLANGXX);
}
Expand All @@ -282,10 +280,7 @@ bool Target::isGCC() const {
return (compiler == Compiler::GCC || compiler == Compiler::GXX);
}

bool Target::isKnownCompiler() const {
return compiler != Compiler::UNKNOWN;
}

bool Target::isKnownCompiler() const { return compiler != Compiler::UNKNOWN; }

const std::string &Target::getDefaultTriple(std::string &triple) const {
triple = getArchName(Arch::x86_64);
Expand Down Expand Up @@ -341,7 +336,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) {
*clangversion = ClangVersion();
pathtmp.clear();

auto tryDir = [&]()->bool {
auto tryDir = [&]() -> bool {
listFiles(dir.str().c_str(), nullptr, [](const char *file) {
if (file[0] != '.' && isDirectory(file, dir.str().c_str())) {
ClangVersion cv = parseClangVersion(file);
Expand Down Expand Up @@ -384,14 +379,14 @@ bool Target::findClangIntrinsicHeaders(std::string &path) {
};

#define TRYDIR(basedir, subdir) \
do { \
dir << basedir << subdir; \
if (tryDir()) { \
path.swap(pathtmp); \
return true; \
} \
clear(dir); \
} while (0)
do { \
dir << basedir << subdir; \
if (tryDir()) { \
path.swap(pathtmp); \
return true; \
} \
clear(dir); \
} while (0)

#define TRYDIR2(libdir) TRYDIR(clangbindir, libdir)
#define TRYDIR3(libdir) TRYDIR(std::string(), libdir)
Expand All @@ -417,10 +412,9 @@ do { \

#ifdef __APPLE__
constexpr const char *OSXIntrinDirs[] = {
"/Library/Developer/CommandLineTools/usr/lib/clang",
"/Applications/Contents/Developer/Toolchains/"
"XcodeDefault.xctoolchain/usr/lib/clang"
};
"/Library/Developer/CommandLineTools/usr/lib/clang",
"/Applications/Contents/Developer/Toolchains/"
"XcodeDefault.xctoolchain/usr/lib/clang"};

for (auto intrindir : OSXIntrinDirs)
TRYDIR3(intrindir);
Expand Down Expand Up @@ -463,8 +457,7 @@ void Target::setupGCCLibs(Arch arch) {
case Arch::i686:
GCCLibPath << "/" << getArchName(Arch::i386);
GCCLibSTDCXXPath << "/" << getArchName(i386);
default:
;
default:;
}

if (dynamic) {
Expand Down Expand Up @@ -529,31 +522,32 @@ bool Target::setup() {
OSVersion SDKVer;
bool lower;
} RequiredSDKVersion[] = {
{ Arch::i386, {10, 13}, true },
{ Arch::x86_64h, {10, 8} },
{ Arch::arm64, {11, 0} },
{ Arch::arm64e, {11, 0} },
{Arch::i386, {10, 13}, true},
{Arch::x86_64h, {10, 8}},
{Arch::arm64, {11, 0}},
{Arch::arm64e, {11, 0}},
};

for (auto &RequiredSDK : RequiredSDKVersion) {
if (haveArch(RequiredSDK.arch)) {

if (RequiredSDK.lower) {
if (SDKOSNum > RequiredSDK.SDKVer) {
err << "Architecture '" << getArchName(RequiredSDK.arch) << "' requires "
<< "macOS " << RequiredSDK.SDKVer.shortStr() << " SDK (or earlier)"
<< err.endl();
err << "Architecture '" << getArchName(RequiredSDK.arch)
<< "' requires "
<< "macOS " << RequiredSDK.SDKVer.shortStr()
<< " SDK (or earlier)" << err.endl();
return false;
}
} else {
if (SDKOSNum < RequiredSDK.SDKVer) {
err << "Architecture '" << getArchName(RequiredSDK.arch) << "' requires "
err << "Architecture '" << getArchName(RequiredSDK.arch)
<< "' requires "
<< "macOS " << RequiredSDK.SDKVer.shortStr() << " SDK (or later)"
<< err.endl();
return false;
}
}

}
}

Expand Down Expand Up @@ -600,15 +594,14 @@ bool Target::setup() {

if (SDKOSNum >= OSVersion(10, 14)) {
if (!isGCC() && !usegcclibs && stdlib == StdLib::libstdcxx) {
err << "macOS SDK '>= 10.14' does not support libstdc++ anymore"
<< err.endl();
return false;
err << "macOS SDK '>= 10.14' does not support libstdc++ anymore"
<< err.endl();
return false;
}

if (haveArch(Arch::i386)) {
err << "macOS SDK '>= 10.14' does not support i386 anymore"
<< err.endl();
return false;
err << "macOS SDK '>= 10.14' does not support i386 anymore" << err.endl();
return false;
}
}

Expand Down Expand Up @@ -664,7 +657,8 @@ bool Target::setup() {

if (v.empty()) {
err << "'-foc-use-gcc-libstdc++' requires gcc to be installed "
"(./build_gcc.sh)" << err.endl();
"(./build_gcc.sh)"
<< err.endl();
return false;
}

Expand Down Expand Up @@ -723,7 +717,8 @@ bool Target::setup() {
#ifndef __APPLE__
if (!findClangIntrinsicHeaders(ClangIntrinsicPath)) {
warn << "cannot find clang intrinsic headers; please report this "
"issue to the OSXCross project" << warn.endl();
"issue to the OSXCross project"
<< warn.endl();
} else {
if (haveArch(Arch::x86_64h) && clangversion < ClangVersion(3, 5)) {
err << "'" << getArchName(Arch::x86_64h) << "' requires clang 3.5 "
Expand All @@ -748,7 +743,9 @@ bool Target::setup() {
fargs.push_back("-nostdinc++");
fargs.push_back("-Qunused-arguments");
}

if ((SDKOSNum >= OSVersion(11, 1)) && (stdlib == StdLib::libcxx)) {
fargs.push_back("-lc++");
}
if (stdlib == StdLib::libstdcxx && usegcclibs && targetarch.size() < 2 &&
!isGCH()) {
// Use libs from './build_gcc' installation
Expand Down Expand Up @@ -823,8 +820,7 @@ bool Target::setup() {
if (OSNum.Num()) {
std::string tmp;
tmp = "-mmacosx-version-min=";
if (clangversion < ClangVersion(11, 0) &&
OSNum >= OSVersion(11, 0)) {
if (clangversion < ClangVersion(11, 0) && OSNum >= OSVersion(11, 0)) {
// Clang <= 10 can't parse -mmacosx-version-min=11.x
tmp += "10.16";
} else {
Expand Down Expand Up @@ -887,8 +883,10 @@ bool Target::setup() {

if (isClang()) {
if (SDKOSNum >= OSVersion(14, 0) && clangversion < ClangVersion(17, 0)) {
// MacOS 14 SDK uses __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ in AvailabilityInternal.h
fargs.push_back("-D__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__=" + OSNum.numStr());
// MacOS 14 SDK uses __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ in
// AvailabilityInternal.h
fargs.push_back("-D__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__=" +
OSNum.numStr());
}
if (clangversion >= ClangVersion(3, 8)) {
//
Expand Down Expand Up @@ -927,13 +925,15 @@ bool Target::setup() {

if (isgcclibstdcxx) {
err << "building for macOS '<= 10.5' with GCC (or clang++-gstdc++) "
"is no longer supported" << err.endl();
"is no longer supported"
<< err.endl();
error = true;
} else if (isClang()) {
nowarning = !!getenv("OSXCROSS_NO_10_5_DEPRECATION_WARNING");
if (!nowarning)
warn << "building for macOS '<= 10.5' "
"is no longer supported" << warn.endl();
"is no longer supported"
<< warn.endl();
}

if (!nowarning)
Expand Down

0 comments on commit 8517f3b

Please sign in to comment.