-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Description
Steps to reproduce
CC @dcharkes, this is the last of the build-related problems I've run into for Native Assets (I think anyways...)
I'm happy to PR a fix for this, I just would like clarification on which of the 2 approaches listed below (or something else) we would like to go with in order to fix this.
Currently, CCompilerConfig is created this way on macOS:
flutter/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart
Lines 169 to 189 in 09387f2
| /// Flutter expects `xcrun` to be on the path on macOS hosts. | |
| /// | |
| /// Use the `clang`, `ar`, and `ld` that would be used if run with `xcrun`. | |
| Future<CCompilerConfig> cCompilerConfigMacOS() async { | |
| final ProcessResult xcrunResult = await globals.processManager.run(<String>[ | |
| 'xcrun', | |
| 'clang', | |
| '--version', | |
| ]); | |
| if (xcrunResult.exitCode != 0) { | |
| throwToolExit('Failed to find clang with xcrun:\n${xcrunResult.stderr}'); | |
| } | |
| final String installPath = LineSplitter.split( | |
| xcrunResult.stdout as String, | |
| ).firstWhere((String s) => s.startsWith('InstalledDir: ')).split(' ').last; | |
| return CCompilerConfig( | |
| compiler: Uri.file('$installPath/clang'), | |
| archiver: Uri.file('$installPath/ar'), | |
| linker: Uri.file('$installPath/ld'), | |
| ); | |
| } |
This breaks under Nix on macOS when the xcrun is provided via Nix, as ld + ar are not present at the location expected above.
Expected results
CCompilerConfig should be created via either:
- (Simpler + likely more correct) use
xcrun --find <binary-name>to findclang,ld, andar
i. Based on CLI experimentation this produces correct results in both Nix + non-Nix environments on macOS - Looking on
PATHfor clang and then use that to find its associatedld+ar(like is done on Linux)
Actual results
Build fails due to ld + ar not existing at the expected location.
Logs
Logs
ERROR: Build input for <project-name> contains errors
- BuildInput.config.code.cCompiler.linker (/nix/store/538b7kiga26rcxpqjspyn4r8wg32fmgh-clang-20.1.6/bin/ld) does not exist as a file.
- BuildInput.config.code.cCompiler.archiver (/nix/store/538b7kiga26rcxpqjspyn4r8wg32fmgh-clang-20.1.6/bin/ar) does not exist as a file.Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team