Commit 04b49f4e authored by Emily's avatar Emily
Browse files

apple-sdk: add hack for C++ issues on `x86_64-darwin`

parent cb1de513
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -38,5 +38,21 @@ self: super: {
        llvm-readtapi --filetype=tbd-v4 usr/lib/$libSystem~ -o usr/lib/$libSystem
        rm usr/lib/$libSystem~
      done

      # Strip weak C++ symbols to work around `libc++` leakage in system
      # frameworks for now. These are only present on `x86_64-darwin`, so
      # it should hopefully be harmless.
      #
      # TODO FIXME: This is kind of horrible.
      while read -r -d "" stub; do
        printf 'Stripping weak C++ symbols from %s\n' "$stub"
        llvm-readtapi --filetype=tbd-v5 "$stub" \
        | jq '
          (.main_library, .libraries[]?).exported_symbols[]?.data.weak[]? |=
            select(startswith("__Z") | not)
        ' > $stub~
        llvm-readtapi --filetype=tbd-v4 $stub~ -o $stub
        rm $stub~
      done < <(find . -name '*.tbd' -print0)
    '';
}