Add a cross-platform port of cctools.
This basically is binutils for Mac OS X, but ported to work on (GNU/)Linux and FreeBSD. And it's up-to-date as well! I'm mentioning this, because it was quite hard to find a recent port of it and I just accidentally stumbled on it while trying to do the port by myself. So thanks to @tpoechtrager for doing this. Also, I've added two more patches, which essentially are: * ld-rpath-nonfinal: This allows -rpath to be used for linking non-final builds, which was allowed for earlier versions of cctools and got a check for that in more recent versions. * ld-ignore-rpath-link: Ignores the -rpath-link option, because the cross-wrapper uses it in different places. Unfortunately, the cctools linker doesn't support it, so we might need to implement this later if it's possible (I'm not a Mach-O man^H^H^Hexpert). Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
83dd414ca2
commit
dd10bb3181
55
pkgs/os-specific/darwin/cctools-port/default.nix
Normal file
55
pkgs/os-specific/darwin/cctools-port/default.nix
Normal file
@ -0,0 +1,55 @@
|
||||
{ stdenv, cross, fetchurl, autoconf, automake, libtool
|
||||
, libcxx, llvm, clang, openssl, libuuid
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "cctools-port-${version}";
|
||||
version = "845";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/tpoechtrager/cctools-port/archive/"
|
||||
+ "cctools-${version}-ld64-136-1.tar.gz";
|
||||
sha256 = "06pg6h1g8avgx4j6cfykdpggf490li796gzhhyqn27jsagli307i";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
autoconf automake libtool libcxx llvm clang openssl libuuid
|
||||
];
|
||||
|
||||
patches = [ ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs tools
|
||||
sed -i -e 's/which/type -P/' tools/*.sh
|
||||
sed -i -e 's|clang++|& -I${libcxx}/include/c++/v1|' cctools/autogen.sh
|
||||
|
||||
# Workaround for https://www.sourceware.org/bugzilla/show_bug.cgi?id=11157
|
||||
cat > cctools/include/unistd.h <<EOF
|
||||
#ifdef __block
|
||||
# undef __block
|
||||
# include_next "unistd.h"
|
||||
# define __block __attribute__((__blocks__(byref)))
|
||||
#else
|
||||
# include_next "unistd.h"
|
||||
#endif
|
||||
EOF
|
||||
'';
|
||||
|
||||
preConfigure = ''
|
||||
cd cctools
|
||||
sh autogen.sh
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"CXXFLAGS=-I${libcxx}/include/c++/v1"
|
||||
"--target=${cross.config}"
|
||||
];
|
||||
|
||||
meta = {
|
||||
homepage = "http://www.opensource.apple.com/source/cctools/";
|
||||
description = "Mac OS X Compiler Tools (cross-platform port)";
|
||||
license = stdenv.lib.licenses.apsl20;
|
||||
};
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp
|
||||
index 2565518..9250016 100644
|
||||
--- a/cctools/ld64/src/ld/Options.cpp
|
||||
+++ b/cctools/ld64/src/ld/Options.cpp
|
||||
@@ -2522,6 +2522,11 @@ void Options::parse(int argc, const char* argv[])
|
||||
throw "missing argument to -rpath";
|
||||
fRPaths.push_back(path);
|
||||
}
|
||||
+ else if ( strcmp(arg, "-rpath-link") == 0 ) {
|
||||
+ const char* path = argv[++i];
|
||||
+ if ( path == NULL )
|
||||
+ throw "missing argument to -rpath-link";
|
||||
+ }
|
||||
else if ( strcmp(arg, "-read_only_stubs") == 0 ) {
|
||||
fReadOnlyx86Stubs = true;
|
||||
}
|
31
pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch
Normal file
31
pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch
Normal file
@ -0,0 +1,31 @@
|
||||
diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp
|
||||
index 9250016..91d54ec 100644
|
||||
--- a/cctools/ld64/src/ld/Options.cpp
|
||||
+++ b/cctools/ld64/src/ld/Options.cpp
|
||||
@@ -4175,23 +4175,9 @@ void Options::checkIllegalOptionCombinations()
|
||||
throw "-r and -dead_strip cannot be used together";
|
||||
|
||||
// can't use -rpath unless targeting 10.5 or later
|
||||
- if ( fRPaths.size() > 0 ) {
|
||||
- if ( !minOS(ld::mac10_5, ld::iOS_2_0) )
|
||||
- throw "-rpath can only be used when targeting Mac OS X 10.5 or later";
|
||||
- switch ( fOutputKind ) {
|
||||
- case Options::kDynamicExecutable:
|
||||
- case Options::kDynamicLibrary:
|
||||
- case Options::kDynamicBundle:
|
||||
- break;
|
||||
- case Options::kStaticExecutable:
|
||||
- case Options::kObjectFile:
|
||||
- case Options::kDyld:
|
||||
- case Options::kPreload:
|
||||
- case Options::kKextBundle:
|
||||
- throw "-rpath can only be used when creating a dynamic final linked image";
|
||||
- }
|
||||
- }
|
||||
-
|
||||
+ if ( fRPaths.size() > 0 && !minOS(ld::mac10_5, ld::iOS_2_0) )
|
||||
+ throw "-rpath can only be used when targeting Mac OS X 10.5 or later";
|
||||
+
|
||||
if ( fPositionIndependentExecutable ) {
|
||||
switch ( fOutputKind ) {
|
||||
case Options::kDynamicExecutable:
|
@ -6546,7 +6546,13 @@ let
|
||||
|
||||
cramfsswap = callPackage ../os-specific/linux/cramfsswap { };
|
||||
|
||||
darwin.xcode = callPackage ../os-specific/darwin/xcode { };
|
||||
darwin = {
|
||||
cctools = forceNativeDrv (callPackage ../os-specific/darwin/cctools-port {
|
||||
cross = assert crossSystem != null; crossSystem;
|
||||
});
|
||||
|
||||
xcode = callPackage ../os-specific/darwin/xcode {};
|
||||
};
|
||||
|
||||
devicemapper = lvm2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user