add OSXCROSS_GCC_NO_STATIC_RUNTIME option + cleanup

This commit is contained in:
Thomas Pöchtrager 2014-12-24 09:54:27 +01:00
parent 30140e9769
commit 8c0ca406b9
5 changed files with 43 additions and 25 deletions

View File

@ -4,6 +4,9 @@ changed:
* updated cctools to 862
* updated ld64 to 241.9
added:
* OSXCROSS_GCC_NO_STATIC_RUNTIME option (env)
/******************************* v0.8 *******************************/
changed:

7
README.md Executable file → Normal file
View File

@ -50,6 +50,8 @@ That's it. See usage examples below.
If you want to build GCC as well, then you can do this by running:
`[GCC_VERSION=4.9.1] [ENABLE_FORTRAN=1] ./build_gcc.sh`.
\[A gfortran usage example can be found [here](https://github.com/tpoechtrager/osxcross/issues/28#issuecomment-67047134)]
But before you do this, make sure you have got the GCC build depedencies installed on your system.
On debian like systems you can run:
@ -58,6 +60,11 @@ On debian like systems you can run:
to install them.
ATTENTION:
OSXCross links libgcc and libstdc++ statically by default (this affects `-oc-use-gcc-libs` too).
You can turn this behavior off with `OSXCROSS_GCC_NO_STATIC_RUNTIME=1` (env).
### PACKAGING THE SDK: ###
If you need a recent SDK, then you must do the SDK packaging on OS X.

0
wrapper/programs/osxcross-conf.cpp Executable file → Normal file
View File

View File

@ -47,14 +47,13 @@ int env(int argc, char **argv) {
const char *pp = p;
for (; *p; ++p) {
do {
auto badChar = [&](const char *p) {
std::cerr << desc << " should not contain '" << *p << "'" << std::endl;
const char *start =
p - std::min(static_cast<size_t>(p - pp), static_cast<size_t>(30));
const char *start = p - std::min<size_t>(p - pp, 30);
size_t len = std::min(strlen(start), static_cast<size_t>(60));
size_t len = std::min<size_t>(strlen(start), 60);
std::cerr << std::string(start, len) << std::endl;
while (start++ != p)
@ -71,7 +70,7 @@ int env(int argc, char **argv) {
badChar(p);
return true;
}
}
} while (*p && *++p);
return false;
};

View File

@ -306,30 +306,45 @@ void Target::setupGCCLibs(Arch arch) {
std::stringstream GCCLibSTDCXXPath;
std::stringstream GCCLibPath;
const bool dynamic = !!getenv("OSXCROSS_GCC_NO_STATIC_RUNTIME");
getSDKPath(SDKPath);
GCCLibSTDCXXPath << SDKPath << "/../../" << otriple << "/lib";
GCCLibPath << SDKPath << "/../../lib/gcc/" << otriple << "/"
<< gccversion.Str();
GCCLibPath << SDKPath << "/../../lib/gcc/"
<< otriple << "/" << gccversion.Str();
auto addLib = [&](const std::stringstream &path, const char *lib) {
static std::stringstream tmp;
clear(tmp);
tmp << path.str() << "/lib" << lib << ".a";
fargs.push_back(tmp.str());
};
GCCLibSTDCXXPath << SDKPath << "/../../" << otriple << "/lib";
switch (arch) {
case Arch::i386:
case Arch::i486:
case Arch::i586:
case Arch::i686:
GCCLibSTDCXXPath << "/" << getArchName(i386);
GCCLibPath << "/" << getArchName(Arch::i386);
GCCLibSTDCXXPath << "/" << getArchName(i386);
default:
;
}
if (dynamic) {
fargs.push_back("-L");
fargs.push_back(GCCLibPath.str());
fargs.push_back("-L");
fargs.push_back(GCCLibSTDCXXPath.str());
}
auto addLib = [&](const std::stringstream &path, const char *lib) {
if (dynamic) {
fargs.push_back("-l");
fargs.push_back(lib);
} else {
static std::stringstream tmp;
clear(tmp);
tmp << path.str() << "/lib" << lib << ".a";
fargs.push_back(tmp.str());
}
};
fargs.push_back("-Qunused-arguments");
addLib(GCCLibSTDCXXPath, "stdc++");
@ -565,13 +580,11 @@ bool Target::setup() {
}
}
/* TODO: libgcc */
if (isCXX() && (/*!isCXX11orNewer() ||*/ isLibCXX())) {
if (isCXX() && isLibCXX()) {
fargs.push_back("-nostdinc++");
fargs.push_back("-nodefaultlibs");
if (haveSourceFile() && !isGCH()) {
if (!isGCH()) {
std::string tmp;
tmp = "-L";
@ -584,17 +597,13 @@ bool Target::setup() {
if (isLibCXX()) {
fargs.push_back("-lc++");
fargs.push_back("-lc++abi");
} else if (isLibSTDCXX()) {
// Hack: Use SDKs libstdc++ as long
// >= -std=c++11 is not given.
fargs.push_back("-lstdc++");
}
fargs.push_back(OSNum <= OSVersion(10, 4) ? "-lgcc_s.10.4"
: "-lgcc_s.10.5");
}
} else if (!isLibCXX() /*&& isCXX11orNewer()*/ && !isGCH()) {
} else if (!isLibCXX() && !isGCH() &&
!getenv("OSXCROSS_GCC_NO_STATIC_RUNTIME")) {
fargs.push_back("-static-libgcc");
fargs.push_back("-static-libstdc++");
}