From 36f9ff6d757e51aa20c8f59817e94e645fb04a35 Mon Sep 17 00:00:00 2001 From: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> Date: Thu, 29 Feb 2024 18:05:02 +1300 Subject: [PATCH] Use host toolchain for all mac and ios targets (#32283) * Use host toolchain for all mac and ios targets. * Fix ASAN options for clang build * Collect .ips files from the system directory as well --- .github/workflows/darwin.yaml | 11 +++---- build/config/BUILDCONFIG.gn | 11 +++---- build/config/compiler/BUILD.gn | 4 +-- build/toolchain/ios/BUILD.gn | 42 ------------------------- examples/darwin-framework-tool/BUILD.gn | 1 + 5 files changed, 11 insertions(+), 58 deletions(-) delete mode 100644 build/toolchain/ios/BUILD.gn diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index a58617131a035d..0602b735d36b88 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -119,13 +119,10 @@ jobs: run: | xcodebuild -target "MatterTvCastingBridge" -sdk iphoneos working-directory: examples/tv-casting-app/darwin/MatterTvCastingBridge - - name: Uploading .ips files in Xcode derived data to debug the failure - uses: actions/upload-artifact@v4 - if: ${{ failure() && !env.ACT }} - with: - name: darwin-framework-derived-data - path: ~/Library/Developer/Xcode/DerivedData/**/*.ips - retention-days: 5 + - name: Collect crash logs + run: | + mkdir -p /tmp/darwin/framework-tests + find ~/Library/Developer/Xcode/DerivedData /Library/Logs/DiagnosticReports -name '*.ips' -print0 | xargs -0 -J % cp % /tmp/darwin/framework-tests - name: Uploading log files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 01626726e0b9af..7eb09b79c4c22d 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -76,11 +76,11 @@ if (_chip_defaults.custom_toolchain != "") { } else { _target_compiler = "gcc" } - _default_toolchain = "${_build_overrides.build_root}/toolchain/linux:linux_${target_cpu}_${_target_compiler}" -} else if (target_os == host_os && - (target_cpu == host_cpu || - (target_cpu == "arm64e" && host_cpu == "arm64"))) { +} else if (host_os == "mac" && (target_os == "mac" || target_os == "ios")) { + # On Mac the host toolchain supports building for all mac and ios targets + _default_toolchain = host_toolchain +} else if (target_os == host_os && target_cpu == host_cpu) { _default_toolchain = host_toolchain } else if (target_os == "freertos") { if (_chip_defaults.is_clang) { @@ -113,9 +113,6 @@ if (_chip_defaults.custom_toolchain != "") { } else { assert(false, "Unsupported target_cpu: ${current_cpu}") } -} else if (target_os == "ios") { - _default_toolchain = - "${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}" } else if (target_os == "tizen") { _default_toolchain = "${_build_overrides.build_root}/toolchain/tizen:tizen_${target_cpu}" diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 7ada1348f797b4..df85153297cad7 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -343,7 +343,7 @@ config("cosmetic_default") { } config("runtime_default") { - if (is_clang) { + if (is_clang) { # Using Pigweed clang instead of Darwin host clang configs = [ "$dir_pw_toolchain/host_clang:no_system_libcpp", "$dir_pw_toolchain/host_clang:xcode_sysroot", @@ -402,7 +402,7 @@ config("sanitize_address") { ] ldflags = cflags - if (target_os == "mac" || target_os == "ios") { + if ((target_os == "mac" || target_os == "ios") && !is_clang) { defines += [ "_LIBCPP_HAS_NO_ASAN" ] } } diff --git a/build/toolchain/ios/BUILD.gn b/build/toolchain/ios/BUILD.gn deleted file mode 100644 index c86dfcb83b38d5..00000000000000 --- a/build/toolchain/ios/BUILD.gn +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2020 The Pigweed Authors -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/build.gni") - -import("${build_root}/toolchain/gcc_toolchain.gni") - -gcc_toolchain("ios_arm") { - toolchain_args = { - current_os = "ios" - current_cpu = "arm" - is_clang = false - } -} - -gcc_toolchain("ios_arm64") { - toolchain_args = { - current_os = "ios" - current_cpu = "arm64" - is_clang = false - } -} - -gcc_toolchain("ios_x64") { - toolchain_args = { - current_os = "ios" - current_cpu = "x86_64" - is_clang = false - } -} diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 9dcbddbbfd8cbf..6228643a958f81 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -139,6 +139,7 @@ action("build-darwin-framework") { config("config") { include_dirs = [ ".", + "include", "${chip_root}/examples/common", "${chip_root}/examples/darwin-framework-tool/commands/common", "${chip_root}/zzz_generated/darwin-framework-tool",