darwin-specific stuff

This commit is contained in:
Eric Seidel 2015-02-03 14:06:13 -08:00
parent 92188d9d17
commit ebb8d03f96
10 changed files with 382 additions and 113 deletions

View File

@ -0,0 +1,35 @@
{ stdenv, fetchurl }:
stdenv.mkDerivation rec {
name = "ps-${version}";
version = "153";
src = fetchurl {
url = "http://opensource.apple.com/tarballs/adv_cmds/adv_cmds-${version}.tar.gz";
sha256 = "174v6a4zkcm2pafzgdm6kvs48z5f911zl7k49hv7kjq6gm58w99v";
};
buildPhase = ''
cd ps
cc -Os -Wall -I. -c -o fmt.o fmt.c
cc -Os -Wall -I. -c -o keyword.o keyword.c
cc -Os -Wall -I. -c -o nlist.o nlist.c
cc -Os -Wall -I. -c -o print.o print.c
cc -Os -Wall -I. -c -o ps.o ps.c
cc -Os -Wall -I. -c -o tasks.o tasks.c
cc -o ps fmt.o keyword.o nlist.o print.o ps.o tasks.o
'';
installPhase = ''
mkdir -p $out/bin $out/share/man/man1
cp ps $out/bin/ps
cp ps.1 $out/share/man/man1
'';
meta = {
platforms = stdenv.lib.platforms.darwin;
maintainers = with stdenv.lib.maintainers; [ gridaphobe ];
};
}

View File

@ -0,0 +1,46 @@
{ stdenv, fetchurl, flex, yacc }:
stdenv.mkDerivation rec {
version = "86";
name = "bootstrap_cmds-${version}";
src = fetchurl {
url = "http://www.opensource.apple.com/tarballs/bootstrap_cmds/${name}.tar.gz";
sha256 = "0xr0296jm1r3q7kbam98h85g23qlfi763z54ahj563n636kyk2wb";
};
buildInputs = [ flex yacc ];
buildPhase = ''
cd migcom.tproj
yacc -d parser.y
flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o error.o error.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o global.o global.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o handler.o header.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o header.o header.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o mig.o mig.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o routine.o routine.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o server.o server.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o statement.o statement.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o string.o string.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o type.o type.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o user.o user.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o utils.o utils.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o lexxer.yy.o lexxer.yy.c
cc -Os -pipe -DMIG_VERSION="" -Wall -mdynamic-no-pic -I. -c -o y.tab.o y.tab.c
cc -dead_strip -o migcom error.o global.o header.o mig.o routine.o server.o statement.o string.o type.o user.o utils.o lexxer.yy.o y.tab.o
'';
installPhase = ''
mkdir -p $out/bin $out/libexec $out/share/man/man1
chmod +x mig.sh
cp mig.sh $out/bin/mig
cp migcom $out/libexec
cp mig.1 $out/share/man/man1
cp migcom.1 $out/share/man/man1
'';
}

View File

@ -1,64 +0,0 @@
{ stdenv, cross, fetchurl, autoconf, automake, libtool
, libcxx, llvm, clang, openssl, libuuid
, maloader, makeWrapper, xctoolchain
}:
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 makeWrapper
];
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}"
];
postInstall = ''
for tool in dyldinfo dwarfdump dsymutil; do
makeWrapper "${maloader}/bin/ld-mac" "$out/bin/${cross.config}-$tool" \
--add-flags "${xctoolchain}/bin/$tool"
ln -s "$out/bin/${cross.config}-$tool" "$out/bin/$tool"
done
'';
meta = {
homepage = "http://www.opensource.apple.com/source/cctools/";
description = "Mac OS X Compiler Tools (cross-platform port)";
license = stdenv.lib.licenses.apsl20;
};
}

View File

