mirror of
				https://github.com/pytorch/pytorch.git
				synced 2025-11-04 16:04:58 +08:00 
			
		
		
		
	[inductor] optimize cflags for Windows. (#131980)
changes: 1. optimize cflags for Windows. Ref: https://github.com/pytorch/pytorch/blob/v2.4.0/torch/utils/cpp_extension.py#L215 Pull Request resolved: https://github.com/pytorch/pytorch/pull/131980 Approved by: https://github.com/jgong5, https://github.com/jansel
This commit is contained in:
		@ -366,14 +366,26 @@ def _get_cpp_std_cflag(std_num: str = "c++17") -> List[str]:
 | 
			
		||||
        return [f"std={std_num}"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _get_linux_cpp_cflags(cpp_compiler: str) -> List[str]:
 | 
			
		||||
    if not _IS_WINDOWS:
 | 
			
		||||
def _get_os_related_cpp_cflags(cpp_compiler: str) -> List[str]:
 | 
			
		||||
    if _IS_WINDOWS:
 | 
			
		||||
        cflags = [
 | 
			
		||||
            "wd4819",
 | 
			
		||||
            "wd4251",
 | 
			
		||||
            "wd4244",
 | 
			
		||||
            "wd4267",
 | 
			
		||||
            "wd4275",
 | 
			
		||||
            "wd4018",
 | 
			
		||||
            "wd4190",
 | 
			
		||||
            "wd4624",
 | 
			
		||||
            "wd4067",
 | 
			
		||||
            "wd4068",
 | 
			
		||||
            "EHsc",
 | 
			
		||||
        ]
 | 
			
		||||
    else:
 | 
			
		||||
        cflags = ["Wno-unused-variable", "Wno-unknown-pragmas"]
 | 
			
		||||
        if _is_clang(cpp_compiler):
 | 
			
		||||
            cflags.append("Werror=ignored-optimization-argument")
 | 
			
		||||
        return cflags
 | 
			
		||||
    else:
 | 
			
		||||
        return []
 | 
			
		||||
    return cflags
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _get_optimization_cflags() -> List[str]:
 | 
			
		||||
@ -439,7 +451,7 @@ def get_cpp_options(
 | 
			
		||||
        + _get_optimization_cflags()
 | 
			
		||||
        + _get_warning_all_cflag(warning_all)
 | 
			
		||||
        + _get_cpp_std_cflag()
 | 
			
		||||
        + _get_linux_cpp_cflags(cpp_compiler)
 | 
			
		||||
        + _get_os_related_cpp_cflags(cpp_compiler)
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    passthough_args.append(" ".join(extra_flags))
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user