From b789ef5dd0bb47536d3d67b674429f508b87616c Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Tue, 18 Nov 2025 12:44:38 -0600 Subject: [PATCH 1/3] [native_toolchain_c] Fix clang compiler search + tools for Swiftly Swiftly proxies commands to some of the tools that ship with Swift distributions, including: `clang`, `ld.lld`, and other tools. Therefore, such tools are symlinks to `swiftly`, and running `swiftly` directly would therefore not work when bundling assets. This PR adds support for using `package:native_toolchain_c` on macOS with Swiftly installed, defaulting to the user's default installation of `ar` and `ld` where applicable. --- .../lib/src/native_toolchain/apple_clang.dart | 15 +++++++++++++++ .../lib/src/tool/tool_resolver.dart | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 9c7eb4c99e..67dcf49619 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:code_assets/code_assets.dart'; + import '../tool/tool.dart'; import '../tool/tool_resolver.dart'; @@ -31,6 +33,10 @@ final Tool appleAr = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ar'), ), + PathToolResolver( + toolName: 'Apple archiver', + executableName: OS.current.executableFileName('ar'), + ), ]), ); @@ -43,6 +49,15 @@ final Tool appleLd = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ld'), ), + PathToolResolver( + toolName: 'Apple linker', + executableName: OS.current.executableFileName('ld'), + ), + RelativeToolResolver( + toolName: 'Apple linker', + wrappedResolver: appleClang.defaultResolver!, + relativePath: Uri.file(OS.current.executableFileName('ld.lld')), + ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 0603703181..ec12fb57d5 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -65,8 +66,10 @@ class PathToolResolver extends ToolResolver { if (process.exitCode == 0) { final file = File(LineSplitter.split(process.stdout).first); final uri = File(await file.resolveSymbolicLinks()).uri; - if (uri.pathSegments.last == 'llvm') { + if (uri.pathSegments.last == 'llvm' || + uri.pathSegments.last == 'swiftly') { // https://github.com/dart-lang/native/issues/136 + // https://github.com/dart-lang/native/issues/2792 return file.uri; } return uri; From a367d17582bc1064bd9e9ad8151900a1a2c212b3 Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Wed, 19 Nov 2025 08:55:13 -0600 Subject: [PATCH 2/3] Resolved tool_resolver.dart unnecessary import --- pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index ec12fb57d5..84fcdf679e 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:async'; import 'dart:convert'; import 'dart:io'; From 0ff54c46b2c41aa0d8078153a4bb52e2dcbfe2d4 Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Wed, 19 Nov 2025 09:11:22 -0600 Subject: [PATCH 3/3] Added CHANGELOG.md update and version bump --- pkgs/native_toolchain_c/CHANGELOG.md | 5 +++++ pkgs/native_toolchain_c/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/CHANGELOG.md b/pkgs/native_toolchain_c/CHANGELOG.md index 16151e6f64..916abb3089 100644 --- a/pkgs/native_toolchain_c/CHANGELOG.md +++ b/pkgs/native_toolchain_c/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.17.4 + +- Fixed resolution of C compiler and tools on macOS when `swiftly` is installed. +- Broaden compiler tool discovery on macOS. + ## 0.17.3 - Bump `package:hooks` and `package:code_assets`to 1.0.0. diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index d0f58df9a8..1a3e16f778 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -1,7 +1,7 @@ name: native_toolchain_c description: >- A library to invoke the native C compiler installed on the host machine. -version: 0.17.3 +version: 0.17.4 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c topics: