2023-06-04 23:40:37 +02:00
|
|
|
{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook, memstreamHook
|
2020-04-21 05:52:24 +02:00
|
|
|
, installShellFiles
|
2020-11-19 08:39:27 +01:00
|
|
|
, libuuid
|
2018-05-22 01:50:12 +02:00
|
|
|
, libobjc ? null, maloader ? null
|
2019-02-09 21:09:43 +01:00
|
|
|
, enableTapiSupport ? true, libtapi
|
2023-02-24 02:05:18 +01:00
|
|
|
, fetchpatch
|
2015-02-03 23:06:13 +01:00
|
|
|
}:
|
|
|
|
|
2017-04-24 22:00:11 +02:00
|
|
|
let
|
2018-04-16 01:22:17 +02:00
|
|
|
|
2017-11-25 19:43:57 +01:00
|
|
|
# The targetPrefix prepended to binary names to allow multiple binuntils on the
|
2017-06-23 23:45:27 +02:00
|
|
|
# PATH to both be usable.
|
2021-01-15 15:45:37 +01:00
|
|
|
targetPrefix = lib.optionalString
|
2018-08-20 20:43:41 +02:00
|
|
|
(stdenv.targetPlatform != stdenv.hostPlatform)
|
|
|
|
"${stdenv.targetPlatform.config}-";
|
2017-04-24 22:00:11 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
# Non-Darwin alternatives
|
2018-08-20 20:43:41 +02:00
|
|
|
assert (!stdenv.hostPlatform.isDarwin) -> maloader != null;
|
2017-04-24 22:00:11 +02:00
|
|
|
|
2020-07-20 22:48:39 +02:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "${targetPrefix}cctools-port";
|
2022-08-06 11:49:27 +02:00
|
|
|
version = "973.0.1";
|
2020-07-20 22:48:39 +02:00
|
|
|
|
|
|
|
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";
|
2020-07-20 22:48:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
2023-06-04 23:40:37 +02:00
|
|
|
nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]
|
|
|
|
++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ memstreamHook ];
|
2020-07-20 22:48:39 +02:00
|
|
|
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;
|
2020-07-20 22:48:39 +02:00
|
|
|
|
2022-08-06 11:49:27 +02:00
|
|
|
patches = [
|
|
|
|
./ld-ignore-rpath-link.patch
|
|
|
|
./ld-rpath-nonfinal.patch
|
2023-02-24 02:05:18 +01:00
|
|
|
(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=";
|
|
|
|
})
|
2023-06-04 23:40:37 +02:00
|
|
|
# Always use `open_memstream`. This is provided by memstream via hook on x86_64-darwin.
|
|
|
|
./darwin-memstream.patch
|
|
|
|
];
|
2020-07-20 22:48:39 +02:00
|
|
|
|
|
|
|
__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";
|
2020-07-20 22:48:39 +02:00
|
|
|
configureFlags = [ "--disable-clang-as" ]
|
2021-01-15 15:45:37 +01:00
|
|
|
++ lib.optionals enableTapiSupport [
|
2020-07-20 22:48:39 +02:00
|
|
|
"--enable-tapi-support"
|
|
|
|
"--with-libtapi=${libtapi}"
|
2017-11-14 16:35:18 +01:00
|
|
|
];
|
|
|
|
|
2021-01-15 15:45:37 +01:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2020-07-20 22:48:39 +02:00
|
|
|
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" ""
|
2020-07-20 22:48:39 +02:00
|
|
|
|
|
|
|
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
|
2020-07-20 22:48:39 +02:00
|
|
|
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
|
2020-07-20 22:48:39 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
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)";
|
2024-04-05 22:18:41 +02:00
|
|
|
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
|
|
|
};
|
2020-07-20 22:48:39 +02:00
|
|
|
}
|