1# Copyright 2020 The SwiftShader Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set(ROOT_PROJECT_COMPILE_OPTIONS 16 ${SWIFTSHADER_COMPILE_OPTIONS} 17 ${WARNINGS_AS_ERRORS} 18) 19 20set(REACTOR_SRC_FILES 21 Debug.cpp 22 Debug.hpp 23 EmulatedIntrinsics.cpp 24 EmulatedIntrinsics.hpp 25 ExecutableMemory.cpp 26 ExecutableMemory.hpp 27 Nucleus.hpp 28 OptimalIntrinsics.cpp 29 OptimalIntrinsics.hpp 30 Print.hpp 31 Reactor.cpp 32 Reactor.hpp 33 ReactorDebugInfo.cpp 34 ReactorDebugInfo.hpp 35 Routine.hpp 36) 37 38set(SUBZERO_SRC_FILES 39 Optimizer.cpp 40 SubzeroReactor.cpp 41) 42 43set(LLVM_SRC_FILES 44 CPUID.cpp 45 CPUID.hpp 46 LLVMAsm.cpp 47 LLVMAsm.hpp 48 LLVMJIT.cpp 49 LLVMReactor.cpp 50 LLVMReactor.hpp 51 LLVMReactorDebugInfo.cpp 52 LLVMReactorDebugInfo.hpp 53) 54 55if(REACTOR_EMIT_DEBUG_INFO) 56 if(WIN32) 57 # Boost stacktrace uses COM on Windows. 58 # On Windows, cache COM instances in TLS for performance. 59 list(APPEND REACTOR_PRIVATE_COMPILE_DEFINITIONS "BOOST_STACKTRACE_USE_WINDBG_CACHED") 60 else() 61 # Boost stacktrace uses libbacktrace 62 list(APPEND REACTOR_PRIVATE_COMPILE_DEFINITIONS "BOOST_STACKTRACE_USE_BACKTRACE") 63 list(APPEND REACTOR_PRIVATE_LINK_LIBRARIES libbacktrace) 64 endif() 65 66 list(APPEND REACTOR_PRIVATE_LINK_LIBRARIES Boost::boost) 67endif(REACTOR_EMIT_DEBUG_INFO) 68 69# Enable instrumentation of Reactor routines for MemorySanitizer builds (LLVM backend). 70# TODO(b/155148722): Remove when unconditionally instrumenting for all build systems. 71if(REACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION) 72 list(APPEND REACTOR_PUBLIC_COMPILE_DEFINITIONS "REACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION") 73endif() 74 75list(APPEND REACTOR_PRIVATE_COMPILE_DEFINITIONS "REACTOR_ANONYMOUS_MMAP_NAME=swiftshader_jit") 76 77# SubzeroReactor library 78 79add_library(ReactorSubzero STATIC EXCLUDE_FROM_ALL 80 ${REACTOR_SRC_FILES} 81 ${SUBZERO_SRC_FILES} 82) 83 84set_target_properties(ReactorSubzero PROPERTIES 85 POSITION_INDEPENDENT_CODE 1 86 FOLDER "Reactor" 87) 88 89target_include_directories(ReactorSubzero 90 PUBLIC 91 . 92) 93 94target_compile_definitions(ReactorSubzero 95 PUBLIC 96 ${REACTOR_PUBLIC_COMPILE_DEFINITIONS} 97 PRIVATE 98 ${REACTOR_PRIVATE_COMPILE_DEFINITIONS} 99) 100 101target_compile_options(ReactorSubzero 102 PRIVATE 103 ${ROOT_PROJECT_COMPILE_OPTIONS} 104) 105 106target_link_libraries(ReactorSubzero 107 PRIVATE 108 subzero 109 marl 110 ${REACTOR_PRIVATE_LINK_LIBRARIES} 111) 112 113 114# ReactorLLVM library 115 116add_library(ReactorLLVM STATIC EXCLUDE_FROM_ALL 117 ${REACTOR_SRC_FILES} 118 ${LLVM_SRC_FILES} 119) 120 121set_target_properties(ReactorLLVM PROPERTIES 122 POSITION_INDEPENDENT_CODE 1 123 FOLDER "Reactor" 124) 125 126target_include_directories(ReactorLLVM 127 PUBLIC 128 . 129) 130 131target_compile_definitions(ReactorLLVM 132 PUBLIC 133 ${REACTOR_PUBLIC_COMPILE_DEFINITIONS} 134 PRIVATE 135 ${REACTOR_PRIVATE_COMPILE_DEFINITIONS} 136) 137 138target_compile_options(ReactorLLVM 139 PRIVATE 140 ${ROOT_PROJECT_COMPILE_OPTIONS} 141) 142 143target_link_libraries(ReactorLLVM 144 PRIVATE 145 llvm 146 ${REACTOR_PRIVATE_LINK_LIBRARIES} 147) 148