mirror of
				https://github.com/ton-blockchain/ton
				synced 2025-03-09 15:40:10 +00:00 
			
		
		
		
	Compiler -march fix for not supported arch (#444)
I think there is an issue with the way -march flag is handled in the
current build system.
It is set to native (heavy cpu specific optimizations) via TON_ARCH and it is never
checked if it is supported by the compiler.
That's what is causing all those issues with apple m1 builds or any
other arm system.
Without checking early, build will only fail at link stage.
Strict arch support checking is due.
1. Check if "-march=${TON_ARCH}" flag is supported by the compiler
   Adds it to CXX_FLAGS if al good
2. Otherwise if such flag is not supported but TON_ARCH is set to default we
   continue execution without setting march and leaving arch decisions to
   cmake build system
3. Otherwise user specified TON_ARCH intentionally and current arch is
   not supported by the compiler.
   Therefore we terminate build process immediately and let user know
   what's the matter.
Co-authored-by: Trinketer22 <trinketer22@localhost>
			
			
This commit is contained in:
		
							parent
							
								
									35d17249e6
								
							
						
					
					
						commit
						d11580dfb3
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -197,10 +197,13 @@ find_package(Threads REQUIRED)
 | 
			
		|||
find_package(ZLIB REQUIRED)
 | 
			
		||||
 | 
			
		||||
if (TON_ARCH AND NOT MSVC)
 | 
			
		||||
  CHECK_CXX_COMPILER_FLAG( "-march=${TON_ARCH}" COMPILER_OPT_ARCH_SUPPORTED )
 | 
			
		||||
  if (TON_ARCH STREQUAL "apple-m1")
 | 
			
		||||
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=${TON_ARCH}")	
 | 
			
		||||
  else()
 | 
			
		||||
  elseif(COMPILER_OPT_ARCH_SUPPORTED)
 | 
			
		||||
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${TON_ARCH}")
 | 
			
		||||
  elseif(NOT TON_ARCH STREQUAL "native")
 | 
			
		||||
    message(FATAL_ERROR "Compiler doesn't support arch ${TON_ARCH}")
 | 
			
		||||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
if (THREADS_HAVE_PTHREAD_ARG)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue