From 19a401c38e30ebc0879925a5caedcbe43de0028f Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 19 Sep 2018 09:22:33 -0700 Subject: [PATCH] macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 213639572 --- tools/osx/crosstool/CROSSTOOL.tpl | 355 +++++++++++++++++++++++++----- 1 file changed, 305 insertions(+), 50 deletions(-) diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl index 5761edc1f5f52a..fb4ea3dd3fbcb5 100644 --- a/tools/osx/crosstool/CROSSTOOL.tpl +++ b/tools/osx/crosstool/CROSSTOOL.tpl @@ -119,7 +119,6 @@ toolchain { 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,6 +168,23 @@ toolchain { feature { 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" } @@ -317,6 +333,21 @@ toolchain { } } } + 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 { @@ -1086,6 +1117,9 @@ toolchain { flag: "-framework" flag: "Foundation" } + with_feature { + not_feature: "kernel_extension" + } } } feature { @@ -1462,10 +1496,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "x86_64" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -1478,6 +1508,15 @@ toolchain { 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}" @@ -1770,7 +1809,6 @@ toolchain { 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" @@ -1819,6 +1857,23 @@ toolchain { feature { 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" } @@ -1976,6 +2031,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -3128,10 +3186,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "x86_64" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -3144,6 +3198,15 @@ toolchain { 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}" @@ -3436,7 +3499,6 @@ toolchain { 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" @@ -3485,6 +3547,23 @@ toolchain { feature { 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" } @@ -3642,6 +3721,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -4796,10 +4878,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "i386" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -4812,6 +4890,15 @@ toolchain { 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}" @@ -5104,7 +5191,6 @@ toolchain { 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" @@ -5154,6 +5240,23 @@ toolchain { feature { 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" } @@ -5311,6 +5414,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -6490,10 +6596,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "x86_64" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -6506,6 +6608,15 @@ toolchain { 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}" @@ -6801,7 +6912,6 @@ toolchain { 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" @@ -6850,6 +6960,23 @@ toolchain { feature { 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" } @@ -7007,6 +7134,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -8159,10 +8289,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "i386" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -8175,6 +8301,15 @@ toolchain { 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}" @@ -8467,7 +8602,6 @@ toolchain { 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" @@ -8516,6 +8650,23 @@ toolchain { feature { 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" } @@ -8673,6 +8824,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -9813,10 +9967,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "armv7" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -9829,6 +9979,15 @@ toolchain { 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}" @@ -10121,7 +10280,6 @@ toolchain { 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" @@ -10170,6 +10328,23 @@ toolchain { feature { 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" } @@ -10327,6 +10502,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -11469,10 +11647,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "armv7k" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -11485,6 +11659,15 @@ toolchain { 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}" @@ -11777,7 +11960,6 @@ toolchain { 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" @@ -11827,6 +12009,23 @@ toolchain { feature { 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" } @@ -11984,6 +12183,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -13151,10 +13353,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "arm64" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -13167,6 +13365,15 @@ toolchain { 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}" @@ -13462,7 +13669,6 @@ toolchain { 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" @@ -13511,6 +13717,23 @@ toolchain { feature { 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" } @@ -13668,6 +13891,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -14808,10 +15034,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "arm64" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -14824,6 +15046,15 @@ toolchain { 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}" @@ -15117,7 +15348,6 @@ toolchain { 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" @@ -15166,6 +15396,23 @@ toolchain { feature { 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" } @@ -15323,6 +15570,9 @@ toolchain { } } } + feature { + name: "kernel_extension" + } feature { name: "linkstamps" flag_set { @@ -16463,10 +16713,6 @@ toolchain { execution_requirement: "requires-darwin" } flag_set { - flag_group { - flag: "-arch" - flag: "" - } flag_group { flag: "-Xlinker" flag: "-objc_abi_version" @@ -16479,6 +16725,15 @@ toolchain { flag: "-fobjc-link-runtime" flag: "-ObjC" } + with_feature { + not_feature: "kernel_extension" + } + } + flag_set { + flag_group { + flag: "-arch" + flag: "" + } flag_group { flag: "-framework" flag: "%{framework_names}"