@ -0,0 +1,122 @@
From b6001ddb935351b4d150546ddab6d25eae05afaa Mon Sep 17 00:00:00 2001
From: Daniel Peebles <pumpkin@me.com>
Date: Sun, 12 Oct 2014 12:23:51 -0400
Subject: [PATCH] work
---
cctools/Makefile.am | 2 +-
cctools/configure.ac | 2 --
cctools/ld64/src/3rd/helper.c | 2 ++
cctools/ld64/src/3rd/strlcat.c | 2 ++
cctools/ld64/src/3rd/strlcpy.c | 3 ++-
cctools/ld64/src/ld/Options.cpp | 2 ++
tools/find_lto_header.sh | 2 +-
7 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/cctools/Makefile.am b/cctools/Makefile.am
index 44084ad..34a670c 100644
--- a/cctools/Makefile.am
+++ b/cctools/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS=libstuff ar as misc libobjc2 otool ld64 $(LD_CLASSIC)
+SUBDIRS=libstuff ar as misc ld64 $(LD_CLASSIC)
ACLOCAL_AMFLAGS = -I m4
diff --git a/cctools/configure.ac b/cctools/configure.ac
index c4f6c47..b641925 100644
--- a/cctools/configure.ac
+++ b/cctools/configure.ac
@@ -278,8 +278,6 @@ AC_CONFIG_FILES([as/ppc/Makefile])
AC_CONFIG_FILES([as/ppc64/Makefile])
#AC_CONFIG_FILES([man/Makefile])
AC_CONFIG_FILES([misc/Makefile])
-AC_CONFIG_FILES([otool/Makefile])
-AC_CONFIG_FILES([libobjc2/Makefile])
AC_CONFIG_FILES([ld/Makefile])
diff --git a/cctools/ld64/src/3rd/helper.c b/cctools/ld64/src/3rd/helper.c
index 19f4be7..bec6869 100644
--- a/cctools/ld64/src/3rd/helper.c
+++ b/cctools/ld64/src/3rd/helper.c
@@ -23,6 +23,7 @@
const char ldVersionString[] = "236.3\n";
+#if 0
void __assert_rtn(const char *func, const char *file, int line, const char *msg)
{
#ifdef __FreeBSD__
@@ -33,6 +34,7 @@ void __assert_rtn(const char *func, const char *file, int line, const char *msg)
__assert(msg, file, line);
#endif /* __FreeBSD__ */
}
+#endif
int _NSGetExecutablePath(char *path, unsigned int *size)
{
diff --git a/cctools/ld64/src/3rd/strlcat.c b/cctools/ld64/src/3rd/strlcat.c
index 500d038..dadf269 100644
--- a/cctools/ld64/src/3rd/strlcat.c
+++ b/cctools/ld64/src/3rd/strlcat.c
@@ -23,6 +23,7 @@
#include <string.h>
+#if 0
size_t
strlcat(char * restrict dst, const char * restrict src, size_t maxlen) {
const size_t srclen = strlen(src);
@@ -36,3 +37,4 @@ strlcat(char * restrict dst, const char * restrict src, size_t maxlen) {
}
return dstlen + srclen;
}
+#endif
\ No newline at end of file
diff --git a/cctools/ld64/src/3rd/strlcpy.c b/cctools/ld64/src/3rd/strlcpy.c
index c69f107..34a399b 100644
--- a/cctools/ld64/src/3rd/strlcpy.c
+++ b/cctools/ld64/src/3rd/strlcpy.c
@@ -23,6 +23,7 @@
#include <string.h>
+#if 0
size_t
strlcpy(char * restrict dst, const char * restrict src, size_t maxlen) {
const size_t srclen = strlen(src);
@@ -34,4 +35,4 @@ strlcpy(char * restrict dst, const char * restrict src, size_t maxlen) {
}
return srclen;
}
-
+#endif
\ No newline at end of file
diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp
index 3a78df8..0ecf9f2 100644
--- a/cctools/ld64/src/ld/Options.cpp
+++ b/cctools/ld64/src/ld/Options.cpp
@@ -49,6 +49,8 @@ namespace lto {
extern const char* version();
}
+#define __MAC_OS_X_VERSION_MIN_REQUIRED 1060
+
// magic to place command line in crash reports
const int crashreporterBufferSize = 2000;
static char crashreporterBuffer[crashreporterBufferSize];
diff --git a/tools/find_lto_header.sh b/tools/find_lto_header.sh
index aee3a4a..4733981 100755
--- a/tools/find_lto_header.sh
+++ b/tools/find_lto_header.sh
@@ -14,7 +14,7 @@ function try()
# Adding the include directory with -I causes the build to fail.
ln -sf "$LLVM_INC_DIR/llvm-c/lto.h" "include/llvm-c/lto.h"
mkdir -p tmp
- echo -n "-Wl,-rpath,$LLVM_LIB_DIR,--enable-new-dtags -L$LLVM_LIB_DIR -lLTO " > tmp/ldflags
+ echo -n "-Wl,-rpath,$LLVM_LIB_DIR -L$LLVM_LIB_DIR -lLTO " > tmp/ldflags
echo -n "-DLTO_SUPPORT=1 " > tmp/cflags
echo -n "-DLTO_SUPPORT=1 " > tmp/cxxflags
echo -n "$LLVM_LIB_DIR" > tmp/ldpath
--
1.9.3 (Apple Git-50)

View File

@ -0,0 +1,80 @@
{ stdenv, fetchurl, autoconf, automake, libtool
, llvm, libcxx, clang, openssl, libuuid
}:
let
baseParams = rec {
name = "cctools-port-${version}";
version = "855";
src = let
# Should be fetchFromGitHub but it was whining so this will do for now
owner = "tpoechtrager";
repo = "cctools-port";
rev = "7083dddbb0f106d791d313829ea7dc45db90e375";
in fetchurl {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = "017gxlcwgi7xhayjzj9w3fac175p2rm4vjzf9cycq9683m9pmyzj";
};
buildInputs = [
autoconf automake libtool llvm clang openssl libuuid libcxx
];
patches = [ ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch ];
enableParallelBuilding = true;
postPatch = ''
patchShebangs tools
sed -i -e 's/which/type -P/' tools/*.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
'';
meta = {
homepage = "http://www.opensource.apple.com/source/cctools/";
description = "Mac OS X Compiler Tools (cross-platform port)";
license = stdenv.lib.licenses.apsl20;
};
};
in {
# Hacks that for the darwin stdenv (sad that we need write workarounds for what started as a darwin package)
native = stdenv.mkDerivation (baseParams // {
patches = baseParams.patches ++ [ ./darwin.patch ];
postInstall = ''
cd $out/bin
for tool in dwarfdump dsymutil; do
ln -s /usr/bin/$tool
done
'';
});
cross =
{ cross, maloader, makeWrapper, xctoolchain}: stdenv.mkDerivation (baseParams // {
configureFlags = baseParams.configureFlags ++ [ "--target=${cross.config}" ];
postInstall = ''
for tool in dyldinfo dwarfdump dsymutil; do
${makeWrapper}/bin/makeWrapper "${maloader}/bin/ld-mac" "$out/bin/${cross.config}-$tool" \
--add-flags "${xctoolchain}/bin/$tool"
ln -s "$out/bin/${cross.config}-$tool" "$out/bin/$tool"
done
'';
});
}

View File

@ -1,71 +1,43 @@
{ stdenv, fetchadc, xar, gzip, cpio }:
{ stdenv, fetchurl, xar, gzip, cpio }:
let
name = "command-line-tools-mac-os-10.9";
pkg = { installPhase }: stdenv.mkDerivation {
name = "${name}.pkg";
phases = [ "installPhase" ];
inherit installPhase;
meta = with stdenv.lib; {
description = "Developer tools .pkg file";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.unfree;
};
};
basic = pkg: stdenv.mkDerivation {
pkg = { name, sha256 }: stdenv.mkDerivation {
inherit name;
src = fetchurl {
url = "http://swcdn.apple.com/content/downloads/00/14/031-07556/i7hoqm3awowxdy48l34uel4qvwhdq8lgam/${name}.pkg";
inherit sha256;
};
buildInputs = [ xar gzip cpio ];
phases = [ "unpackPhase" "installPhase" ];
outputs = [ "sdk" "tools" ];
unpackPhase = ''
${xar}/bin/xar -x -f "${pkg}"
xar -x -f $src
'';
installPhase = ''
start="$(pwd)"
mkdir -p $sdk
mkdir -p $tools
cd $sdk
cat $start/DevSDK_OSX109.pkg/Payload | ${gzip}/bin/gzip -d | ${cpio}/bin/cpio -idm
cd $tools
cat $start/CLTools_Executables.pkg/Payload | ${gzip}/bin/gzip -d | ${cpio}/bin/cpio -idm
mkdir -p $out
cd $out
cat $start/Payload | gzip -d | cpio -idm
'';
meta = with stdenv.lib; {
description = "Mac OS command-line developer tools and SDK";
description = "Apple developer tools ${name}";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.unfree;
};
};
in rec {
dmg = fetchadc {
# Isn't this a beautiful path? Note the subtle differences before and after the slash!
path = "Developer_Tools/command_line_tools_os_x_10.9_for_xcode__xcode_6/command_line_tools_for_os_x_10.9_for_xcode_6.dmg";
sha256 = "0zrpf73r3kfk9pdh6p6j6w1sbw7s2pp0f8rd83660r5hk1y3j5jc";
tools = pkg {
name = "CLTools_Executables";
sha256 = "1rqrgip9pwr9d6p1hkd027lzxpymr1qm54jjnkldjjb8m4nps7bp";
};
pure = { xpwn }: basic (pkg {
installPhase = ''
${xpwn}/bin/hdutil ${dmg} extract "Command Line Tools (OS X 10.9).pkg" $out
'';
});
impure = basic (pkg {
installPhase = ''
/usr/bin/hdiutil attach ${dmg} -mountpoint clt-mount -nobrowse
cp "clt-mount/Command Line Tools (OS X 10.9).pkg" $out
/usr/bin/hdiutil unmount clt-mount
'';
});
sdk = pkg {
name = "DevSDK_OSX109";
sha256 = "0x6r61h78r5cxk9dbw6fnjpn6ydi4kcajvllpczx3mi52crlkm4x";
};
}

View File

@ -0,0 +1,40 @@
{ stdenv, fetchurl, fetchgit, fetchzip, perl, python }:
let
osx_sdk = fetchgit {
url = "https://github.com/samdmarshall/OSXPrivateSDK";
rev = "refs/heads/master";
sha256 = "04m71xhjyac42h7alxjsqsipq07hm85wibvm3h65dqafcbqkl1i1";
};
dispatch = fetchzip {
url = "https://opensource.apple.com/tarballs/libdispatch/libdispatch-339.92.1.tar.gz";
sha256 = "0faxm4r7lamz57m9pr72jwm0qiwcrcy5dsiff0g9qyfi10pnj5i4";
};
in
stdenv.mkDerivation rec {
version = "825.40.1";
name = "libc-${version}";
src = fetchurl {
url = "https://opensource.apple.com/tarballs/Libc/Libc-${version}.tar.gz";
sha256 = "0xsx1im52gwlmcrv4lnhhhn9dyk5ci6g27k6yvibn9vj8fzjxwcf";
};
buildInputs = [ perl ];
patches = [ ./fileport.patch ];
configurePhase = ''
mkdir -p scratch
mkdir -p scratch/System/sys
ln -sv ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders/sys/fsctl.h scratch/System/sys
mkdir tmpbin
ln -s /usr/bin/xcodebuild tmpbin
ln -s /usr/sbin/dtrace tmpbin
export PATH=$PATH:$(pwd -P)/tmpbin
'';
buildPhase = ''
BASE=$(pwd -P)
xcodebuild HEADER_SEARCH_PATHS="$BASE/fbsdcompat $BASE/pthreads $BASE/include $BASE/locale $BASE/locale/FreeBSD ${osx_sdk}/usr/local/include ${osx_sdk}/usr/include $BASE/stdtime/FreeBSD $BASE/gen ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders $BASE/scratch ${osx_sdk}/System/Library/Frameworks/System.framework/PrivateHeaders/uuid $BASE/gdtoa"
'';
}

View File

@ -0,0 +1,38 @@
diff --git a/Platforms/macosx/Makefile.inc b/Platforms/macosx/Makefile.inc
index ff3617f..fdda58f 100644
--- a/Platforms/macosx/Makefile.inc
+++ b/Platforms/macosx/Makefile.inc
@@ -41,7 +41,7 @@ FEATURE_PATCH_3417676 = 1
FEATURE_PATCH_5243343 = 1
# plockstat dtrace support
-FEATURE_PLOCKSTAT = 1
+FEATURE_PLOCKSTAT = 0
# Timezone change notification
FEATURE_TIMEZONE_CHANGE_NOTIFICATION = 1
diff --git a/gen/asl.c b/gen/asl.c
index 1948c92..53fce02 100644
--- a/gen/asl.c
+++ b/gen/asl.c
@@ -35,6 +35,7 @@
#include <time.h>
#include <sys/time.h>
#include <sys/fcntl.h>
+#include <sys/fileport.h>
#include <crt_externs.h>
#include <asl.h>
#include <regex.h>
diff --git a/locale/FreeBSD/toupper.c b/locale/FreeBSD/toupper.c
index d02ddd6..e5a1f10 100644
--- a/locale/FreeBSD/toupper.c
+++ b/locale/FreeBSD/toupper.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/toupper.c,v 1.13 2007/01/09 00:28:01 imp
#include <stdio.h>
#include <runetype.h>
+#define __ct_rune_t ct_rune_t
+
__ct_rune_t
___toupper_l(c, loc)
__ct_rune_t c;