mirror of
https://github.com/tpoechtrager/osxcross.git
synced 2024-08-16 20:10:35 +03:00
new compiler wrapper written in C++
to highlight some changes: - this gets rid of the bash dependency (after installing) - osxcross-env, osxcross-conf and (the fake) dsymutil are now implemented in the wrapper - added: 'sw_vers' tool, which is required by some projects (llvm, ...) - added '-oc-use-gcc-libs' option (uses './build_gcc.sh' libstdc++) This new wrapper is also more restrict and several times faster than the bash implementation (~0.2ms vs. 10ms+).
This commit is contained in:
parent
03b2068713
commit
f8e57bfcd3
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*gcc*.tar.*
|
||||
*MacOSX*.*
|
||||
cpucount
|
||||
build/
|
||||
target/
|
10
CHANGELOG
10
CHANGELOG
@ -1,3 +1,11 @@
|
||||
0.7:
|
||||
- added: new compiler wrapper written in C++
|
||||
- added: '-oc-use-gcc-libs' option (uses './build_gcc.sh' libstdc++)
|
||||
- added: 10.6 SDK support (10.4-10.9 are all supported now)
|
||||
- added: 'sw_vers' tool, which is required by some projects
|
||||
- changed: 'osxcross-conf', 'osxcross-env' and the (fake) 'dsymutil' are now implemented in the wrapper
|
||||
- changed: switched to two-space indents
|
||||
|
||||
0.6:
|
||||
- added: NetBSD support
|
||||
- added: dependencies installer script (Don Bright)
|
||||
@ -16,7 +24,7 @@
|
||||
- added: a workaround for buggy unistd.h headers
|
||||
|
||||
0.3:
|
||||
- added: support 10.9 (Mavericks) SDK
|
||||
- added: 10.9 SDK support
|
||||
- added: *-apple-darwin*-clang* symlinks (same as invoking o32-clang or o64-clang++)
|
||||
- changed: no need to build extra cctools binaries for targeting i386, symlinking the x86_64 builds works as well
|
||||
|
||||
|
11
README.md
11
README.md
@ -6,7 +6,8 @@ The goal of OSXCross is to provide a well working OS X cross toolchain for Linux
|
||||
|
||||
### HOW DOES IT WORK? ###
|
||||
|
||||
[Clang/LLVM is a cross compiler by default](http://clang.llvm.org/docs/CrossCompilation.html) and is now available on nearly every Linux distribution,
|
||||
[Clang/LLVM is a cross compiler by default](http://clang.llvm.org/docs/CrossCompilation.html)
|
||||
and is now available on nearly every Linux distribution,
|
||||
so we just need a proper
|
||||
[port](https://github.com/tpoechtrager/cctools-port)
|
||||
of the [cctools](http://www.opensource.apple.com/tarballs/cctools) (ld, lipo, ...) and the OS X SDK.
|
||||
@ -90,6 +91,14 @@ You can use the shortcut `o32-...` or `i386-apple-darwin...` what ever you like
|
||||
|
||||
##### Building test.cpp with libc++: #####
|
||||
|
||||
Note: libc++ requires Mac OS X 10.7 or newer! If you really need C++11 for
|
||||
an older OS X version, then you can do the following:
|
||||
|
||||
1. Build GCC so you have an up-to-date libstdc++
|
||||
2. Build your source code with GCC or with clang and '-oc-use-gcc-libs'
|
||||
|
||||
Usage Examples:
|
||||
|
||||
* Clang:
|
||||
|
||||
* C++98: `o32-clang++ -stdlib=libc++ test.cpp -o test`
|
||||
|
127
build.sh
127
build.sh
@ -80,7 +80,7 @@ fi
|
||||
LINKER_VERSION=134.9
|
||||
|
||||
# Don't change this
|
||||
OSXCROSS_VERSION=0.6
|
||||
OSXCROSS_VERSION=0.7
|
||||
|
||||
TARBALL_DIR=$BASE_DIR/tarballs
|
||||
BUILD_DIR=$BASE_DIR/build
|
||||
@ -102,6 +102,8 @@ case $SDK_VERSION in
|
||||
*) echo "Invalid SDK Version" && exit 1 ;;
|
||||
esac
|
||||
|
||||
export TARGET
|
||||
|
||||
echo ""
|
||||
echo "Building OSXCross toolchain, Version: $OSXCROSS_VERSION"
|
||||
echo ""
|
||||
@ -132,8 +134,6 @@ require autogen
|
||||
require automake
|
||||
require libtool
|
||||
|
||||
CLANG_TARGET_OPTION=`./oclang/check_target_option.sh`
|
||||
|
||||
pushd $BUILD_DIR &>/dev/null
|
||||
|
||||
function remove_locks()
|
||||
@ -287,108 +287,38 @@ set +e
|
||||
ln -s \
|
||||
$SDK_DIR/MacOSX$SDK_VERSION.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/std*.h \
|
||||
usr/include 2>/dev/null
|
||||
$BASE_DIR/oclang/find_intrinsic_headers.sh $SDK_DIR/MacOSX$SDK_VERSION.sdk
|
||||
test ! -f "usr/include/float.h" && cp -f $BASE_DIR/oclang/quirks/float.h usr/include
|
||||
set -e
|
||||
popd &>/dev/null
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
cp -f oclang/dsymutil $TARGET_DIR/bin
|
||||
|
||||
WRAPPER=$TARGET_DIR/bin/x86_64-apple-$TARGET-oclang
|
||||
cp -f oclang/oclang $WRAPPER
|
||||
|
||||
WRAPPER_SCRIPT=`basename $WRAPPER`
|
||||
WRAPPER_DIR=`dirname $WRAPPER`
|
||||
|
||||
pushd $WRAPPER_DIR &>/dev/null
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT o32-clang
|
||||
ln -sf $WRAPPER_SCRIPT o32-clang++
|
||||
ln -sf $WRAPPER_SCRIPT o32-clang++-libc++
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT o64-clang
|
||||
ln -sf $WRAPPER_SCRIPT o64-clang++
|
||||
ln -sf $WRAPPER_SCRIPT o64-clang++-libc++
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$TARGET-clang
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$TARGET-clang++
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$TARGET-clang++-libc++
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang++
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang++-libc++
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
OSXCROSS_CONF="$TARGET_DIR/bin/osxcross-conf"
|
||||
OSXCROSS_ENV="$TARGET_DIR/bin/osxcross-env"
|
||||
|
||||
rm -f $OSXCROSS_CONF $ENV_CONF
|
||||
rm -f $OSXCROSS_CONF $OSXCROSS_ENV
|
||||
|
||||
echo "#!/usr/bin/env bash" > $OSXCROSS_CONF
|
||||
echo "" >> $OSXCROSS_CONF
|
||||
echo "pushd \"\${0%/*}\" &>/dev/null" >> $OSXCROSS_CONF
|
||||
echo "" >> $OSXCROSS_CONF
|
||||
echo "DIR=\`pwd\`" >> $OSXCROSS_CONF
|
||||
echo "OSXCROSS_ROOT=\$DIR/../.." >> $OSXCROSS_CONF
|
||||
echo "" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_VERSION=$OSXCROSS_VERSION\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_OSX_VERSION_MIN=$OSX_VERSION_MIN\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_TARGET=$TARGET\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_SDK_VERSION=$SDK_VERSION\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_SDK=\$DIR/../`basename $SDK_DIR`/MacOSX$SDK_VERSION.sdk\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_TARBALL_DIR=\$OSXCROSS_ROOT/`basename $TARBALL_DIR`\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_PATCH_DIR=\$OSXCROSS_ROOT/`basename $PATCH_DIR`\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_TARGET_DIR=\$OSXCROSS_ROOT/`basename $TARGET_DIR`\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_BUILD_DIR=\$OSXCROSS_ROOT/`basename $BUILD_DIR`\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_CCTOOLS_PATH=\$DIR\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_TARGET_OPTION=$CLANG_TARGET_OPTION\"" >> $OSXCROSS_CONF
|
||||
echo "echo \"export OSXCROSS_LINKER_VERSION=$LINKER_VERSION\"" >> $OSXCROSS_CONF
|
||||
echo "" >> $OSXCROSS_CONF
|
||||
echo "popd &>/dev/null" >> $OSXCROSS_CONF
|
||||
echo "" >> $OSXCROSS_CONF
|
||||
|
||||
if [ -f $BUILD_DIR/cctools*/cctools/tmp/ldpath ]; then
|
||||
LIB_PATH=:`cat $BUILD_DIR/cctools*/cctools/tmp/ldpath`
|
||||
else
|
||||
LIB_PATH=""
|
||||
fi
|
||||
|
||||
echo "#!/bin/sh" > $OSXCROSS_ENV
|
||||
echo "" >> $OSXCROSS_ENV
|
||||
echo "BDIR=\`readlink -f \\\`dirname \$0\\\`\`" >> $OSXCROSS_ENV
|
||||
echo "" >> $OSXCROSS_ENV
|
||||
echo "echo \"export PATH=\$PATH:\$BDIR\"" >> $OSXCROSS_ENV
|
||||
echo "echo \"export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$BDIR/../lib${LIB_PATH}\"" >> $OSXCROSS_ENV
|
||||
|
||||
|
||||
chmod +x $OSXCROSS_CONF $OSXCROSS_ENV
|
||||
echo "compiling wrapper ..."
|
||||
export OSX_VERSION_MIN
|
||||
export LINKER_VERSION
|
||||
$BASE_DIR/wrapper/build.sh 1>/dev/null
|
||||
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`cat $BUILD_DIR/cctools*/cctools/tmp/ldpath`" # libLTO.so
|
||||
|
||||
echo ""
|
||||
|
||||
if [ -n $OSX_VERSION_MIN ]; then
|
||||
if [ `echo "${SDK_VERSION/u/}<$OSX_VERSION_MIN" | bc -l` -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
|
||||
echo "OSX_VERSION_MIN must be >= 10.4"
|
||||
trap "" EXIT
|
||||
exit 1
|
||||
if [ `echo "${SDK_VERSION/u/}<$OSX_VERSION_MIN" | bc -l` -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
|
||||
echo "OSX_VERSION_MIN must be >= 10.4"
|
||||
trap "" EXIT
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ `echo "${SDK_VERSION/u/}>=10.9" | bc -l` -eq 1 ] && ( [ $OSX_VERSION_MIN == "default" ] ||
|
||||
[ `echo "$OSX_VERSION_MIN>=10.9" | bc -l` -eq 1 ] );
|
||||
then
|
||||
export SCRIPT=`basename $0`
|
||||
./build_libcxx.sh || exit 0
|
||||
fi
|
||||
fi # OSX_VERSION_MIN set
|
||||
|
||||
test_compiler o32-clang $BASE_DIR/oclang/test.c
|
||||
test_compiler o64-clang $BASE_DIR/oclang/test.c
|
||||
|
||||
@ -408,12 +338,33 @@ if [ `echo "${SDK_VERSION/u/}>=10.7" | bc -l` -eq 1 ]; then
|
||||
test_compiler_cxx11 o64-clang++ $BASE_DIR/oclang/test_libcxx.cpp
|
||||
fi
|
||||
|
||||
set +e
|
||||
which csh &>/dev/null
|
||||
HAVE_CSH=0
|
||||
[ $? -eq 0 ] && HAVE_CSH=1
|
||||
|
||||
if [ $HAVE_CSH -eq 0 ]; then
|
||||
which tcsh &>/dev/null
|
||||
[ $? -eq 0 ] && HAVE_CSH=1
|
||||
fi
|
||||
|
||||
CSHRC=""
|
||||
[ $HAVE_CSH -eq 1 ] && CSHRC=", ~/.cshrc"
|
||||
set -e
|
||||
|
||||
echo ""
|
||||
echo "Now add"
|
||||
echo ""
|
||||
echo -e "\e[32m\`$OSXCROSS_ENV\`\e[0m"
|
||||
echo ""
|
||||
echo "to your ~/.bashrc or ~/.profile (including the '\`')"
|
||||
if [ $HAVE_CSH -eq 1 ]; then
|
||||
echo "or in case of csh:"
|
||||
echo ""
|
||||
echo -e "\e[32msetenv PATH \`$OSXCROSS_ENV -v=PATH\`\e[0m"
|
||||
echo -e "\e[32msetenv LD_LIBRARY_PATH \`$OSXCROSS_ENV -v=LD_LIBRARY_PATH\`\e[0m"
|
||||
echo ""
|
||||
fi
|
||||
echo "to your ~/.bashrc${CSHRC} or ~/.profile (including the '\`')"
|
||||
echo ""
|
||||
|
||||
echo "Done! Now you can use o32-clang(++) and o64-clang(++) like a normal compiler"
|
||||
|
27
build_gcc.sh
27
build_gcc.sh
@ -78,13 +78,7 @@ fi # have gcc
|
||||
|
||||
popd &>/dev/null # build dir
|
||||
|
||||
WRAPPER=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-${OSXCROSS_TARGET}-ogcc
|
||||
cp ogcc/ogcc $WRAPPER
|
||||
|
||||
WRAPPER_SCRIPT=`basename $WRAPPER`
|
||||
WRAPPER_DIR=`dirname $WRAPPER`
|
||||
|
||||
pushd $WRAPPER_DIR &>/dev/null
|
||||
pushd $OSXCROSS_TARGET_DIR/bin &>/dev/null
|
||||
|
||||
if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
||||
mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc
|
||||
@ -94,21 +88,14 @@ if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
||||
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-g++ i386-apple-$OSXCROSS_TARGET-base-g++
|
||||
fi
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT o32-gcc
|
||||
ln -sf $WRAPPER_SCRIPT o32-g++
|
||||
ln -sf $WRAPPER_SCRIPT o32-g++-libc++
|
||||
echo "compiling wrapper ..."
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT o64-gcc
|
||||
ln -sf $WRAPPER_SCRIPT o64-g++
|
||||
ln -sf $WRAPPER_SCRIPT o64-g++-libc++
|
||||
export TARGET=$OSXCROSS_TARGET
|
||||
export OSX_VERSION_MIN=$OSXCROSS_OSX_VERSION_MIN
|
||||
export LINKER_VERSION=$OSXCROSS_LINKER_VERSION
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-gcc
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-g++
|
||||
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-g++-libc++
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-gcc
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-g++
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-g++-libc++
|
||||
TARGETCOMPILER=gcc \
|
||||
$BASE_DIR/wrapper/build.sh 1>/dev/null
|
||||
|
||||
popd &>/dev/null # wrapper dir
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL="C"
|
||||
|
||||
which clang 2>&1 1>/dev/null || exit 1
|
||||
|
||||
x=`clang -target i386-apple-darwin9 2>&1`
|
||||
|
||||
case "$x" in
|
||||
*i386-apple-darwin9*)
|
||||
echo "-ccc-host-triple"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "-target"
|
@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# No-op script to bypass dsymutil invocation errors
|
||||
#
|
||||
# Please see:
|
||||
# https://github.com/tpoechtrager/osxcross/issues/1
|
||||
# https://github.com/tpoechtrager/osxcross/pull/2
|
||||
#
|
||||
|
||||
if [ $# -eq 0 ] || [ -n "$OSXCROSS_SHOW_DSYMUTIL_INVOCATION" ]; then
|
||||
NAME_OF_PARENT_PROCESS=`basename \`ps -ocommand= -p $PPID 2>/dev/null | awk '{print $1}'\``
|
||||
|
||||
echo -en "\e[1mosxcross \e[35mwarning:\e[0m\e[1m dsymutil invocation is a no-op (dsymutil $@) " 1>&2
|
||||
|
||||
if [ -n "$NAME_OF_PARENT_PROCESS" ]; then
|
||||
echo -e "(invoked by $NAME_OF_PARENT_PROCESS)\e[0m" 1>&2
|
||||
else
|
||||
echo -e "\e[0m" 1>&2
|
||||
fi
|
||||
fi
|
@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# help clang to find its own intrinsic headers
|
||||
# this issue appears to be fixed in 3.4+
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
set -e
|
||||
|
||||
SDK_DIR="$1"
|
||||
|
||||
test -n "$SDK_DIR" || { echo "no SDK directory given" && exit 1; }
|
||||
test -e "$SDK_DIR" || { echo "$SDK_DIR does not exist" && exit 1; }
|
||||
|
||||
CLANG_VERSION=`echo "int main(){printf(\"%d.%d\",__clang_major__,__clang_minor__);return 0;}" | clang -xc -ansi -otest - 2>/dev/null && ./test && rm test`
|
||||
CLANG_DIR=`dirname \`which clang\``
|
||||
|
||||
CLANG_INTRIN_DIR="$CLANG_DIR/../include/clang/$CLANG_VERSION/include"
|
||||
|
||||
test ! -e "$CLANG_INTRIN_DIR" && CLANG_INTRIN_DIR="$CLANG_DIR/../lib/clang/$CLANG_VERSION/include"
|
||||
test ! -e "$CLANG_INTRIN_DIR" && CLANG_INTRIN_DIR="$CLANG_DIR/../include/clang/$CLANG_VERSION/include"
|
||||
test ! -e "$CLANG_INTRIN_DIR" && CLANG_INTRIN_DIR="$CLANG_DIR/../include/clang/$CLANG_VERSION"
|
||||
|
||||
test -e "$CLANG_INTRIN_DIR" || { echo "cannot find clang intrinsics directory" && exit 1; }
|
||||
test -f "$CLANG_INTRIN_DIR/xmmintrin.h" || { echo "xmmintrin.h does not exist in $CLANG_INTRIN_DIR" && exit 1; }
|
||||
|
||||
echo "found clang intrinsic headers: $CLANG_INTRIN_DIR"
|
||||
|
||||
test -f $CLANG_INTRIN_DIR/float.h && ln -sf $CLANG_INTRIN_DIR/float.h $SDK_DIR/usr/include
|
||||
test -f $CLANG_INTRIN_DIR/stdarg.h && ln -sf $CLANG_INTRIN_DIR/stdarg.h $SDK_DIR/usr/include
|
||||
|
||||
ln -sf $CLANG_INTRIN_DIR/*intrin*.h $SDK_DIR/usr/include
|
||||
ln -sf $CLANG_INTRIN_DIR/mm*.h $SDK_DIR/usr/include
|
||||
ln -sf $CLANG_INTRIN_DIR/*va*.h $SDK_DIR/usr/include
|
||||
ln -sf $CLANG_INTRIN_DIR/*cpu*.h $SDK_DIR/usr/include
|
||||
ln -sf $CLANG_INTRIN_DIR/*math*.h $SDK_DIR/usr/include
|
||||
ln -sf $CLANG_INTRIN_DIR/*iso*.h $SDK_DIR/usr/include
|
@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function try()
|
||||
{
|
||||
LLVM_CONFIG="llvm-config$1"
|
||||
which $LLVM_CONFIG &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
set -e
|
||||
LLVM_INC_DIR=`$LLVM_CONFIG --includedir`
|
||||
LLVM_LIB_DIR=`$LLVM_CONFIG --libdir`
|
||||
ln -sf "$LLVM_INC_DIR/llvm-c/lto.h" "include/llvm-c/lto.h"
|
||||
echo -n "export LDFLAGS+=\" -L$LLVM_LIB_DIR -lLTO \" "
|
||||
echo -n "export CFLAGS+=\" -DLTO_SUPPORT=1 \" "
|
||||
echo -n "export CXXFLAGS+=\" -DLTO_SUPPORT=1 \""
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
try ""
|
||||
try "-3.2"
|
||||
try "-3.3"
|
||||
try "-3.4"
|
||||
try "-3.5"
|
||||
|
||||
echo "echo \"can not find lto.h - make sure llvm-devel is installed on your system\""
|
||||
exit 1
|
122
oclang/oclang
122
oclang/oclang
@ -1,122 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
eval `./osxcross-env`
|
||||
eval `./osxcross-conf`
|
||||
popd &>/dev/null
|
||||
|
||||
type=`basename $0`
|
||||
|
||||
if [[ $type == *o64* ]] || [[ $type == *x86_64* ]]; then
|
||||
ARCH1="x86_64"
|
||||
ARCH2=$ARCH1
|
||||
else
|
||||
if [[ $type == *o32* ]] || [[ $type == *i386* ]]; then
|
||||
ARCH1="i386"
|
||||
ARCH2="i686"
|
||||
else
|
||||
echo "unknown arch"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $type == *++* ]]; then
|
||||
COMPILER="clang++"
|
||||
else
|
||||
COMPILER="clang"
|
||||
fi
|
||||
|
||||
if [ $COMPILER == "clang++" ] && [[ $type == *libc++* ]]; then
|
||||
USE_LIBCXX=1
|
||||
else
|
||||
USE_LIBCXX=0
|
||||
fi
|
||||
|
||||
TARGET=$ARCH1-apple-$OSXCROSS_TARGET
|
||||
OSX_VERSION_MIN=$OSXCROSS_OSX_VERSION_MIN
|
||||
|
||||
export COMPILER_PATH="$OSXCROSS_CCTOOLS_PATH:$COMPILER_PATH"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
for p in "$@"
|
||||
do
|
||||
if [[ "$p" == -mmacosx-version-min=* ]]; then
|
||||
OSXCROSS_OSX_VERSION_MIN="default"
|
||||
OSX_VERSION_MIN=`echo "$p" | tr '=' ' ' | awk '{print $2}'`
|
||||
continue
|
||||
fi
|
||||
if [ "$p" == "-stdlib=libc++" ]; then
|
||||
USE_LIBCXX=2
|
||||
continue
|
||||
fi
|
||||
if [ "$p" == "-v" ] || [ "$p" == "--version" ]; then
|
||||
if [ $# -eq 1 ]; then
|
||||
$COMPILER $OSXCROSS_TARGET_OPTION $TARGET $p
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
$COMPILER $OSXCROSS_TARGET_OPTION $TARGET
|
||||
exit $?
|
||||
fi
|
||||
|
||||
STDINC=$OSXCROSS_SDK/usr/include
|
||||
|
||||
if [ $USE_LIBCXX -eq 0 ]; then
|
||||
MIN_TARGET_VERSION=`echo "$OSX_VERSION_MIN" | tr '.' ' ' | awk '{printf "%d %d", $1, $2}'`
|
||||
MIN_TARGET_VERSION_MAJOR=`echo $MIN_TARGET_VERSION | awk '{print $1}'`
|
||||
MIN_TARGET_VERSION_MINOR=`echo $MIN_TARGET_VERSION | awk '{print $2}'`
|
||||
|
||||
if [ $MIN_TARGET_VERSION_MAJOR -ge 10 ] && [ $MIN_TARGET_VERSION_MINOR -ge 9 ]; then
|
||||
# default to libc++ on >= 10.9
|
||||
USE_LIBCXX=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $USE_LIBCXX -ne 0 ]; then
|
||||
# -nostdinc++ to avoid using local libc++ headers...
|
||||
CXXINC="-nostdinc++ -cxx-isystem $OSXCROSS_SDK/usr/include/c++/v1"
|
||||
|
||||
if ( [ $OSX_VERSION_MIN != "default" ] &&
|
||||
[ `echo "$OSX_VERSION_MIN<=10.6" | bc -l` -eq 1 ] );
|
||||
then
|
||||
if [ $OSXCROSS_OSX_VERSION_MIN = "default" ]; then
|
||||
echo -en "\e[1mosxcross \e[31merror:\e[0m\e[0m" 2>&1
|
||||
echo " -stdlib=libc++ requires Mac OS X 10.7 or later" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
OSXCROSS_OSX_VERSION_MIN="10.7"
|
||||
fi
|
||||
else
|
||||
CXXINC="-cxx-isystem $OSXCROSS_SDK/usr/lib/gcc/i686-apple-$OSXCROSS_TARGET/4.2.1/include"
|
||||
CXXINC="$CXXINC -cxx-isystem $OSXCROSS_SDK/usr/include/c++/4.0.0 "
|
||||
CXXINC="$CXXINC -cxx-isystem $OSXCROSS_SDK/usr/include/c++/4.0.0/$ARCH2-apple-darwin9 "
|
||||
fi
|
||||
|
||||
if [ $OSXCROSS_OSX_VERSION_MIN != "default" ]; then
|
||||
OSX_VERSION_MIN_OPT="-mmacosx-version-min=$OSXCROSS_OSX_VERSION_MIN"
|
||||
else
|
||||
OSX_VERSION_MIN_OPT=""
|
||||
fi
|
||||
|
||||
XMMINTRIN=`readlink "$STDINC/xmmintrin.h"`
|
||||
if [ $? -eq 0 ] && [ ! -f "$XMMINTRIN" ]; then
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
if [ -f "osxcross-fix-intrinsic-headers" ]; then
|
||||
echo -e "\e[1mosxcross:\e[0m\e[35m fixing intrinsic symlinks...\e[0m" 1>&2
|
||||
./osxcross-fix-intrinsic-headers $OSXCROSS_SDK || { echo -e "\e[31mfailed.\e[0m" 1>&2 && exit 1; }
|
||||
echo -e "\e[1mdone.\e[0m" 1>&2
|
||||
else
|
||||
echo -en "\e[1mosxcross \e[31merror:\e[0m\e[1m dead intrinsic link found -" 1>&2
|
||||
echo -e "please re-run ./build.sh\e[0m" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
$COMPILER \
|
||||
$OSXCROSS_TARGET_OPTION $TARGET -isysroot $OSXCROSS_SDK \
|
||||
$CXXINC -mlinker-version=$OSXCROSS_LINKER_VERSION \
|
||||
$OSXCROSS_OPT_ARGS ${1+"$@"} $OSX_VERSION_MIN_OPT
|
||||
|
||||
exit $?
|
@ -1,27 +1,6 @@
|
||||
#include <typeindex>
|
||||
#include <type_traits>
|
||||
#include <chrono>
|
||||
#include <tuple>
|
||||
#include <scoped_allocator>
|
||||
#include <cstdint>
|
||||
#include <cinttypes>
|
||||
#include <system_error>
|
||||
#include <array>
|
||||
#include <forward_list>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
#include <cfenv>
|
||||
#include <codecvt>
|
||||
#include <regex>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
#include <condition_variable>
|
||||
#include <ctgmath>
|
||||
#include <cstdbool>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
|
99
ogcc/ogcc
99
ogcc/ogcc
@ -1,99 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
eval `./osxcross-env`
|
||||
eval `./osxcross-conf`
|
||||
popd &>/dev/null
|
||||
|
||||
type=`basename $0`
|
||||
|
||||
if [[ $type == *o64* ]] || [[ $type == *x86_64* ]]; then
|
||||
ARCH="x86_64"
|
||||
ARCHFLAG="-m64"
|
||||
else
|
||||
if [[ $type == *o32* ]] || [[ $type == *i386* ]]; then
|
||||
ARCH="i386"
|
||||
ARCHFLAG="-m32"
|
||||
else
|
||||
echo "unknown arch"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $type == *++* ]]; then
|
||||
COMPILER="$OSXCROSS_TARGET_DIR/bin/$ARCH-apple-$OSXCROSS_TARGET-base-g++"
|
||||
else
|
||||
COMPILER="$OSXCROSS_TARGET_DIR/bin/$ARCH-apple-$OSXCROSS_TARGET-base-gcc"
|
||||
fi
|
||||
|
||||
OSX_VERSION_MIN=$OSXCROSS_OSX_VERSION_MIN
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
ARCHGIVEN=0
|
||||
|
||||
for p in "$@"
|
||||
do
|
||||
if [ "$p" == "-arch" ] || [ "$p" == "-m32" ] || [ "$p" == "-m64" ]; then
|
||||
ARCHGIVEN=1
|
||||
continue
|
||||
fi
|
||||
if [[ "$p" == -mmacosx-version-min=* ]]; then
|
||||
OSXCROSS_OSX_VERSION_MIN="default"
|
||||
OSX_VERSION_MIN=`echo "$p" | tr '=' ' ' | awk '{print $2}'`
|
||||
continue
|
||||
fi
|
||||
if [ "$p" == "-v" ] || [ "$p" == "--version" ]; then
|
||||
if [ $# -eq 1 ]; then
|
||||
$COMPILER $p
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ARCHGIVEN -eq 0 ]; then
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS $ARCHFLAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $COMPILER == *g++ ]] && [[ $type == *libc++* ]]; then
|
||||
if ( [ $OSX_VERSION_MIN != "default" ] &&
|
||||
[ `echo "$OSX_VERSION_MIN<=10.6" | bc -l` -eq 1 ] );
|
||||
then
|
||||
if [ $OSXCROSS_OSX_VERSION_MIN = "default" ]; then
|
||||
echo -en "\e[1mosxcross \e[31merror:\e[0m\e[0m" 2>&1
|
||||
echo " -stdlib=libc++ requires Mac OS X 10.7 or later" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
OSXCROSS_OSX_VERSION_MIN="10.7"
|
||||
fi
|
||||
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS -std=c++0x -nostdinc++ -nodefaultlibs"
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS -lc -isystem $OSXCROSS_SDK/usr/include/c++/v1"
|
||||
|
||||
REGEX="\-o\s*[^ ]+\.gch"
|
||||
if [[ ! "$@" =~ $REGEX ]]; then
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS -lc++ -lc++abi -lgcc_s.10.5"
|
||||
fi
|
||||
else
|
||||
REGEX="\-o\s*[^ ]+\.gch"
|
||||
if [[ ! "$@" =~ $REGEX ]]; then
|
||||
if [[ $COMPILER == *g++ ]]; then
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS -static-libgcc -static-libstdc++"
|
||||
else
|
||||
OSXCROSS_OPT_ARGS="$OSXCROSS_OPT_ARGS -static-libgcc"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $OSXCROSS_OSX_VERSION_MIN != "default" ]; then
|
||||
OSX_VERSION_MIN_OPT="-mmacosx-version-min=$OSXCROSS_OSX_VERSION_MIN"
|
||||
else
|
||||
OSX_VERSION_MIN_OPT=""
|
||||
fi
|
||||
|
||||
export COMPILER_PATH="$OSXCROSS_CCTOOLS_PATH:$COMPILER_PATH"
|
||||
export LD_LIBRARY_PATH="/usr/local/lib:/usr/pkg/lib:$LD_LIBRARY_PATH"
|
||||
|
||||
$COMPILER $OSX_VERSION_MIN_OPT $OSXCROSS_OPT_ARGS ${1+"$@"}
|
||||
|
||||
exit $?
|
@ -11,11 +11,14 @@ else
|
||||
BINARYPACKAGE="0"
|
||||
fi
|
||||
|
||||
TMPDIR=`mktemp -d`
|
||||
TMPDIR=`mktemp -d /tmp/XXXXXXXXX`
|
||||
|
||||
BASEDIR=`pwd`
|
||||
|
||||
set +e
|
||||
REVHASH=`git rev-parse --short HEAD`
|
||||
set -e
|
||||
|
||||
OSXCROSSVER=`cat build.sh | grep "OSXCROSS_VERSION" | head -n1 | tr '=' ' ' | awk '{print $2}'`
|
||||
|
||||
pushd $TMPDIR
|
||||
@ -53,7 +56,7 @@ else
|
||||
echo "" >> $READMEINSTALL
|
||||
fi
|
||||
|
||||
find $BASEDIR -maxdepth 1 -type f -print0 | xargs -0 -i cp {} .
|
||||
find $BASEDIR -maxdepth 1 -type f -exec cp {} . \;
|
||||
|
||||
if [ $BINARYPACKAGE == "1" ]; then
|
||||
rm -f *.sh
|
||||
|
24
tools/tools.sh
Normal file → Executable file
24
tools/tools.sh
Normal file → Executable file
@ -9,15 +9,19 @@ export CXX=clang++
|
||||
# enable debug messages
|
||||
test -n "$OCDEBUG" && set -x
|
||||
|
||||
# how many concurrent jobs should be used for compiling?
|
||||
JOBS=`tools/get_cpu_count.sh`
|
||||
PSCRIPT="`basename $0`"
|
||||
|
||||
if [ "`basename $0`" != "build.sh" ]; then
|
||||
`tools/osxcross_conf.sh`
|
||||
if [[ $PSCRIPT != *wrapper/build.sh ]]; then
|
||||
# how many concurrent jobs should be used for compiling?
|
||||
JOBS=`tools/get_cpu_count.sh`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "you need to complete ./build.sh first, before you can start building $DESC"
|
||||
exit 1
|
||||
if [ $PSCRIPT != "build.sh" ]; then
|
||||
`tools/osxcross_conf.sh`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "you need to complete ./build.sh first, before you can start building $DESC"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -78,6 +82,12 @@ function extract()
|
||||
fi
|
||||
}
|
||||
|
||||
function verbose_cmd()
|
||||
{
|
||||
echo "$@"
|
||||
eval "$@"
|
||||
}
|
||||
|
||||
function test_compiler()
|
||||
{
|
||||
echo -ne "testing $1 ... "
|
||||
|
0
tools/trap_exit.sh
Normal file → Executable file
0
tools/trap_exit.sh
Normal file → Executable file
126
wrapper/build.sh
Executable file
126
wrapper/build.sh
Executable file
@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
pushd .. &>/dev/null
|
||||
source ./tools/tools.sh
|
||||
popd &>/dev/null
|
||||
|
||||
EXESUFFIX=""
|
||||
|
||||
function create_wrapper_link
|
||||
{
|
||||
verbose_cmd ln -sf "${TARGETTRIPLE}-wrapper${EXESUFFIX}" "${1}${EXESUFFIX}"
|
||||
}
|
||||
|
||||
[ -z "$TARGET" ] && TARGET=darwin12
|
||||
[ -z "$OSX_VERSION_MIN" ] && OSX_VERSION_MIN=10.5
|
||||
[ -z "$LINKER_VERSION" ] && LINKER_VERSION=134.9
|
||||
[ -z "$TARGETCOMPILER" ] && TARGETCOMPILER=clang
|
||||
|
||||
TARGETTRIPLE=x86_64-apple-$TARGET
|
||||
|
||||
FLAGS=""
|
||||
|
||||
if [ -n "$BWPLATFORM" ]; then
|
||||
PLATFORM=$BWPLATFORM
|
||||
|
||||
if [ $PLATFORM = "Darwin" -a $(uname -s) != "Darwin" ]; then
|
||||
CXX=o32-clang++
|
||||
elif [ $PLATFORM = "FreeBSD" -a $(uname -s) != "FreeBSD" ]; then
|
||||
CXX=amd64-pc-freebsd10.0-clang++
|
||||
FLAGS+="-lrt "
|
||||
elif [ $PLATFORM = "Windows" ]; then
|
||||
CXX=w32-clang++
|
||||
FLAGS+="-wc-static-runtime -g "
|
||||
EXESUFFIX=".exe"
|
||||
elif [ $PLATFORM = "MWindows" ]; then
|
||||
CXX=i686-w64-mingw32-g++
|
||||
FLAGS+="-static-libgcc -static-libstdc++ -g "
|
||||
EXESUFFIX=".exe"
|
||||
fi
|
||||
else
|
||||
PLATFORM=$(uname -s)
|
||||
FLAGS="-march=native "
|
||||
fi
|
||||
|
||||
if [ -n "$BWCXX" ]; then
|
||||
[ "$CXX" != "$BWCXX" ] && echo "using $BWCXX" 1>&2
|
||||
CXX=$BWCXX
|
||||
fi
|
||||
|
||||
[ $PLATFORM = "Darwin" ] && FLAGS+="-framework CoreServices "
|
||||
[ $PLATFORM = "FreeBSD" ] && FLAGS+="-lutil "
|
||||
|
||||
if [[ $PLATFORM != *Windows ]] && [ $PLATFORM != "Darwin" ]; then
|
||||
FLAGS+="-lrt "
|
||||
fi
|
||||
|
||||
function compile_wrapper()
|
||||
{
|
||||
mkdir -p ../target ../target/bin
|
||||
|
||||
verbose_cmd $CXX compiler.cpp -std=c++0x -pedantic -Wall -Wextra \
|
||||
"-DOSXCROSS_TARGET=\"\\\"$TARGET\\\"\"" \
|
||||
"-DOSXCROSS_OSX_VERSION_MIN=\"\\\"$OSX_VERSION_MIN\\\"\"" \
|
||||
"-DOSXCROSS_LINKER_VERSION=\"\\\"$LINKER_VERSION\\\"\"" \
|
||||
-o "../target/bin/${TARGETTRIPLE}-wrapper${EXESUFFIX}" -O2 \
|
||||
$FLAGS $*
|
||||
}
|
||||
|
||||
compile_wrapper
|
||||
|
||||
pushd "../target/bin" &>/dev/null
|
||||
|
||||
if [ $TARGETCOMPILER = "clang" ]; then
|
||||
create_wrapper_link o32-clang
|
||||
create_wrapper_link o32-clang++
|
||||
create_wrapper_link o32-clang++-libc++
|
||||
|
||||
create_wrapper_link o64-clang
|
||||
create_wrapper_link o64-clang++
|
||||
create_wrapper_link o64-clang++-libc++
|
||||
|
||||
create_wrapper_link i386-apple-$TARGET-clang
|
||||
create_wrapper_link i386-apple-$TARGET-clang++
|
||||
create_wrapper_link i386-apple-$TARGET-clang++-libc++
|
||||
|
||||
create_wrapper_link x86_64-apple-$TARGET-clang
|
||||
create_wrapper_link x86_64-apple-$TARGET-clang++
|
||||
create_wrapper_link x86_64-apple-$TARGET-clang++-libc++
|
||||
elif [ $TARGETCOMPILER = "gcc" ]; then
|
||||
create_wrapper_link o32-gcc
|
||||
create_wrapper_link o32-g++
|
||||
create_wrapper_link o32-g++-libc++
|
||||
|
||||
create_wrapper_link o64-gcc
|
||||
create_wrapper_link o64-g++
|
||||
create_wrapper_link o64-g++-libc++
|
||||
|
||||
create_wrapper_link i386-apple-$TARGET-gcc
|
||||
create_wrapper_link i386-apple-$TARGET-g++
|
||||
create_wrapper_link i386-apple-$TARGET-g++-libc++
|
||||
|
||||
create_wrapper_link x86_64-apple-$TARGET-gcc
|
||||
create_wrapper_link x86_64-apple-$TARGET-g++
|
||||
create_wrapper_link x86_64-apple-$TARGET-g++-libc++
|
||||
fi
|
||||
|
||||
create_wrapper_link i386-apple-$TARGET-cc
|
||||
create_wrapper_link i386-apple-$TARGET-c++
|
||||
|
||||
create_wrapper_link x86_64-apple-$TARGET-cc
|
||||
create_wrapper_link x86_64-apple-$TARGET-c++
|
||||
|
||||
create_wrapper_link osxcross-conf
|
||||
create_wrapper_link osxcross-env
|
||||
|
||||
create_wrapper_link sw_vers
|
||||
create_wrapper_link i386-apple-$TARGET-sw_vers
|
||||
create_wrapper_link x86_64-apple-$TARGET-sw_vers
|
||||
|
||||
create_wrapper_link dsymutil
|
||||
create_wrapper_link i386-apple-$TARGET-dsymutil
|
||||
create_wrapper_link x86_64-apple-$TARGET-dsymutil
|
||||
|
||||
popd &>/dev/null
|
||||
popd &>/dev/null
|
15
wrapper/compat.h
Normal file
15
wrapper/compat.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifdef __clang__
|
||||
#if __has_include(<__config>)
|
||||
#include <__config>
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CONFIG
|
||||
// NetBSD's libstdc++ 4.5.3
|
||||
// requires this
|
||||
#undef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __has_builtin
|
||||
#define __has_builtin(x) 0
|
||||
#endif
|
1807
wrapper/compiler.cpp
Normal file
1807
wrapper/compiler.cpp
Normal file
File diff suppressed because it is too large
Load Diff
14
wrapper/oscompat.h
Normal file
14
wrapper/oscompat.h
Normal file
@ -0,0 +1,14 @@
|
||||
namespace {
|
||||
#ifdef _WIN32
|
||||
int setenv(const char *name, const char *value, int overwrite) {
|
||||
std::string buf;
|
||||
(void)overwrite; // TODO
|
||||
|
||||
buf = name;
|
||||
buf += '=';
|
||||
buf += value;
|
||||
|
||||
return putenv(buf.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user