Automated rollback of commit 19a401c38e30ebc0879925a5caedcbe43de0028f.

*** Reason for rollback ***

Breaks external go_rules (https://github.com/bazelbuild/bazel/issues/6283)

*** Original change description ***

macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext.
PiperOrigin-RevId: 215447343
diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl
index 7bb69e0..5987ce5 100644
--- a/tools/osx/crosstool/CROSSTOOL.tpl
+++ b/tools/osx/crosstool/CROSSTOOL.tpl
@@ -119,6 +119,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   objcopy_embed_flag: "-I"
   objcopy_embed_flag: "binary"
@@ -169,23 +170,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -334,21 +318,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-    flag_set {
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-nostdlib"
-        flag: "-lkmod"
-        flag: "-lkmodc++"
-        flag: "-lcc_kext"
-        flag: "-Xlinker"
-        flag: "-kext"
-      }
-    }
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -1117,9 +1086,6 @@
         flag: "-framework"
         flag: "Foundation"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
     }
   }
   feature {
@@ -1497,6 +1463,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "x86_64"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -1508,15 +1478,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "x86_64"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -1809,6 +1770,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "x86_64-apple-ios"
@@ -1858,23 +1820,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -2032,9 +1977,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -3187,6 +3129,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "x86_64"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -3198,15 +3144,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "x86_64"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -3499,6 +3436,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "i386-apple-watchos"
@@ -3548,23 +3486,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -3722,9 +3643,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -4879,6 +4797,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "i386"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -4890,15 +4812,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "i386"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -5191,6 +5104,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "x86_64-apple-tvos"
@@ -5241,23 +5155,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -5415,9 +5312,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -6597,6 +6491,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "x86_64"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -6608,15 +6506,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "x86_64"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -6912,6 +6801,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "i386-apple-ios"
@@ -6961,23 +6851,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -7135,9 +7008,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -8290,6 +8160,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "i386"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -8301,15 +8175,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "i386"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -8602,6 +8467,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "armv7-apple-ios"
@@ -8651,23 +8517,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -8825,9 +8674,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -9968,6 +9814,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "armv7"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -9979,15 +9829,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "armv7"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -10280,6 +10121,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "armv7-apple-watchos"
@@ -10329,23 +10171,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -10503,9 +10328,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -11648,6 +11470,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "armv7k"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -11659,15 +11485,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "armv7k"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -11960,6 +11777,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "arm64-apple-tvos"
@@ -12010,23 +11828,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -12184,9 +11985,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -13354,6 +13152,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "arm64"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -13365,15 +13167,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "arm64"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -13669,6 +13462,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   linker_flag: "-target"
   linker_flag: "arm64-apple-ios"
@@ -13718,23 +13512,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -13892,9 +13669,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -15035,6 +14809,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "arm64"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -15046,15 +14824,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "arm64"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"
@@ -15348,6 +15117,7 @@
   compiler_flag: "-fno-omit-frame-pointer"
   cxx_flag: "-std=c++11"
   linker_flag: "-headerpad_max_install_names"
+  linker_flag: "-lc++"
   linker_flag: "-no-canonical-prefixes"
   objcopy_embed_flag: "-I"
   objcopy_embed_flag: "binary"
@@ -15397,23 +15167,6 @@
     name: "dbg"
   }
   feature {
-    name: "link_libc++"
-    flag_set {
-      action: "c++-link-executable"
-      action: "c++-link-dynamic-library"
-      action: "c++-link-nodeps-dynamic-library"
-      action: "objc-executable"
-      action: "objc++-executable"
-      flag_group {
-        flag: "-lc++"
-      }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    enabled: true
-  }
-  feature {
     name: "compile_all_modules"
   }
   feature {
@@ -15571,9 +15324,6 @@
     }
   }
   feature {
-    name: "kernel_extension"
-  }
-  feature {
     name: "linkstamps"
     flag_set {
       action: "c++-link-executable"
@@ -16714,6 +16464,10 @@
     }
     flag_set {
       flag_group {
+        flag: "-arch"
+        flag: "<architecture>"
+      }
+      flag_group {
         flag: "-Xlinker"
         flag: "-objc_abi_version"
         flag: "-Xlinker"
@@ -16725,15 +16479,6 @@
         flag: "-fobjc-link-runtime"
         flag: "-ObjC"
       }
-      with_feature {
-        not_feature: "kernel_extension"
-      }
-    }
-    flag_set {
-      flag_group {
-        flag: "-arch"
-        flag: "<architecture>"
-      }
       flag_group {
         flag: "-framework"
         flag: "%{framework_names}"