From f9515fe9e55694e2dbca2673f7c03b4c03273cb8 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Wed, 18 Jan 2017 10:47:13 +0100 Subject: [PATCH 1/3] Add descriptive header to build scripts. --- build.sh | 6 ++++++ build_binutils.sh | 7 +++++++ build_clang.sh | 7 +++++++ build_compiler_rt.sh | 6 ++++++ build_gcc.sh | 7 +++++++ build_llvm_dsymutil.sh | 5 +++++ 6 files changed, 38 insertions(+) diff --git a/build.sh b/build.sh index aed3f28..f5df280 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +# +# Build and install the cctools the SDK and macports. +# +# This script requires the OS X SDK and the Clang/LLVM compiler. +# + pushd "${0%/*}" &>/dev/null diff --git a/build_binutils.sh b/build_binutils.sh index e3c1756..1a259fa 100755 --- a/build_binutils.sh +++ b/build_binutils.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash +# +# Build and install the GNU binutils and the GNU Debugger (gdb) for +# target OS X. +# +# You may want to run this script if you want to build software using +# gcc. Please refer to the README.md for details. +# pushd "${0%/*}" &>/dev/null diff --git a/build_clang.sh b/build_clang.sh index 6713b59..585fc96 100755 --- a/build_clang.sh +++ b/build_clang.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash +# +# Build and install Clang/LLVM, using `gcc`. +# +# You only need to run this if your distribution does not provide +# clang - or if you want to build your own version from a recent +# source tree. +# pushd "${0%/*}" &>/dev/null diff --git a/build_compiler_rt.sh b/build_compiler_rt.sh index d3d3fde..5f70668 100755 --- a/build_compiler_rt.sh +++ b/build_compiler_rt.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +# +# Build and install the "compiler-rt" runtime library. +# +# This requires that you already finished `build.sh`. +# Please refer to README.COMPILER-RT.md for details. +# pushd "${0%/*}" &>/dev/null diff --git a/build_gcc.sh b/build_gcc.sh index afa5202..3af5352 100755 --- a/build_gcc.sh +++ b/build_gcc.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash +# +# Build and install gcc/gcc++ as a cross-compiler with target OSX, +# using `clang`. +# +# You may want to run this script if you want to build software using +# gcc. Please refer to the README.md for details. +# pushd "${0%/*}" &>/dev/null diff --git a/build_llvm_dsymutil.sh b/build_llvm_dsymutil.sh index 3fd6738..af677f7 100755 --- a/build_llvm_dsymutil.sh +++ b/build_llvm_dsymutil.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash +# +# Build and install the `llvm-dsymutil` tool required for debugging. +# +# Please refer to README.DEBUGGING.md for details. +# pushd "${0%/*}" &>/dev/null From f9ebecaa1da2d9e55b4251ecbd45b2c08b37e1f1 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Wed, 18 Jan 2017 11:02:52 +0100 Subject: [PATCH 2/3] Add descriptive header to tool scripts. --- tools/gen_cyglto_dll.sh | 4 ++++ tools/gen_sdk_package.sh | 4 +++- tools/gen_sdk_package_darling_dmg.sh | 9 +++++++++ tools/gen_sdk_package_p7zip.sh | 8 ++++++++ tools/mount_xcode_image.sh | 5 +++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/gen_cyglto_dll.sh b/tools/gen_cyglto_dll.sh index 0633d1c..a855d46 100755 --- a/tools/gen_cyglto_dll.sh +++ b/tools/gen_cyglto_dll.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +# +# Build and install the LTO library, which the Cygwin package of +# libLLVM is lacking. +# pushd "${0%/*}/.." &>/dev/null source tools/tools.sh diff --git a/tools/gen_sdk_package.sh b/tools/gen_sdk_package.sh index c19abda..2f9d708 100755 --- a/tools/gen_sdk_package.sh +++ b/tools/gen_sdk_package.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash -# OS X SDK packaging script +# +# Package the OS X SDKs into a tar file to be used by `build.sh`. +# export LC_ALL=C diff --git a/tools/gen_sdk_package_darling_dmg.sh b/tools/gen_sdk_package_darling_dmg.sh index 0de5756..5004a66 100755 --- a/tools/gen_sdk_package_darling_dmg.sh +++ b/tools/gen_sdk_package_darling_dmg.sh @@ -1,4 +1,13 @@ #!/usr/bin/env bash +# +# Mount a Xcode .dmg (using fuse) and run gen_sdk_package.sh. +# +# Works up to Xcode 7.3 +# +# This script uses darling-dmg and fuse to mount the .dmg, thus +# avoiding to actually unpack it. +# darling-dmg will be downloaded and compiled if missing. +# pushd "${0%/*}/.." &>/dev/null source tools/tools.sh diff --git a/tools/gen_sdk_package_p7zip.sh b/tools/gen_sdk_package_p7zip.sh index 1f50167..9121222 100755 --- a/tools/gen_sdk_package_p7zip.sh +++ b/tools/gen_sdk_package_p7zip.sh @@ -1,4 +1,12 @@ #!/usr/bin/env bash +# +# Extract required files from a Xcode .dmg using p7zip and run +# gen_sdk_package.sh. +# +# Works up to Xcode 7.2 +# +# p7zip will be downloaded and compiled if missing. +# pushd "${0%/*}/.." &>/dev/null source tools/tools.sh diff --git a/tools/mount_xcode_image.sh b/tools/mount_xcode_image.sh index d234bad..30e2a7e 100755 --- a/tools/mount_xcode_image.sh +++ b/tools/mount_xcode_image.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash +# +# Mount a Xcode .dmg (requires root) and run gen_sdk_package.sh. +# +# Works up to Xcode 4.2 +# if [ $(uname -s) != "Linux" ]; then echo "This script must be run on Linux" From 0c4f91001b0b06c36d560062c9779fab4fcbc292 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Wed, 18 Jan 2017 11:08:35 +0100 Subject: [PATCH 3/3] Update README.md. --- README.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8c67c23..b8c1140 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,26 @@ Linux, *BSD, and Cygwin. ### 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, -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. +For cross-compiling for OS X you need +* the Clang/LLVM compiler +* the the [cctools](http://www.opensource.apple.com/tarballs/cctools) + (ld, lipo, …), and +* the OSX SDK. + +[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 and the OS X SDK. + +OSXCross includes a collection of scripts for preparing the SDK and +building the cctools. + +It also includes scripts for optionally building +* Clang using gcc (for the case your distribution does not include it), +* an up-to-date vanilla GCC as a cross-compiler for target OS X, +* the "compiler-rt" runtime library, and +* the `llvm-dsymutil` tool required for debugging. -If you want, then you can build an up-to-date vanilla GCC as well. ### WHAT CAN I BUILD WITH IT? ### @@ -38,17 +50,18 @@ Then ensure you have the following installed on your system: `Clang 3.2+`, `patch`, `libxml2-devel` (<=10.6 only) and the `bash shell`. +You can run 'sudo tools/get\_dependencies.sh' to get these (and the +optional packages) automatically. + *Optional:* -`llvm-devel`: For Link Time Optimization support -`uuid-devel`: For ld64 `-random_uuid` support -`llvm-devel` + `xar-devel`: For ld64 `-bitcode_bundle` support +- `llvm-devel`: For Link Time Optimization support +- `uuid-devel`: For ld64 `-random_uuid` support +- `llvm-devel` + `xar-devel`: For ld64 `-bitcode_bundle` support You can find xar [here](https://github.com/mackyle/xar). Do not install libxar-dev on Ubuntu, it's a different package. -\-- -You can run 'sudo tools/get\_dependencies.sh' to get these automatically. ##### Building Clang #####