darwin.{cctools,libtapi}: drop old source

This commit is contained in:
Randy Eckenrode
2024-07-13 21:08:29 -04:00
parent 79f5f9bf1b
commit 76e12091eb
10 changed files with 0 additions and 616 deletions
-122
View File
@@ -1,122 +0,0 @@
{ lib, stdenv, fetchFromGitHub, symlinkJoin, xcbuildHook, tcsh, libobjc, libtapi, libunwind, llvm, memstreamHook, xar }:
let
cctools = stdenv.mkDerivation rec {
pname = "cctools";
version = "973.0.1";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "cctools";
rev = "${pname}-${version}";
hash = "sha256-0NlDqy3zeg4D0MbDipx0sMYDfzYa63Jxfsckzz/928o=";
};
patches = [
./cctools-add-missing-vtool-libstuff-dep.patch
];
postPatch = ''
for file in libstuff/writeout.c misc/libtool.c misc/lipo.c; do
substituteInPlace "$file" \
--replace '__builtin_available(macOS 10.12, *)' '0'
done
substituteInPlace libmacho/swap.c \
--replace '#ifndef RLD' '#if 1'
'';
nativeBuildInputs = [ xcbuildHook memstreamHook ];
buildInputs = [ libobjc llvm ];
xcbuildFlags = [
"MACOSX_DEPLOYMENT_TARGET=10.12"
];
doCheck = true;
checkPhase = ''
runHook preCheck
Products/Release/libstuff_test
rm Products/Release/libstuff_test
runHook postCheck
'';
installPhase = ''
runHook preInstall
rm -rf "$out/usr"
mkdir -p "$out/bin"
find Products/Release -maxdepth 1 -type f -perm 755 -exec cp {} "$out/bin/" \;
cp -r include "$out/"
ln -s ./nm-classic "$out"/bin/nm
ln -s ./otool-classic "$out"/bin/otool
runHook postInstall
'';
};
ld64 = stdenv.mkDerivation rec {
pname = "ld64";
version = "609";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "ld64";
rev = "${pname}-${version}";
hash = "sha256-WAaphem6NS4eCHL/pISlDXnO1CDYTgSrVGzcothh4/Q=";
};
postPatch = ''
substituteInPlace ld64.xcodeproj/project.pbxproj \
--replace "/bin/csh" "${tcsh}/bin/tcsh" \
--replace 'F9E8D4BE07FCAF2A00FD5801 /* PBXBuildRule */,' "" \
--replace 'F9E8D4BD07FCAF2000FD5801 /* PBXBuildRule */,' ""
sed -i src/ld/Options.cpp -e '1iconst char ldVersionString[] = "${version}";'
'';
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [
libtapi
libunwind
llvm
xar
];
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
find Products/Release-assert -maxdepth 1 -type f -perm 755 -exec cp {} "$out/bin/" \;
runHook postInstall
'';
};
in
symlinkJoin rec {
name = "cctools-${version}";
version = "${cctools.version}-${ld64.version}";
paths = [
cctools
ld64
];
# workaround for the fetch-tarballs script
passthru = {
inherit (cctools) src;
ld64_src = ld64.src;
};
meta = with lib; {
description = "MacOS Compiler Tools";
homepage = "http://www.opensource.apple.com/source/cctools/";
license = licenses.apple-psl20;
platforms = platforms.darwin;
};
}
@@ -1,11 +0,0 @@
diff -ru a/cctools.xcodeproj/project.pbxproj b/cctools.xcodeproj/project.pbxproj
--- a/cctools.xcodeproj/project.pbxproj 2021-02-24 20:30:55.000000000 -0500
+++ b/cctools.xcodeproj/project.pbxproj 2022-01-31 20:01:09.000000000 -0500
@@ -2558,6 +2558,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ DE97E92421F3B86100C7947D /* libstuff.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1,17 +0,0 @@
--- a/cctools/include/stuff/diagnostics.h
+++ b/cctools/include/stuff/diagnostics.h
@@ -60,13 +60,6 @@ void diagnostics_log_msg(enum diagnostic_level level, const char* message);
*/
void diagnostics_write(void);
-#if defined(__APPLE__ ) && defined(__has_builtin)
-# if __has_builtin(__builtin_available)
-# define HAVE_OPENMEMSTREAM_RUNTIME __builtin_available(macOS 10.13, *)
-# endif
-#endif
-#ifndef HAVE_OPENMEMSTREAM_RUNTIME
-# define HAVE_OPENMEMSTREAM_RUNTIME 1
-#endif
+#define HAVE_OPENMEMSTREAM_RUNTIME 1
#endif /* diagnostics_h */
@@ -1,16 +0,0 @@
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;
}
@@ -1,29 +0,0 @@
diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp
index e4b37ec..4189ebc 100644
--- a/cctools/ld64/src/ld/Options.cpp
+++ b/cctools/ld64/src/ld/Options.cpp
@@ -5800,24 +5800,6 @@ void Options::checkIllegalOptionCombinations()
if ( fDeadStrip && (fOutputKind == Options::kObjectFile) )
throw "-r and -dead_strip cannot be used together";
- // can't use -rpath unless targeting 10.5 or later
- if ( fRPaths.size() > 0 ) {
- if ( !platforms().minOS(ld::version2008) )
- 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 ( fPositionIndependentExecutable ) {
switch ( fOutputKind ) {
case Options::kDynamicExecutable:
-113
View File
@@ -1,113 +0,0 @@
# Create a cctools-compatible bintools that uses equivalent tools from LLVM in place of the ones
# from cctools when possible.
{ lib, stdenv, makeWrapper, cctools-port, llvmPackages, enableManpages ? stdenv.targetPlatform == stdenv.hostPlatform }:
let
inherit (stdenv) targetPlatform hostPlatform;
cctoolsVersion = lib.getVersion cctools-port;
llvmVersion = llvmPackages.release_version;
# `bitcode_strip` is not available until LLVM 12.
useLLVMBitcodeStrip = lib.versionAtLeast llvmVersion "12";
# A compatible implementation of `otool` was not added until LLVM 13.
useLLVMOtool = lib.versionAtLeast llvmVersion "13";
# Older versions of `strip` cause problems for the version of `codesign_allocate` available in
# the version of cctools in nixpkgs. The version of `codesign_allocate` in cctools-1005.2 does
# not appear to have issues, but the source is not available yet (as of June 2023).
useLLVMStrip = lib.versionAtLeast llvmVersion "15" || lib.versionAtLeast cctoolsVersion "1005.2";
# Clang 11 performs an optimization on x86_64 that is sensitive to the presence of debug info.
# This causes GCC to fail to bootstrap due to object file differences between stages 2 and 3.
useClangAssembler = lib.versionAtLeast llvmVersion "12" || !stdenv.isx86_64;
llvm_bins = [
"dwarfdump"
"nm"
"objdump"
"size"
"strings"
]
++ lib.optional useLLVMBitcodeStrip "bitcode-strip"
++ lib.optional useLLVMOtool "otool"
++ lib.optional useLLVMStrip "strip";
# Only include the tools that LLVM doesnt provide and that are present normally on Darwin.
# The only exceptions are the following tools, which should be reevaluated when LLVM is bumped.
# - install_name_tool (llvm-objcopy): unrecognized linker commands when building open source CF;
# - libtool (llvm-libtool-darwin): not fully compatible when used with xcbuild; and
# - lipo (llvm-lipo): crashes when running the LLVM test suite.
cctools_bins = [
"cmpdylib"
"codesign_allocate"
"ctf_insert"
"install_name_tool"
"ld"
"libtool"
"lipo"
"nmedit"
"pagestuff"
"ranlib"
"segedit"
"vtool"
]
++ lib.optional (!useLLVMBitcodeStrip) "bitcode_strip"
++ lib.optional (!useLLVMOtool) "otool"
++ lib.optional (!useLLVMStrip) "strip"
++ lib.optional (!useClangAssembler) "as";
targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
linkManPages = pkg: source: target: lib.optionalString enableManpages ''
sourcePath=${pkg}/share/man/man1/${source}.1.gz
targetPath=$man/share/man/man1/${target}.1.gz
if [ -f "$sourcePath" ]; then
mkdir -p "$(dirname "$targetPath")"
ln -s "$sourcePath" "$targetPath"
fi
'';
in
stdenv.mkDerivation {
pname = "cctools-llvm";
version = "${llvmVersion}-${cctoolsVersion}";
nativeBuildInputs = [ makeWrapper ];
# The `man` output has to be included unconditionally because darwin.binutils expects it.
outputs = [ "out" "dev" "man" ];
buildCommand = ''
mkdir -p "$out/bin" "$man"
ln -s ${lib.getDev cctools-port} "$dev"
'' + lib.optionalString useClangAssembler ''
# Use the clang-integrated assembler instead of using `as` from cctools.
makeWrapper "${lib.getBin llvmPackages.clang-unwrapped}/bin/clang" "$out/bin/${targetPrefix}as" \
--add-flags "-x assembler -integrated-as -c"
'' + ''
ln -s "${lib.getBin llvmPackages.bintools-unwrapped}/bin/${targetPrefix}llvm-ar" "$out/bin/${targetPrefix}ar"
${linkManPages llvmPackages.llvm-manpages "llvm-ar" "ar"}
for tool in ${toString llvm_bins}; do
cctoolsTool=''${tool/-/_}
ln -s "${lib.getBin llvmPackages.llvm}/bin/llvm-$tool" "$out/bin/${targetPrefix}$cctoolsTool"
${linkManPages llvmPackages.llvm-manpages "llvm-$tool" "$cctoolsTool"}
done
for tool in ${toString cctools_bins}; do
ln -s "${lib.getBin cctools-port}/bin/${targetPrefix}$tool" "$out/bin/${targetPrefix}$tool"
${linkManPages (lib.getMan cctools-port) "$tool" "$tool"}
done
${linkManPages (lib.getMan cctools-port) "ld64" "ld64"}
${lib.optionalString (!useLLVMOtool) # The actual man page for otool in cctools is llvm-otool
(linkManPages (lib.getMan cctools-port) "llvm-otool" "llvm-otool")}
'';
passthru = { inherit targetPrefix; };
}
-198
View File
@@ -1,198 +0,0 @@
{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook, memstreamHook
, installShellFiles
, libuuid
, libobjc ? null, maloader ? null
, enableTapiSupport ? true, libtapi
, fetchpatch
}:
let
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
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";
version = "973.0.1";
src = fetchFromGitHub {
owner = "tpoechtrager";
repo = "cctools-port";
# 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" "gas" "man" ];
nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]
++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ memstreamHook ];
buildInputs = [ libuuid ]
++ lib.optionals stdenv.isDarwin [ libobjc ]
++ lib.optional enableTapiSupport libtapi;
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" ]
++ lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target";
configureFlags = [ "--disable-clang-as" ]
++ lib.optionals enableTapiSupport [
"--enable-tapi-support"
"--with-libtapi=${libtapi}"
];
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" "" \
# 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 = ''
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
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
'';
postInstall = ''
# Move GNU as to its own output to prevent it from being used accidentally.
moveToOutput bin/gas "$gas"
moveToOutput libexec "$gas"
'';
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;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}
@@ -1,75 +0,0 @@
{ lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }:
stdenv.mkDerivation (finalAttrs: {
pname = "libtapi";
version = "1100.0.11"; # determined by looking at VERSION.txt
src = fetchFromGitHub {
owner = "tpoechtrager";
repo = "apple-libtapi";
rev = "664b8414f89612f2dfd35a9b679c345aa5389026";
sha256 = "1y1yl46msabfy14z0rln333a06087bk14f5h7q1cdawn8nmvbdbr";
};
sourceRoot = "${finalAttrs.src.name}/src/llvm";
# Backported from newer llvm, fixes configure error when cross compiling.
# Also means we don't have to manually fix the result with install_name_tool.
patches = [
./disable-rpath.patch
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# TODO: make unconditional and rebuild the world
# TODO: send upstream
./native-clang-tblgen.patch
];
nativeBuildInputs = [ cmake python3 ];
# ncurses is required here to avoid a reference to bootstrap-tools, which is
# not allowed for the stdenv.
buildInputs = [ ncurses ];
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
# This package could probably have a llvm_6 llvm-tblgen and clang-tblgen
# provided to reduce some building. This package seems intended to
# include all of its dependencies, including enough of LLVM to build the
# required tablegens.
(
let
nativeCC = pkgsBuildBuild.stdenv.cc;
nativeBintools = nativeCC.bintools.bintools;
nativeToolchainFlags = [
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
];
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
)
];
# fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found
# adapted from upstream
# https://github.com/tpoechtrager/apple-libtapi/blob/3cb307764cc5f1856c8a23bbdf3eb49dfc6bea48/build.sh#L58-L60
preConfigure = ''
INCLUDE_FIX="-I $PWD/projects/clang/include"
INCLUDE_FIX+=" -I $PWD/build/projects/clang/include"
cmakeFlagsArray+=(-DCMAKE_CXX_FLAGS="$INCLUDE_FIX")
'';
buildFlags = [ "clangBasic" "libtapi" "tapi" ];
installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ];
meta = with lib; {
description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
mainProgram = "tapi";
homepage = "https://github.com/tpoechtrager/apple-libtapi";
license = licenses.ncsa;
maintainers = with maintainers; [ matthewbauer ];
};
})
@@ -1,14 +0,0 @@
diff --git a/src/llvm/cmake/modules/AddLLVM.cmake b/src/llvm/cmake/modules/AddLLVM.cmake
index a53016eb0..b65e608a4 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -1683,8 +1683,7 @@ function(llvm_setup_rpath name)
endif()
if (APPLE)
- set(_install_name_dir INSTALL_NAME_DIR "@rpath")
- set(_install_rpath "@loader_path/../lib" ${extra_libdir})
+ set(_install_name_dir)
elseif(UNIX)
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
@@ -1,21 +0,0 @@
diffprojects/libtapi/CMakeLists.txt b/src/llvm/projects/libtapi/CMakeLists.txt
index 8ee6d8138..8277be147 100644
--- a/projects/libtapi/CMakeLists.txt
+++ b/projects/libtapi/CMakeLists.txt
@@ -193,7 +193,15 @@ if (NOT DEFINED CLANG_VERSION)
set(CLANG_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
endif ()
if (NOT DEFINED CLANG_TABLEGEN_EXE)
- set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
+ if(LLVM_USE_HOST_TOOLS)
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/clang-tblgen")
+ else()
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/clang-tblgen")
+ endif()
+ else()
+ set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
+ endif ()
endif ()
# Include must go first.