Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ jobs:
run: .\.ci\env\bazelisk.ps1
- name: Bazel release
shell: cmd
env:
BAZEL_SH: 'C:\Program Files\Git\bin\bash.exe'
run: |
if not exist "%BAZEL_SH%" (
echo ERROR: Required Bazel shell not found: %BAZEL_SH%
exit /b 1
)
set PATH=C:\msys64\usr\bin;%PATH%
call .\oneapi\setvars.bat
call "%ONEAPI_ROOT%\setvars-vcvarsall.bat" %VS_VER%
Expand Down
4 changes: 2 additions & 2 deletions dev/bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ validation.
bazelisk.exe version
```

3. For `bazel test` on Windows, set `BAZEL_SH` to a Bash executable. Git for
Windows is sufficient.
3. Before running Bazel build, test, or analysis commands on Windows, set
`BAZEL_SH` to a Bash executable. Git for Windows is sufficient.
```bat
set BAZEL_SH=C:\Program Files\Git\bin\bash.exe
```
Expand Down
21 changes: 19 additions & 2 deletions dev/bazel/cc/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ _CPU_SUFFIX_TO_ISA_BACK_MAP = {
_CPU_SUFFIXES = _CPU_SUFFIX_TO_ISA_MAP.keys()
_CPU_ISA_IDS = _CPU_SUFFIX_TO_ISA_MAP.values()

_MSVC_CPU_FLAGS = {
"sse2": [],
"avx2": ["/arch:AVX2"],
# Match dev/make/compiler_definitions/vc.mkl.32e.mk: MSVC's skx
# objects use the AVX2 code-generation target.
"avx512": ["/arch:AVX2"],
}

def _get_cpu_compile_kwargs(toolchain, cpu, kwargs):
if toolchain.compiler != "msvc-cl":
return kwargs
cpu_kwargs = dict(kwargs)
cpu_kwargs["user_compile_flags"] = (
kwargs.get("user_compile_flags", []) + _MSVC_CPU_FLAGS[cpu]
)
return cpu_kwargs

def _categorize_sources(source_files, cpu_files_supported = True,
fpt_files_supported = True):
fpt_cpu_files_supported = cpu_files_supported and fpt_files_supported
Expand Down Expand Up @@ -217,7 +234,7 @@ def _compile(name, ctx, toolchain, feature_config, compilation_contexts=[],
sources_by_category.cpu_files),
local_defines = local_defines + cpu_defines[cpu],
compilation_contexts = dep_compilation_contexts,
**kwargs,
**_get_cpu_compile_kwargs(toolchain, cpu, kwargs),
)
compilation_contexts.append(compilation_context)
compilation_outputs.append(compulation_output)
Expand All @@ -231,7 +248,7 @@ def _compile(name, ctx, toolchain, feature_config, compilation_contexts=[],
srcs = sources_by_category.fpt_cpu_files,
local_defines = local_defines + cpu_defines[cpu] + fpt_defines[fpt],
compilation_contexts = dep_compilation_contexts,
**kwargs,
**_get_cpu_compile_kwargs(toolchain, cpu, kwargs),
)
compilation_contexts.append(compilation_context)
compilation_outputs.append(compulation_output)
Expand Down
18 changes: 13 additions & 5 deletions dev/bazel/config/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,20 @@ dump_config_info = rule(

def _detect_cpu_extension(repo_ctx):
cpudetect_src = repo_ctx.path(repo_ctx.attr._cpudetect_src)
cpudetect_exe = repo_ctx.path("cpudetect")
is_windows = "windows" in repo_ctx.os.name
cpudetect_exe = repo_ctx.path("cpudetect.exe" if is_windows else "cpudetect")
repo_ctx.report_progress("Compile cpu-detector")
compile_result = repo_ctx.execute([
"g++", "-pedantic", "-Wall", "-std=c++11",
cpudetect_src, "-o{}".format(cpudetect_exe),
])
if is_windows:
compile_command = [
"cl", "/nologo", "/EHsc", "/std:c++14",
cpudetect_src, "/Fe:{}".format(cpudetect_exe),
]
else:
compile_command = [
"g++", "-pedantic", "-Wall", "-std=c++11",
Comment thread
napetrov marked this conversation as resolved.
Outdated
cpudetect_src, "-o{}".format(cpudetect_exe),
]
compile_result = repo_ctx.execute(compile_command)
if compile_result.return_code != 0:
utils.warn("Cannot compile cpu-detector:\n" +
compile_result.stderr + "\n" +
Expand Down
7 changes: 5 additions & 2 deletions dev/bazel/flags.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ lnx_cc_flags = {
# use MSVC-style spellings. Mirrors dev/make/compiler_definitions/{icx,dpcpp}.mkl.32e.mk
# (COMPILER.win.icx / COMPILER.win.dpcpp).
win_icx_common_flags = [
"-MD",
"-nologo",
"-WX",
"-Qopenmp-simd",
Expand Down Expand Up @@ -122,7 +121,11 @@ def get_cpu_flags(arch_id, os_id, compiler_id):
if compiler_id == "gcc":
sse2 = ["-march=nocona"]
avx2 = ["-march=haswell"]
avx512 = ["-march=haswell"]
avx512 = ["-march=skylake-avx512"]
elif compiler_id == "clang":
sse2 = ["-march=nocona"]
avx2 = ["-march=haswell"]
avx512 = ["-march=skylake-avx512"]
elif compiler_id in ["icx", "icpx"]:
# icx on Windows accepts -march like its Linux counterpart.
sse2 = ["-march=nocona"]
Expand Down
17 changes: 17 additions & 0 deletions dev/bazel/toolchains/cc_toolchain_config_win.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ def _impl(ctx):
pedantic_feature = feature(name = "pedantic")
dbg_feature = feature(name = "dbg")
opt_feature = feature(name = "opt")
runtime_library_feature = feature(
name = "runtime_library",
enabled = True,
flag_sets = [
flag_set(
actions = all_compile_actions,
flag_groups = [flag_group(flags = ["-MDd"])],
with_features = [with_feature_set(features = ["dbg"])],
),
flag_set(
actions = all_compile_actions,
flag_groups = [flag_group(flags = ["-MD"])],
with_features = [with_feature_set(not_features = ["dbg"])],
),
],
)
# Windows PE/COFF objects have no PIC/non-PIC distinction, so we do not
# register a `supports_pic` feature. Matches rules_cc's MSVC auto-config
# and keeps `cc_common.compile` from emitting both variants (which the
Expand Down Expand Up @@ -712,6 +728,7 @@ def _impl(ctx):
pedantic_feature,
dbg_feature,
opt_feature,
runtime_library_feature,
supports_dynamic_linker_feature,
do_not_link_dynamic_dependencies_feature,
default_compile_flags_feature,
Expand Down
9 changes: 6 additions & 3 deletions dev/bazel/toolchains/cc_toolchain_lnx.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ def _find_tools(repo_ctx, reqs):
cc_link_path = _create_dynamic_link_wrapper(repo_ctx, "cc", cc_path)
dpcc_link_path = _create_dynamic_link_wrapper(repo_ctx, "dpc", dpcc_path)
if dpcpp_found:
#The llvm-ar tool is used because bazel prepended directory names with +
#which caused issues with the default gnu ar tool on REHL. Since icx is clang based we can use the llvm-ar tool.
ar_path = cc_path[:-3] + "compiler/llvm-ar"
# The llvm-ar tool is used because Bazel prepends directory names with +,
# which caused issues with GNU ar on RHEL. Derive it from the DPC++
# compiler, not from the unrelated host C/C++ compiler.
ar_path = paths.join(paths.dirname(dpcc_path), "compiler", "llvm-ar")
if not repo_ctx.path(ar_path).exists:
auto_configure_fail("Cannot find DPC++ archiver at {}".format(ar_path))

ar_merge_path = _create_ar_merge_tool(repo_ctx, ar_path)

Expand Down
2 changes: 1 addition & 1 deletion dev/make/compiler_definitions/gnu.32e.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ link.dynamic.mac.gnu = $(link.dynamic.all.gnu)
p4_OPT.gnu = $(-Q)march=nocona
mc3_OPT.gnu = $(-Q)march=corei7
avx2_OPT.gnu = $(-Q)march=haswell
skx_OPT.gnu = $(-Q)march=skylake
skx_OPT.gnu = $(-Q)march=skylake-avx512
Loading