diff --git a/CHANGELOG b/CHANGELOG index aa4df27..83d2ce4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ changed: added: * support for new '-arch x86_64h' (requires clang 3.5+) * support for multiple '-arch' flags with gcc + * OS X 10.10 support (DP1) /******************************* v0.7 *******************************/ diff --git a/README.md b/README.md index 6862b15..864f680 100755 --- a/README.md +++ b/README.md @@ -145,13 +145,13 @@ However, there are several ways to override the default value: \>= 10.9 also defaults to `libc++` instead of `libstdc++`, this behavior can be overriden by explicitly passing `-stdlib=libstdc++` to clang. -x86_64h defaults to `Mac OS X 10.9` and requires clang 3.5+. +x86\_64h defaults to `Mac OS X 10.9` and requires clang 3.5+. +x86\_64h = x86\_64 with optimizations for the Intel Haswell Architecture. ### LICENSE: #### * scripts/wrapper: GPLv2 * cctools/ld64: APSL 2.0 * xar: New BSD - * bc: GPLv3 ### CREDITS: #### * [cjacker for the cctools linux port](https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/source/browse/#svn%2Ftrunk%2Fcctools-porting%2Fpatches) diff --git a/build.sh b/build.sh index 4c6a951..0cd77b4 100755 --- a/build.sh +++ b/build.sh @@ -96,6 +96,7 @@ case $SDK_VERSION in 10.7*) TARGET=darwin11 ;; 10.8*) TARGET=darwin12 ;; 10.9*) TARGET=darwin13 ;; + 10.10*) TARGET=darwin14 ;; *) echo "Invalid SDK Version" && exit 1 ;; esac @@ -166,7 +167,6 @@ if [ ! -f "have_cctools_${CCTOOLS_REVHASH}_$TARGET" ]; then rm -rf cctools* rm -rf xar* -rm -rf bc* extract $CCTOOLS_TARBALL 1 @@ -217,25 +217,6 @@ LINKER_VERSION="`get_ld_version`" fi # CCTOOLS END -# BC -set +e -which bc &>/dev/null -NEED_BC=$? -set -e - -if [ $NEED_BC -ne 0 ]; then - -extract $TARBALL_DIR/bc*.tar.bz2 2 - -pushd bc* &>/dev/null -CFLAGS="-w" ./configure --prefix=$TARGET_DIR --without-flex -$MAKE -j$JOBS -$MAKE install -j$JOBS -popd &>/dev/null - -fi -# BC END - SDK=`ls $TARBALL_DIR/MacOSX$SDK_VERSION*` # XAR @@ -344,11 +325,11 @@ $BASE_DIR/wrapper/build.sh 1>/dev/null echo "" if [ "$OSX_VERSION_MIN" != "default" ]; then - if [ `echo "${SDK_VERSION/u/}<$OSX_VERSION_MIN" | bc -l` -eq 1 ]; then + if [ `osxcross-cmp ${SDK_VERSION/u/} "<" $OSX_VERSION_MIN` -eq 1 ]; then echo "OSX_VERSION_MIN must be <= SDK_VERSION" trap "" EXIT exit 1 - elif [ `echo "$OSX_VERSION_MIN<10.4" | bc -l` -eq 1 ]; then + elif [ `osxcross-cmp $OSX_VERSION_MIN "<" 10.4` -eq 1 ]; then echo "OSX_VERSION_MIN must be >= 10.4" trap "" EXIT exit 1 @@ -361,7 +342,7 @@ test_compiler o64-clang $BASE_DIR/oclang/test.c test_compiler o32-clang++ $BASE_DIR/oclang/test.cpp test_compiler o64-clang++ $BASE_DIR/oclang/test.cpp -if [ `echo "${SDK_VERSION/u/}>=10.7" | bc -l` -eq 1 ]; then +if [ `osxcross-cmp ${SDK_VERSION/u/} ">=" 10.7` -eq 1 ]; then if [ ! -d "$SDK_DIR/MacOSX$SDK_VERSION.sdk/usr/include/c++/v1" ]; then echo "" echo -n "Given SDK does not contain libc++ headers " diff --git a/tarballs/bc-1.06.94.tar.bz2 b/tarballs/bc-1.06.94.tar.bz2 deleted file mode 100644 index 0a89190..0000000 Binary files a/tarballs/bc-1.06.94.tar.bz2 and /dev/null differ diff --git a/tools/gen_sdk_package.sh b/tools/gen_sdk_package.sh index 48a12e0..a7c609c 100755 --- a/tools/gen_sdk_package.sh +++ b/tools/gen_sdk_package.sh @@ -4,22 +4,22 @@ # This script must be run on OS X # -if [ $(uname -s) != "Darwin" ]; then +if [ -z "$XCODEDIR" -a $(uname -s) != "Darwin" ]; then echo "This script must be run on OS X" exit 1 -fi +elif [ -z "$XCODEDIR" ]; then + XCODEDIR=$(ls /Volumes | grep Xcode | head -n1) -XCODEDIR=$(ls /Volumes | grep Xcode | head -n1) - -if [ -z "$XCODEDIR" ]; then - if [ -d "/Applications/Xcode.app" ]; then - XCODEDIR="/Applications/Xcode.app" + if [ -z "$XCODEDIR" ]; then + if [ -d "/Applications/Xcode.app" ]; then + XCODEDIR="/Applications/Xcode*.app" + else + echo "please mount Xcode.dmg" + exit 1 + fi else - echo "please mount Xcode.dmg" - exit 1 + XCODEDIR="/Volumes/$XCODEDIR/Xcode*.app" fi -else - XCODEDIR="/Volumes/$XCODEDIR/Xcode.app" fi [ ! -d $XCODEDIR ] && exit 1 diff --git a/wrapper/Makefile b/wrapper/Makefile index fcc3404..2cf1f44 100644 --- a/wrapper/Makefile +++ b/wrapper/Makefile @@ -41,6 +41,7 @@ SRCS= \ programs/osxcross-version.cpp \ programs/osxcross-env.cpp \ programs/osxcross-conf.cpp \ + programs/osxcross-cmp.cpp \ programs/sw_vers.cpp OBJS=$(subst .cpp,.o,$(SRCS)) diff --git a/wrapper/main.cpp b/wrapper/main.cpp index e8b6d6d..3679798 100644 --- a/wrapper/main.cpp +++ b/wrapper/main.cpp @@ -490,7 +490,7 @@ void generateMultiArchObjectFile(int &rc, int argc, char **argv, Target &target, pid_t pid; ++num; - obj.str(std::string()); + clear(obj); obj << "/tmp/" << getNanoSeconds() << "_" << outputname << "_" << archname; objs.push_back(obj.str()); diff --git a/wrapper/programs/osxcross-cmp.cpp b/wrapper/programs/osxcross-cmp.cpp new file mode 100644 index 0000000..dd4376f --- /dev/null +++ b/wrapper/programs/osxcross-cmp.cpp @@ -0,0 +1,57 @@ +/*********************************************************************** + * OSXCross Compiler Wrapper * + * Copyright (C) 2014 by Thomas Poechtrager * + * t.poechtrager@gmail.com * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***********************************************************************/ + +#include "proginc.h" + +using namespace tools; + +namespace program { +namespace osxcross { + +int cmp(int argc, char **argv) { + if (argc < 4) + return 1; + + OSVersion a = parseOSVersion(argv[1]); + OSVersion b = parseOSVersion(argv[3]); + + const char *op = argv[2]; + bool res; + + if (!strcmp(op, ">")) + res = a > b; + else if (!strcmp(op, "<")) + res = a < b; + else if (!strcmp(op, ">=")) + res = a >= b; + else if (!strcmp(op, "<=")) + res = a <= b; + else if (!strcmp(op, "==")) + res = a == b; + else + return 1; + + std::cout << (res ? "1" : "0"); + return 0; +} + +} // namespace osxcross +} // namespace program diff --git a/wrapper/progs.h b/wrapper/progs.h index 1f4dd17..dab3a2f 100644 --- a/wrapper/progs.h +++ b/wrapper/progs.h @@ -80,6 +80,7 @@ namespace osxcross { int version(); int env(int argc, char **argv); int conf(const Target &target); +int cmp(int argc, char **argv); } // namespace osxcross static int dummy() { return 0; } @@ -89,6 +90,7 @@ constexpr prog programs[] = { { "sw_vers", sw_vers }, { "osxcross", osxcross::version }, { "osxcross-env", osxcross::env }, { "osxcross-conf", osxcross::conf }, + { "osxcross-cmp", osxcross::cmp }, { "wrapper", dummy } }; template const prog *getprog(const T &name) { diff --git a/wrapper/target.cpp b/wrapper/target.cpp index ddc82c8..d70d507 100644 --- a/wrapper/target.cpp +++ b/wrapper/target.cpp @@ -214,7 +214,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { static ClangVersion clangversion; static std::string pathtmp; - dir.str(std::string()); + clear(dir); clangversion = ClangVersion(); pathtmp.clear(); @@ -227,10 +227,9 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { if (cv != ClangVersion()) { static std::stringstream tmp; - tmp.str(std::string()); + clear(tmp); - auto checkDir = [&](std::stringstream &dir) - { + auto checkDir = [&](std::stringstream &dir) { static std::string intrindir; auto &file = dir; @@ -251,7 +250,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { tmp << dir.str() << "/" << file << "/include"; if (!checkDir(tmp)) { - tmp.str(std::string()); + clear(tmp); tmp << dir.str() << "/" << file; checkDir(tmp); } @@ -269,7 +268,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { dir << clangbin << "/../lib/clang"; if (!check()) { - dir.str(std::string()); + clear(dir); #ifdef __APPLE__ constexpr const char *OSXIntrinDirs[] = { @@ -283,7 +282,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { if (check()) { break; } - dir.str(std::string()); + clear(dir); } #endif @@ -306,7 +305,6 @@ void Target::setupGCCLibs(Arch arch) { std::string SDKPath; std::stringstream GCCLibSTDCXXPath; std::stringstream GCCLibPath; - std::stringstream tmp; getSDKPath(SDKPath); @@ -314,6 +312,13 @@ void Target::setupGCCLibs(Arch arch) { 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()); + }; + switch (arch) { case Arch::i386: case Arch::i486: @@ -327,20 +332,10 @@ void Target::setupGCCLibs(Arch arch) { fargs.push_back("-Qunused-arguments"); - tmp << GCCLibSTDCXXPath.str() << "/libstdc++.a"; - fargs.push_back(tmp.str()); - - tmp.str(std::string()); - tmp << GCCLibSTDCXXPath.str() << "/libsupc++.a"; - fargs.push_back(tmp.str()); - - tmp.str(std::string()); - tmp << GCCLibPath.str() << "/libgcc.a"; - fargs.push_back(tmp.str()); - - tmp.str(std::string()); - tmp << GCCLibPath.str() << "/libgcc_eh.a"; - fargs.push_back(tmp.str()); + addLib(GCCLibSTDCXXPath, "stdc++"); + addLib(GCCLibSTDCXXPath, "supc++"); + addLib(GCCLibPath, "gcc"); + addLib(GCCLibPath, "gcc_eh"); fargs.push_back("-lc"); diff --git a/wrapper/tools.cpp b/wrapper/tools.cpp index 1019f22..5b10c12 100644 --- a/wrapper/tools.cpp +++ b/wrapper/tools.cpp @@ -173,7 +173,7 @@ const std::string &getParentProcessName() { } return name; } else { - file.str(std::string()); + clear(file); file << "/proc/" << ppid << "/exe"; char buf[PATH_MAX + 1]; if (readlink(file.str().c_str(), buf, sizeof(buf)) > 0) { diff --git a/wrapper/tools.h b/wrapper/tools.h index 691182f..792686f 100644 --- a/wrapper/tools.h +++ b/wrapper/tools.h @@ -21,8 +21,18 @@ namespace tools { +// +// Misc helper tools +// + typedef std::vector string_vector; +static inline void clear(std::stringstream &sstr) +{ + sstr.clear(); + sstr.str(std::string()); +} + // // Executable path // @@ -38,7 +48,7 @@ std::string &fixPathDiv(std::string &path); void concatEnvVariable(const char *var, const std::string val); // -// Files and Directories +// Files and directories // std::string *getFileContent(const std::string &file, std::string &content); @@ -130,6 +140,10 @@ struct OSVersion { return Num() <= OSNum.Num(); } + constexpr bool operator==(const OSVersion &OSNum) const { + return Num() == OSNum.Num(); + } + constexpr bool operator!=(const OSVersion &OSNum) const { return Num() != OSNum.Num(); } @@ -239,7 +253,7 @@ inline Arch parseArch(const char *arch) { } // -// Stdlib +// Standard Library // enum StdLib {