nixpkgs/pkgs/os-specific/darwin/cctools/port.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

193 lines
5.7 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook, memstreamHook
, installShellFiles
2020-11-19 08:39:27 +01:00
, libuuid
, libobjc ? null, maloader ? null
, enableTapiSupport ? true, libtapi
, fetchpatch
2015-02-03 23:06:13 +01:00
}:
let
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
2021-01-15 15:45:37 +01:00
targetPrefix = lib.optionalString
(stdenv.targetPlatform != stdenv.hostPlatform)
"${stdenv.targetPlatform.config}-";
in
# Non-Darwin alternatives
assert (!stdenv.hostPlatform.isDarwin) -> maloader != null;
stdenv.mkDerivation {
pname = "${targetPrefix}cctools-port";
2022-08-06 11:49:27 +02:00
version = "973.0.1";
src = fetchFromGitHub {
owner = "tpoechtrager";
repo = "cctools-port";
2022-08-06 11:49:27 +02:00
# This is the commit before: https://github.com/tpoechtrager/cctools-port/pull/114
# That specific change causes trouble for us (see the PR discussion), but
# is also currently the last commit on master at the time of writing, so we
# can just go back one step.
rev = "457dc6ddf5244ebf94f28e924e3a971f1566bd66";
sha256 = "0ns12q7vg9yand4dmdsps1917cavfbw67yl5q7bm6kb4ia5kkx13";
};
outputs = [ "out" "dev" "man" ];
nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]
++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ memstreamHook ];
buildInputs = [ libuuid ]
2020-11-19 08:39:27 +01:00
++ lib.optionals stdenv.isDarwin [ libobjc ]
2021-01-15 15:45:37 +01:00
++ lib.optional enableTapiSupport libtapi;
2022-08-06 11:49:27 +02:00
patches = [
./ld-ignore-rpath-link.patch
./ld-rpath-nonfinal.patch
(fetchpatch {
url = "https://github.com/tpoechtrager/cctools-port/commit/4a734070cd2838e49658464003de5b92271d8b9e.patch";
hash = "sha256-72KaJyu7CHXxJJ1GNq/fz+kW1RslO3UaKI91LhBtiXA=";
})
(fetchpatch {
url = "https://github.com/MercuryTechnologies/cctools-port/commit/025899b7b3593dedb0c681e689e57c0e7bbd9b80.patch";
hash = "sha256-SWVUzFaJHH2fu9y8RcU3Nx/QKx60hPE5zFx0odYDeQs=";
})
# Always use `open_memstream`. This is provided by memstream via hook on x86_64-darwin.
./darwin-memstream.patch
];
__propagatedImpureHostDeps = [
# As far as I can tell, otool from cctools is the only thing that depends on these two, and we should fix them
"/usr/lib/libobjc.A.dylib"
"/usr/lib/libobjc.dylib"
];
enableParallelBuilding = true;
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
configurePlatforms = [ "build" "host" ]
2021-01-15 15:45:37 +01:00
++ lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
configureFlags = [ "--disable-clang-as" ]
2021-01-15 15:45:37 +01:00
++ lib.optionals enableTapiSupport [
"--enable-tapi-support"
"--with-libtapi=${libtapi}"
];
2021-01-15 15:45:37 +01:00
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace cctools/Makefile.am --replace libobjc2 ""
'' + ''
sed -i -e 's/addStandardLibraryDirectories = true/addStandardLibraryDirectories = false/' cctools/ld64/src/ld/Options.cpp
# FIXME: there are far more absolute path references that I don't want to fix right now
substituteInPlace cctools/configure.ac \
--replace "-isystem /usr/local/include -isystem /usr/pkg/include" "" \
--replace "-L/usr/local/lib" "" \
2022-08-06 11:49:27 +02:00
# Appears to use new libdispatch API not available in macOS SDK 10.12.
substituteInPlace cctools/ld64/src/ld/libcodedirectory.c \
--replace "#define LIBCD_PARALLEL 1" ""
patchShebangs tools
sed -i -e 's/which/type -P/' tools/*.sh
cd cctools
'';
preInstall = ''
2022-08-06 11:49:27 +02:00
installManPage ar/ar.{1,5}
# The makefile rules for installing headers are missing in 973.0.1.
# The below is derived from 949.0.1.
mkdir -p $dev/include/mach-o/i386
mkdir -p $dev/include/mach-o/ppc
mkdir -p $dev/include/mach-o/x86_64
mkdir -p $dev/include/mach-o/arm
mkdir -p $dev/include/mach-o/arm64
mkdir -p $dev/include/mach-o/m68k
mkdir -p $dev/include/mach-o/sparc
mkdir -p $dev/include/mach-o/hppa
mkdir -p $dev/include/mach-o/i860
mkdir -p $dev/include/mach-o/m88k
mkdir -p $dev/include/dyld
mkdir -p $dev/include/cbt
pushd include/mach-o
install -c -m 444 arch.h ldsyms.h reloc.h \
stab.h loader.h fat.h swap.h getsect.h nlist.h \
ranlib.h $dev/include/mach-o
popd
2022-08-06 11:49:27 +02:00
pushd include/mach-o/i386
install -c -m 444 swap.h \
$dev/include/mach-o/i386
popd
pushd include/mach-o/ppc
install -c -m 444 reloc.h swap.h \
$dev/include/mach-o/ppc
popd
pushd include/mach-o/x86_64
install -c -m 444 reloc.h \
$dev/include/mach-o/x86_64
popd
pushd include/mach-o/arm
install -c -m 444 reloc.h \
$dev/include/mach-o/arm
popd
pushd include/mach-o/arm64
install -c -m 444 reloc.h \
$dev/include/mach-o/arm64
popd
pushd include/mach-o/m68k
install -c -m 444 swap.h \
$dev/include/mach-o/m68k
popd
pushd include/mach-o/sparc
install -c -m 444 reloc.h swap.h \
$dev/include/mach-o/sparc
popd
pushd include/mach-o/hppa
install -c -m 444 reloc.h swap.h \
$dev/include/mach-o/hppa
popd
pushd include/mach-o/i860
install -c -m 444 reloc.h swap.h \
$dev/include/mach-o/i860
popd
pushd include/mach-o/m88k
install -c -m 444 reloc.h swap.h \
$dev/include/mach-o/m88k
popd
pushd include/stuff
install -c -m 444 bool.h \
$dev/include/dyld
popd
pushd include/cbt
install -c -m 444 libsyminfo.h \
$dev/include/cbt
popd
'';
passthru = {
inherit targetPrefix;
};
meta = {
broken = !stdenv.targetPlatform.isDarwin; # Only supports darwin targets
homepage = "http://www.opensource.apple.com/source/cctools/";
description = "MacOS Compiler Tools (cross-platform port)";
license = lib.licenses.apple-psl20;
2021-01-15 15:45:37 +01:00
maintainers = with lib.maintainers; [ matthewbauer ];
2015-02-03 23:06:13 +01:00
};
}