Skip to content

Conversation

@levkropp
Copy link
Contributor

@levkropp levkropp commented May 6, 2025

[  +24 ms] CMake Error at /usr/share/cmake-3.28/Modules/CMakeDetermineCXXCompiler.cmake:48 (message):
[   +1 ms]   Could not find compiler set in environment variable CXX:
[        ]   clang++.
[        ] Call Stack (most recent call first):
[        ]   CMakeLists.txt:3 (project)
[        ] 
[        ] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
[        ] -- Configuring incomplete, errors occurred!
[   +6 ms] Building Linux application... (completed in 31ms)
[        ] "flutter linux" took 544ms.
[   +1 ms] Unable to generate build files
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _runCmake (package:flutter_tools/src/linux/build_linux.dart:174:5)
           <asynchronous suspension>
           #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:81:5)
           <asynchronous suspension>
           #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:87:5)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1450:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:421:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:131:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>

Clang is needed to build the Flutter GUI (tested on Ubuntu 25.04 and 24.04) so it should be included in the debian/control dependencies file. This was noticed by @Sploder12 on a PR to update the tray_menu flutter plugin and reproduced on my end.

This pull request updates the build dependencies for the multipass project by adding clang to the debian/control file.

Build dependency update:

  • debian/control: Added clang to the Build-Depends list to ensure it is available during the build process.

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.50%. Comparing base (b086fb7) to head (de03b09).
⚠️ Report is 405 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4073   +/-   ##
=======================================
  Coverage   89.50%   89.50%           
=======================================
  Files         259      259           
  Lines       14740    14740           
=======================================
  Hits        13193    13193           
  Misses       1547     1547           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we instead make it honor the compiler that is set for the whole build?

@levkropp
Copy link
Contributor Author

levkropp commented May 6, 2025

Can't we instead make it honor the compiler that is set for the whole build?

I don't think so. The Flutter engine on Linux is compiled with clang and from what I understand, the GTK integration layer (my_application.cc) and Flutter plugins need to be compiled with the same toolchain as the Flutter engine

The Flutter engine's build system is primarily designed to work with Clang/LLVM. This is evident from the engine's DEPS file, which specifies Clang toolchains for various platforms, including Linux. For instance, on Linux x64, the build system expects Clang to be located at src/flutter/buildtools/linux-x64/clang

People have tried to build Flutter with GCC to make it work on a raspberry pi, but this isn't supported officially: https://medium.com/flutter/flutter-on-raspberry-pi-mostly-from-scratch-2824c5e7dcb1

@levkropp
Copy link
Contributor Author

levkropp commented May 6, 2025

On a fresh 24.04 instance after following the README's instructions, I also had to install ninja with sudo apt install ninja-build to build the GUI. I was seeing this error

[   +2 ms] executing: [../../../build/bin/linux/x64/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLUTTER_TARGET_PLATFORM=linux-x64 /home/ubuntu/multipass/src/client/gui/linux
[  +14 ms] CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
[        ] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
[        ] -- Configuring incomplete, errors occurred!
[   +6 ms] Building Linux application... (completed in 19ms)
[        ] "flutter linux" took 12,591ms.
[   +2 ms] Unable to generate build files
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _runCmake (package:flutter_tools/src/linux/build_linux.dart:174:5)
           <asynchronous suspension>
           #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:81:5)
           <asynchronous suspension>
           #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:87:5)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1450:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:421:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:131:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>

Perhaps now would be a good time to also add ninja-build to debian/control if this is reproduced by others

@ricab
Copy link
Collaborator

ricab commented May 7, 2025

OK, so this is not actually tied to the Ubuntu version, you just happened to verify it on 24.04 and above, correct? CI images have clang by default, so it would work there. And I suppose we all had clang installed so far...

@ricab
Copy link
Collaborator

ricab commented May 7, 2025

OK I just found it in their documentation:

To develop Linux apps, use the following command to install these packages:
clang, cmake, ninja-build, pkg-config, libgtk-3-dev, libstdc++-12-dev

I hate that it forces things on people like this, but that's Flutter alright.

@ricab
Copy link
Collaborator

ricab commented May 7, 2025

So yeah, I guess we need to install ninja too. We have the option to disable building the GUI in CMake, so If this ever becomes annoying, we can split this debian/control out into the GUI's folder and add it to the instructions as a separate step.

@levkropp
Copy link
Contributor Author

levkropp commented May 7, 2025

OK, so this is not actually tied to the Ubuntu version, you just happened to verify it on 24.04 and above, correct?

Yes, this is tied to Flutter, and I have verified it on both 24.04 and 25.04

So yeah, I guess we need to install ninja too.

I'll add a commit for that to this PR since it's in the scope of adding Flutter dependencies

Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I just built this in a clean Jammy environment and it worked fine.

@levkropp levkropp changed the title Add clang to debian/control Add clang and ninja-build to debian/control May 8, 2025
@levkropp levkropp requested a review from Sploder12 May 8, 2025 12:59
Copy link
Contributor

@Sploder12 Sploder12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, worked for me on a fresh 24.04 install.

@ricab ricab enabled auto-merge May 8, 2025 18:01
@ricab
Copy link
Collaborator

ricab commented May 8, 2025

Hey @levkropp, I am afraid this will need a rebase before it can merge.

@levkropp levkropp force-pushed the add-clang-dependency branch from 441b062 to de03b09 Compare May 8, 2025 22:40
@ricab ricab added this pull request to the merge queue May 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks May 9, 2025
@ricab ricab added this pull request to the merge queue May 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks May 9, 2025
@levkropp levkropp added this pull request to the merge queue May 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks May 9, 2025
@ricab ricab added this pull request to the merge queue May 9, 2025
@ricab
Copy link
Collaborator

ricab commented May 9, 2025

CLA and docs aren't triggering on merge_groups. Removing them from branch protections for now, but I opened #4081 for later.

Merged via the queue into main with commit 3d1d7f6 May 10, 2025
19 checks passed
@ricab ricab deleted the add-clang-dependency branch May 10, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants