mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 11:42:28 +00:00 
			
		
		
		
	[TravisCI][CMake] Add  Z3_C_EXAMPLES_FORCE_CXX_LINKER CMake option
				
					
				
			and propagate its value into the C API examples. This flag forces the C API examples to use the C++ compiler as the linker rather than the C compiler. This a workaround to avoid linking errors when building with UBSan.
This commit is contained in:
		
							parent
							
								
									64ee9f168d
								
							
						
					
					
						commit
						a9fcfc531b
					
				
					 5 changed files with 52 additions and 2 deletions
				
			
		|  | @ -7,6 +7,19 @@ else() | |||
|   set(EXTERNAL_PROJECT_BUILD_ALWAYS_ARG "") | ||||
| endif() | ||||
| 
 | ||||
| option(Z3_C_EXAMPLES_FORCE_CXX_LINKER | ||||
|   "Force C++ linker when building C example projects" OFF) | ||||
| 
 | ||||
| if (Z3_C_EXAMPLES_FORCE_CXX_LINKER) | ||||
|   # HACK: This is a workaround for UBSan. | ||||
|   message(STATUS "Forcing C++ linker to be used when building example C projects") | ||||
|   set(EXTERNAL_C_PROJ_USE_CXX_LINKER_ARG | ||||
|     "-DFORCE_CXX_LINKER=ON" | ||||
|   ) | ||||
| else() | ||||
|   set(EXTERNAL_C_PROJ_USE_CXX_LINKER_ARG "") | ||||
| endif() | ||||
| 
 | ||||
| ################################################################################ | ||||
| # Build example project using libz3's C API as an external project | ||||
| ################################################################################ | ||||
|  | @ -14,7 +27,9 @@ ExternalProject_Add(c_example | |||
|   DEPENDS libz3 | ||||
|   # Configure step | ||||
|   SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c" | ||||
|   CMAKE_ARGS "-DZ3_DIR=${CMAKE_BINARY_DIR}" | ||||
|   CMAKE_ARGS | ||||
|     "-DZ3_DIR=${CMAKE_BINARY_DIR}" | ||||
|     "${EXTERNAL_C_PROJ_USE_CXX_LINKER_ARG}" | ||||
|   # Build step | ||||
|   ${EXTERNAL_PROJECT_BUILD_ALWAYS_ARG} | ||||
|   BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/c_example_build_dir" | ||||
|  | @ -30,7 +45,9 @@ ExternalProject_Add(c_maxsat_example | |||
|   DEPENDS libz3 | ||||
|   # Configure step | ||||
|   SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/maxsat" | ||||
|   CMAKE_ARGS "-DZ3_DIR=${CMAKE_BINARY_DIR}" | ||||
|   CMAKE_ARGS | ||||
|     "-DZ3_DIR=${CMAKE_BINARY_DIR}" | ||||
|     "${EXTERNAL_C_PROJ_USE_CXX_LINKER_ARG}" | ||||
|   # Build step | ||||
|   ${EXTERNAL_PROJECT_BUILD_ALWAYS_ARG} | ||||
|   BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/c_maxsat_example_build_dir" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue