Set up architecture-dependent optimization flags. Also append CC optimization flags to bazel.rc.. Args: environ_cp: copy of the os.environ.
(environ_cp)
| 507 | |
| 508 | |
| 509 | def set_cc_opt_flags(environ_cp): |
| 510 | """Set up architecture-dependent optimization flags. |
| 511 | |
| 512 | Also append CC optimization flags to bazel.rc.. |
| 513 | |
| 514 | Args: |
| 515 | environ_cp: copy of the os.environ. |
| 516 | """ |
| 517 | if is_ppc64le(): |
| 518 | # gcc on ppc64le does not support -march, use mcpu instead |
| 519 | default_cc_opt_flags = '-mcpu=native' |
| 520 | elif is_windows(): |
| 521 | default_cc_opt_flags = '/arch:AVX' |
| 522 | else: |
| 523 | default_cc_opt_flags = '-march=native -Wno-sign-compare' |
| 524 | question = ('Please specify optimization flags to use during compilation when' |
| 525 | ' bazel option "--config=opt" is specified [Default is %s]: ' |
| 526 | ) % default_cc_opt_flags |
| 527 | cc_opt_flags = get_from_env_or_user_or_default(environ_cp, 'CC_OPT_FLAGS', |
| 528 | question, default_cc_opt_flags) |
| 529 | for opt in cc_opt_flags.split(): |
| 530 | write_to_bazelrc('build:opt --copt=%s' % opt) |
| 531 | # It should be safe on the same build host. |
| 532 | if not is_ppc64le() and not is_windows(): |
| 533 | write_to_bazelrc('build:opt --host_copt=-march=native') |
| 534 | write_to_bazelrc('build:opt --define with_default_optimizations=true') |
| 535 | |
| 536 | |
| 537 | def set_tf_cuda_clang(environ_cp): |
no test coverage detected