Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
snnn committed Jan 24, 2024
1 parent bcb0577 commit 6be25d6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,8 +1456,17 @@ def generate_build_tree(
cflags = None
cxxflags = None
ldflags = None
cudaflags = []
cudaflags = None
for config in configs:
cflags = []
cudaflags = []
if is_windows():
njobs = number_of_parallel_jobs(args)
if njobs > 1:
if args.parallel == 0:
cflags += ["/MP"]
else:
cflags += ["/MP%d" % njobs]
# Setup default values for cflags/cxxflags/ldflags.
# The values set here are purely for security and compliance purposes. ONNX Runtime should work fine without these flags.
if (
Expand All @@ -1467,13 +1476,7 @@ def generate_build_tree(
and not args.build_wasm
):
if is_windows():
cflags = ["/guard:cf", "/DWIN32", "/D_WINDOWS"]
njobs = number_of_parallel_jobs(args)
if njobs > 1:
if args.parallel == 0:
cflags += ["/MP"]
else:
cflags += ["/MP%d" % njobs]
cflags += ["/guard:cf", "/DWIN32", "/D_WINDOWS"]
if not args.use_gdk:
# Target Windows 10
cflags += [
Expand All @@ -1499,8 +1502,6 @@ def generate_build_tree(
if args.enable_address_sanitizer:
cflags += ["/fsanitize=address"]
cxxflags = cflags.copy()
if not args.disable_exceptions:
cxxflags += ["/EHsc"]
if args.use_cuda:
# On Windows, nvcc passes /EHsc to the host compiler by default.
cuda_compile_flags_str = ""
Expand Down Expand Up @@ -1558,6 +1559,8 @@ def generate_build_tree(
cxxflags = cflags.copy()
if args.use_cuda:
cudaflags = cflags.copy()
if cxxflags is None and cflags is not None and len(cflags) != 0:
cxxflags = cflags.copy()
config_build_dir = get_config_build_dir(build_dir, config)
os.makedirs(config_build_dir, exist_ok=True)
if args.use_tvm:
Expand All @@ -1572,7 +1575,7 @@ def generate_build_tree(
)
preinstalled_dir = Path(build_dir) / config
temp_cmake_args = cmake_args.copy()
if cflags is not None and cxxflags is not None:
if cflags is not None and cxxflags is not None and len(cflags) != 0 and len(cxxflags) != 0:
temp_cmake_args += [
"-DCMAKE_C_FLAGS=%s" % (" ".join(cflags)),
"-DCMAKE_CXX_FLAGS=%s" % (" ".join(cxxflags)),
Expand Down

0 comments on commit 6be25d6

Please sign in to comment.