Add /Qspectre compiler flags (#671)

* Add /Qspectre compiler flags

* Added /Zi. Seems required for binskim to pass

* reset cmake min to 3.11 for nuget pipeline

* Reset CMake min to 3.13
This commit is contained in:
jignparm 2019-03-28 11:08:05 -07:00 committed by GitHub
parent f6a77617c1
commit 36f5d008de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -150,6 +150,11 @@ if (MSVC)
SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
endif()
if (onnxruntime_ENABLE_QSPECTRE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre /guard:cf /Zi")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre /guard:cf /Zi")
SET(CMAKE_EXE_LINKER_FLAGS "/guard:cf /DYNAMICBASE")
endif()
else()
if(onnxruntime_BUILD_FOR_NATIVE_MACHINE)
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -march=native -mtune=native")

View file

@ -133,6 +133,7 @@ Use the individual flags to only run the specified stages.
parser.add_argument("--use_nuphar", action='store_true', help="Build with nuphar")
parser.add_argument("--use_tensorrt", action='store_true', help="Build with TensorRT")
parser.add_argument("--tensorrt_home", help="Path to TensorRT installation dir")
parser.add_argument("--enable_qspectre", action='store_true', help="Enable compiler option to compile with /Qspectre and /GUARD:CF")
parser.add_argument("--use_full_protobuf", action='store_true', help="Use the full protobuf library")
parser.add_argument("--disable_contrib_ops", action='store_true', help="Disable contrib ops (reduces binary size)")
return parser.parse_args()
@ -320,6 +321,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home
# By default - we currently support only cross compiling for ARM/ARM64 (no native compilation supported through this script)
"-Donnxruntime_CROSS_COMPILING=" + ("ON" if args.arm64 or args.arm else "OFF"),
"-Donnxruntime_BUILD_x86=" + ("ON" if args.x86 else "OFF"),
"-Donnxruntime_ENABLE_QSPECTRE=" + ("ON" if args.build_shared_lib and args.enable_qspectre else "OFF"),
"-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf else "OFF"),
"-Donnxruntime_DISABLE_CONTRIB_OPS=" + ("ON" if args.disable_contrib_ops else "OFF"),
]