Flutter doesn't build for Linux

Hi Everyone.
I have a problem, I can’t run flutter app in clear Linux, because when I run command “Flutter run -d linux”, I have error that I don’t know what needs to be done to solve this error.

CMake Error at /usr/share/cmake-3.18/Modules/CMakeTestCXXCompiler.cmake:59 (message):
  The C++ compiler                                                      
                                                                        
    "/usr/bin/clang++"                                                  
                                                                        
  is not able to compile a simple test program.                         
                                                                        
  It fails with the following output:                                   
                                                                        
    Change Dir: /home/BadGuy/My practice/first/build/linux/release/CMakeFiles/CMakeTmp
                                                                        
    Run Build Command(s):/usr/bin/ninja cmTC_84ece && [1/2] Building CXX object CMakeFiles/cmTC_84ece.dir/testCXXCompiler.cxx.o
    FAILED: CMakeFiles/cmTC_84ece.dir/testCXXCompiler.cxx.o             
    /usr/bin/clang++   -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -Wa,-mbranches-within-32B-boundaries -fvisibility-inlines-hidden -Wl,--enable-new-dtags -MD -MT CMakeFiles/cmTC_84ece.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_84ece.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_84ece.dir/testCXXCompiler.cxx.o -c testCXXCompiler.cxx
    clang-10: warning: -Wl,-z: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,now: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,-z: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,relro: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,-sort-common: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,--enable-new-dtags: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,--enable-new-dtags: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: error: unsupported argument '-mbranches-within-32B-boundaries' to option 'Wa,'
    clang-10: warning: optimization flag '-ftree-loop-distribute-patterns' is not supported [-Wignored-optimization-argument]
    clang-10: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
    ninja: build stopped: subcommand failed.                            
                                                                        
                                                                        
                                                                        
                                                                        
                                                                        
  CMake will not be able to correctly generate this project.            
Call Stack (most recent call first):                                    
  CMakeLists.txt:2 (project)

report this bug to upstream

It looks like the clang++ compiler supports -mbranches-within-32B-boundaries directly. It doesn’t accept it as a Wa parameter. In other words, try removing the -Wa, before this parameter and run the compile again.

1 Like

I have the same issue when building googletest over conan. Is there maybe a problem with the clang that clearlinux provides? Because I can not find the issue elsewhere.How can I remove the Wa? It seems to come from cmake itself. This is my log:

$ CC=clang CXX=clang++ conan install $CI_PROJECT_DIR -if $BUILD_DIR -s compiler=clang -s compiler.version=10 -s compiler.libcxx=libstdc++11 --build missing
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
gtest/1.10.0: WARN: Package binary is corrupted, removing: def9bf6e03568b3736845f4591358d37ed3dd921
conanfile.txt: Installing package
Requirements
    gtest/1.10.0 from 'conan-center' - Cache
Packages
    gtest/1.10.0:def9bf6e03568b3736845f4591358d37ed3dd921 - Build
Installing (downloading, building) binaries...
gtest/1.10.0: WARN: Build folder is dirty, removing it: /home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921
gtest/1.10.0: Copying sources to build folder
gtest/1.10.0: Building your package in /home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921
gtest/1.10.0: Generator cmake created conanbuildinfo.cmake
gtest/1.10.0: Calling build()
-- The C compiler identification is Clang 10.0.1
-- The CXX compiler identification is Clang 10.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang - broken
CMake Error at /usr/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler
    "/usr/bin/clang"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: /home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake cmTC_3d04c/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_3d04c.dir/build.make CMakeFiles/cmTC_3d04c.dir/build
    gmake[1]: Entering directory '/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_3d04c.dir/testCCompiler.c.o
    /usr/bin/clang   -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -Wa,-mbranches-within-32B-boundaries  -o CMakeFiles/cmTC_3d04c.dir/testCCompiler.c.o -c /home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-10: warning: -Wl,-z: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,now: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,-z: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,relro: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,-sort-common: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: warning: -Wl,--enable-new-dtags: 'linker' input unused [-Wunused-command-line-argument]
    clang-10: error: unsupported argument '-mbranches-within-32B-boundaries' to option 'Wa,'
    clang-10: warning: optimization flag '-ftree-loop-distribute-patterns' is not supported [-Wignored-optimization-argument]
    clang-10: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
    gmake[1]: *** [CMakeFiles/cmTC_3d04c.dir/build.make:85: CMakeFiles/cmTC_3d04c.dir/testCCompiler.c.o] Error 1
    gmake[1]: Leaving directory '/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:140: cmTC_3d04c/fast] Error 2
    
    
  
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeOutput.log".
See also "/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921/CMakeFiles/CMakeError.log".
gtest/1.10.0: 
gtest/1.10.0: ERROR: Package 'def9bf6e03568b3736845f4591358d37ed3dd921' build failed
gtest/1.10.0: WARN: Build folder /home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921
ERROR: gtest/1.10.0: Error in build() method, line 58
	cmake = self._configure_cmake()
while calling '_configure_cmake', line 52
	cmake.configure()
	ConanException: Error 1 while executing cd '/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="10" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++11" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/home/alfa/.conan/data/gtest/1.10.0/_/_/package/def9bf6e03568b3736845f4591358d37ed3dd921" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DBUILD_GMOCK="True" -DGTEST_NO_MAIN="False" -Dgtest_hide_internal_symbols="False" -Wno-dev '/home/alfa/.conan/data/gtest/1.10.0/_/_/build/def9bf6e03568b3736845f4591358d37ed3dd921'
Cleaning up file based variables
00:00
ERROR: Job failed: exit status 1

check CFLAGS CXXFLAGS

I can not check the flags because they are coming from /usr/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake

at least you can change that file if you’re sure the issue arises from it