From b2cb2a8d44baa12d3123e53bb47f2daf37a1e8a7 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 5 Oct 2024 21:23:39 +0100 Subject: [PATCH] {clang-sierraHack{,-stdenv},tests.macOSSierraShared}: drop This is some thing introduced in 2017 to work around a problem that no longer seems to exist. Nothing uses it except its own test, which these days passes even with the standard `clangStdenv`. --- .../bintools-wrapper/default.nix | 10 - .../macos-sierra-reexport-hack.bash | 246 ------------------ pkgs/test/default.nix | 2 - pkgs/test/macos-sierra-shared/default.nix | 90 ------- pkgs/top-level/aliases.nix | 2 + pkgs/top-level/all-packages.nix | 8 - 6 files changed, 2 insertions(+), 356 deletions(-) delete mode 100644 pkgs/build-support/bintools-wrapper/macos-sierra-reexport-hack.bash delete mode 100644 pkgs/test/macos-sierra-shared/default.nix diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index b64e97345ab5..b4736bc960fa 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -31,7 +31,6 @@ , isCCTools ? bintools.isCCTools or false , expand-response-params , targetPackages ? {} -, useMacosReexportHack ? false , wrapGas ? false # Note: the hardening flags are part of the bintools-wrapper, rather than @@ -228,16 +227,9 @@ stdenvNoCC.mkDerivation { fi done - '' + (if !useMacosReexportHack then '' if [ -e ''${ld:-$ldPath/${targetPrefix}ld} ]; then wrap ${targetPrefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${targetPrefix}ld} fi - '' else '' - ldInner="${targetPrefix}ld-reexport-delegate" - wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${targetPrefix}ld} - wrap "${targetPrefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner" - unset ldInner - '') + '' for variant in $ldPath/${targetPrefix}ld.*; do basename=$(basename "$variant") @@ -421,7 +413,5 @@ stdenvNoCC.mkDerivation { attrByPath ["meta" "description"] "System binary utilities" bintools_ + " (wrapper script)"; priority = 10; - } // optionalAttrs useMacosReexportHack { - platforms = platforms.darwin; }; } diff --git a/pkgs/build-support/bintools-wrapper/macos-sierra-reexport-hack.bash b/pkgs/build-support/bintools-wrapper/macos-sierra-reexport-hack.bash deleted file mode 100644 index 255071adf681..000000000000 --- a/pkgs/build-support/bintools-wrapper/macos-sierra-reexport-hack.bash +++ /dev/null @@ -1,246 +0,0 @@ -#! @shell@ - -set -eu -o pipefail - -# For cmd | while read; do ...; done -shopt -s lastpipe - -path_backup="$PATH" -if [ -n "@coreutils_bin@" ]; then - PATH="@coreutils_bin@/bin" -fi - -declare -ri recurThreshold=200 -declare -i overflowCount=0 - -declare -ar origArgs=("$@") - -# Throw away what we won't need -declare -a parentArgs=() - -while (( $# )); do - case "$1" in - -l) - echo "cctools LD does not support '-l foo'" >&2 - exit 1 - ;; - -lazy_library | -reexport_library | -upward_library | -weak_library) - overflowCount+=1 - shift 2 - ;; - -l* | *.so.* | *.dylib | -lazy-l* | -reexport-l* | -upward-l* | -weak-l*) - overflowCount+=1 - shift 1 - ;; - *.a | *.o) - shift 1 - ;; - -L | -F) - # Evidentally ld doesn't like using the child's RPATH, so it still - # needs these. - parentArgs+=("$1" "$2") - shift 2 - ;; - -L?* | -F?*) - parentArgs+=("$1") - shift 1 - ;; - -o) - outputName="$2" - parentArgs+=("$1" "$2") - shift 2 - ;; - -install_name | -dylib_install_name | -dynamic-linker | -plugin) - parentArgs+=("$1" "$2") - shift 2 - ;; - -rpath) - # Only an rpath to the child is needed, which we will add - shift 2 - ;; - *) - if [[ -f "$1" ]]; then - # Propabably a non-standard object file like Haskell's - # `.dyn_o`. Skip it like other inputs - : - else - parentArgs+=("$1") - fi - shift 1 - ;; - esac -done - - - -if (( "$overflowCount" <= "$recurThreshold" )); then - if [ -n "${NIX_DEBUG:-}" ]; then - echo "ld-wrapper: Only ${overflowCount} inputs counted while ${recurThreshold} is the ceiling, linking normally. " >&2 - fi - PATH="$path_backup" - exec @prog@ "${origArgs[@]}" -fi - - - -if [ -n "${NIX_DEBUG:-}" ]; then - echo "ld-wrapper: ${overflowCount} inputs counted when ${recurThreshold} is the ceiling, inspecting further. " >&2 -fi - -# Collect the normalized linker input -declare -a norm=() - -# Arguments are null-separated -@prog@ --dump-normalized-lib-args "${origArgs[@]}" | - while IFS= read -r -d '' input; do - norm+=("$input") - done - -declare -i leafCount=0 -declare lastLeaf='' -declare -a childrenInputs=() trailingInputs=() -while (( "${#norm[@]}" )); do - case "${norm[0]}" in - -lazy_library | -upward_library) - # TODO(@Ericson2314): Don't do that, but intersperse children - # between such args. - echo "ld-wrapper: Warning: Potentially changing link order" >&2 - trailingInputs+=("${norm[0]}" "${norm[1]}") - norm=("${norm[@]:2}") - ;; - -reexport_library | -weak_library) - childrenInputs+=("${norm[0]}" "${norm[1]}") - if [[ "${norm[1]}" != "$lastLeaf" ]]; then - leafCount+=1 - lastLeaf="${norm[1]}" - fi - norm=("${norm[@]:2}") - ;; - *.so | *.dylib) - childrenInputs+=(-reexport_library "${norm[0]}") - if [[ "${norm[0]}" != "$lastLeaf" ]]; then - leafCount+=1 - lastLeaf="${norm[0]}" - fi - norm=("${norm[@]:1}") - ;; - *.o | *.a) - # Don't delegate object files or static libs - parentArgs+=("${norm[0]}") - norm=("${norm[@]:1}") - ;; - *) - if [[ -f "${norm[0]}" ]]; then - # Propabably a non-standard object file. We'll let it by. - parentArgs+=("${norm[0]}") - norm=("${norm[@]:1}") - else - echo "ld-wrapper: Internal Error: Invalid normalized argument" >&2 - exit 255 - fi - ;; - esac -done - - - -if (( "$leafCount" <= "$recurThreshold" )); then - if [ -n "${NIX_DEBUG:-}" ]; then - echo "ld-wrapper: Only ${leafCount} *dynamic* inputs counted while ${recurThreshold} is the ceiling, linking normally. " >&2 - fi - PATH="$path_backup" - exec @prog@ "${origArgs[@]}" -fi - - - -if [ -n "${NIX_DEBUG:-}" ]; then - echo "ld-wrapper: ${leafCount} *dynamic* inputs counted when ${recurThreshold} is the ceiling, delegating to children. " >&2 -fi - -declare -r outputNameLibless=$( \ - if [[ -z "${outputName:+isUndefined}" ]]; then - echo unnamed - return 0; - fi - baseName=$(basename ${outputName}) - if [[ "$baseName" = lib* ]]; then - baseName="${baseName:3}" - fi - echo "$baseName") - -declare -ra children=( - "$outputNameLibless-reexport-delegate-0" - "$outputNameLibless-reexport-delegate-1" -) - -mkdir -p "$out/lib" - -symbolBloatObject=$outputNameLibless-symbol-hack.o -if [[ ! -f $symbolBloatObject ]]; then - # `-Q` means use GNU Assembler rather than Clang, avoiding an awkward - # dependency cycle. - printf '.private_extern _______child_hack_foo\nchild_hack_foo:\n' | - PATH="$PATH:@out@/bin" @targetPrefix@as -Q -- -o $symbolBloatObject -fi - -# Split inputs between children -declare -a child0Inputs=() child1Inputs=("${childrenInputs[@]}") -let "countFirstChild = $leafCount / 2" || true -lastLeaf='' -while (( "$countFirstChild" )); do - case "${child1Inputs[0]}" in - -reexport_library | -weak_library) - child0Inputs+=("${child1Inputs[0]}" "${child1Inputs[1]}") - if [[ "${child1Inputs[1]}" != "$lastLeaf" ]]; then - let countFirstChild-=1 || true - lastLeaf="${child1Inputs[1]}" - fi - child1Inputs=("${child1Inputs[@]:2}") - ;; - *.so | *.dylib) - child0Inputs+=(-reexport_library "${child1Inputs[0]}") - if [[ "${child1Inputs[0]}" != "$lastLeaf" ]]; then - let countFirstChild-=1 || true - lastLeaf="${child1Inputs[1]}" - fi - child1Inputs=("${child1Inputs[@]:2}") - ;; - *) - echo "ld-wrapper: Internal Error: Invalid delegated input" >&2 - exit -1 - ;; - esac -done - - -# First half of libs -@out@/bin/@targetPrefix@ld \ - -macosx_version_min $MACOSX_DEPLOYMENT_TARGET -arch x86_64 -dylib \ - -o "$out/lib/lib${children[0]}.dylib" \ - -install_name "$out/lib/lib${children[0]}.dylib" \ - "$symbolBloatObject" "${child0Inputs[@]}" "${trailingInputs[@]}" - -# Second half of libs -@out@/bin/@targetPrefix@ld \ - -macosx_version_min $MACOSX_DEPLOYMENT_TARGET -arch x86_64 -dylib \ - -o "$out/lib/lib${children[1]}.dylib" \ - -install_name "$out/lib/lib${children[1]}.dylib" \ - "$symbolBloatObject" "${child1Inputs[@]}" "${trailingInputs[@]}" - -parentArgs+=("-L$out/lib" -rpath "$out/lib") -if [[ $outputName != *reexport-delegate* ]]; then - parentArgs+=("-l${children[0]}" "-l${children[1]}") -else - parentArgs+=("-reexport-l${children[0]}" "-reexport-l${children[1]}") -fi - -parentArgs+=("${trailingInputs[@]}") - -if [ -n "${NIX_DEBUG:-}" ]; then - echo "flags using delegated children to @prog@:" >&2 - printf " %q\n" "${parentArgs[@]}" >&2 -fi - -PATH="$path_backup" -exec @prog@ "${parentArgs[@]}" diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index adb112fd3668..b34add94830e 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -125,8 +125,6 @@ with pkgs; ld-library-path = callPackage ./ld-library-path {}; - macOSSierraShared = callPackage ./macos-sierra-shared {}; - cross = callPackage ./cross {} // { __attrsFailEvaluation = true; }; php = recurseIntoAttrs (callPackages ./php {}); diff --git a/pkgs/test/macos-sierra-shared/default.nix b/pkgs/test/macos-sierra-shared/default.nix deleted file mode 100644 index 810d5d97829b..000000000000 --- a/pkgs/test/macos-sierra-shared/default.nix +++ /dev/null @@ -1,90 +0,0 @@ -{ lib, clangStdenv, clang-sierraHack-stdenv, stdenvNoCC }: - -let - makeBigExe = stdenv: prefix: rec { - - count = 320; - - sillyLibs = lib.genList (i: stdenv.mkDerivation rec { - name = "${prefix}-fluff-${toString i}"; - unpackPhase = '' - src=$PWD - cat << 'EOF' > ${name}.c - unsigned int asdf_${toString i}(void) { - return ${toString i}; - } - EOF - ''; - buildPhase = '' - $CC -std=c99 -shared ${name}.c -o lib${name}.dylib -Wl,-install_name,$out/lib/lib${name}.dylib - ''; - installPhase = '' - mkdir -p "$out/lib" - mv lib${name}.dylib "$out/lib" - ''; - meta.platforms = lib.platforms.darwin; - }) count; - - finalExe = stdenv.mkDerivation { - name = "${prefix}-final-asdf"; - unpackPhase = '' - src=$PWD - cat << 'EOF' > main.cxx - - #include - #include - - ${toString (lib.genList (i: "extern \"C\" unsigned int asdf_${toString i}(void); ") count)} - - unsigned int (*funs[])(void) = { - ${toString (lib.genList (i: "asdf_${toString i},") count)} - }; - - int main(int argc, char **argv) { - bool ret; - unsigned int i = 0; - for (auto f : funs) { - if (f() != i++) { - std::cerr << "Failed to get expected response from function #" << i << std::endl; - return EXIT_FAILURE; - } - } - return EXIT_SUCCESS; - } - EOF - ''; - buildPhase = '' - $CXX -std=c++11 main.cxx ${toString (map (x: "-l${x.name}") sillyLibs)} -o ${prefix}-asdf - ''; - buildInputs = sillyLibs; - installPhase = '' - mkdir -p "$out/bin" - mv ${prefix}-asdf "$out/bin" - ''; - meta.platforms = lib.platforms.darwin; - }; - - }; - - good = makeBigExe clang-sierraHack-stdenv "good"; - - bad = makeBigExe clangStdenv "bad"; - -in stdenvNoCC.mkDerivation { - name = "macos-sierra-shared-test"; - buildInputs = [ good.finalExe bad.finalExe ]; - # TODO(@Ericson2314): Be impure or require exact MacOS version of builder? - buildCommand = '' - if bad-asdf &> /dev/null - then echo "WARNING: bad-asdf did not fail, not running on sierra?" >&2 - else echo "bad-asdf should fail on sierra, OK" >&2 - fi - - # Must succeed on all supported MacOS versions - good-asdf - echo "good-asdf should succeed on sierra, OK" - - touch $out - ''; - meta.platforms = lib.platforms.darwin; -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 972743705c9f..67324d2720b3 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -252,6 +252,8 @@ mapAliases { cloog_0_18_0 = throw "cloog_0_18_0 has been removed from Nixpkgs, as it is unmaintained and obsolete"; # Added 2024-09-13 cloogppl = throw "cloogppl has been removed from Nixpkgs, as it is unmaintained and obsolete"; # Added 2024-09-13 clang-ocl = throw "'clang-ocl' has been replaced with 'rocmPackages.clang-ocl'"; # Added 2023-10-08 + clang-sierraHack = throw "clang-sierraHack has been removed because it solves a problem that no longer seems to exist. Hey, what were you even doing with that thing anyway?"; # Added 2024-10-05 + clang-sierraHack-stdenv = clang-sierraHack; # Added 2024-10-05 inherit (libsForQt5.mauiPackages) clip; # added 2022-05-17 clpm = throw "'clpm' has been removed from nixpkgs"; # Added 2024-04-01 clwrapperFunction = throw "Lisp packages have been redesigned. See 'lisp-modules' in the nixpkgs manual."; # Added 2024-05-07 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7db8390e7964..bb5c2f0b4215 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14454,13 +14454,6 @@ with pkgs; libclang = llvmPackages.libclang; clang-manpages = llvmPackages.clang-manpages; - clang-sierraHack = clang.override { - name = "clang-wrapper-with-reexport-hack"; - bintools = darwin.binutils.override { - useMacosReexportHack = true; - }; - }; - clang = llvmPackages.clang; clang_12 = llvmPackages_12.clang; clang_13 = llvmPackages_13.clang; @@ -14483,7 +14476,6 @@ with pkgs; #Use this instead of stdenv to build with clang clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv; - clang-sierraHack-stdenv = overrideCC stdenv buildPackages.clang-sierraHack; libcxxStdenv = if stdenv.hostPlatform.isDarwin then stdenv else lowPrio llvmPackages.libcxxStdenv; clean = callPackage ../development/compilers/clean { };