mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 07:31:28 +00:00
Add support for Bazel builds on Windows with clang-cl
.
Adds basic `--config=clang-cl` to set up the basic options needed, and then fix a number of issues that surface in Windows builds for me. With these fixes, `//llvm/...` builds cleanly. One unittest still fails, but its just due to running out of stack space due to creating a large number of short-lived stack variables. The test should probably be decomposed into a set of tests (`LegalizerInfoTest::RuleSets`), but that seemed like too invasive of a change here and with everything building cleanly this isn't disrupting me experimenting with Windows builds. Some parts of `//clang/...` builds, but that will require more work.
This commit is contained in:
parent
947e14be98
commit
112dc16014
@ -69,9 +69,18 @@ build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading
|
||||
build:generic_gcc --copt=-Werror --host_copt=-Werror
|
||||
|
||||
###############################################################################
|
||||
# Windows specific flags for building with VC.
|
||||
# Generic Windows flags common to both MSVC and Clang.
|
||||
###############################################################################
|
||||
|
||||
# Yay for security warnings. Boo for non-standard.
|
||||
build:windows --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
|
||||
|
||||
###############################################################################
|
||||
# Windows specific flags for building with MSVC.
|
||||
###############################################################################
|
||||
|
||||
build:msvc --config=windows
|
||||
|
||||
build:msvc --copt=/WX --host_copt=/WX # Treat warnings as errors...
|
||||
# ...but disable the ones that are violated
|
||||
build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once
|
||||
@ -87,8 +96,30 @@ build:msvc --linkopt=/WX --host_linkopt=/WX # Treat warnings as errors...
|
||||
# ...but disable the ones that are violated.
|
||||
build:msvc --linkopt=/IGNORE:4001 --host_linkopt=/IGNORE:4001 # no object files
|
||||
|
||||
# Yay for security warnings. Boo for non-standard.
|
||||
build:msvc --copt=/D_CRT_SECURE_NO_WARNINGS --host_copt=/D_CRT_SECURE_NO_WARNINGS
|
||||
###############################################################################
|
||||
# Options for Windows `clang-cl` builds.
|
||||
###############################################################################
|
||||
|
||||
# We just start with the baseline Windows config as `clang-cl` doesn't accept
|
||||
# some of the generic Clang flags.
|
||||
build:clang-cl --config=windows
|
||||
|
||||
# Switch from MSVC to the `clang-cl` compiler.
|
||||
build:clang-cl --compiler=clang-cl
|
||||
|
||||
# C++14 standard version is required.
|
||||
build:clang-cl --cxxopt=/std:c++14 --host_cxxopt=/std:c++14
|
||||
|
||||
# Use Clang's internal warning flags instead of the ones that sometimes map
|
||||
# through to MSVC's flags.
|
||||
build:clang-cl --copt=/clang:-Wall --host_copt=/clang:-Wall
|
||||
build:clang-cl --copt=/clang:-Werror --host_copt=/clang:-Werror
|
||||
|
||||
# This doesn't appear to be enforced by any upstream bot.
|
||||
build:clang-cl --copt=/clang:-Wno-unused --host_copt=/clang:-Wno-unused
|
||||
|
||||
# There appears to be an unused constant in GoogleTest on Windows.
|
||||
build:clang-cl --copt=/clang:-Wno-unused-const-variable --host_copt=/clang:-Wno-unused-const-variable
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -29,7 +29,6 @@ cc_binary(
|
||||
copts = [
|
||||
"$(STACK_FRAME_UNLIMITED)",
|
||||
],
|
||||
linkopts = ["-ldl"],
|
||||
stamp = 0,
|
||||
deps = [
|
||||
"//llvm:Support",
|
||||
|
@ -3102,7 +3102,9 @@ cc_binary(
|
||||
name = "llvm-mca",
|
||||
srcs = glob([
|
||||
"tools/llvm-mca/*.cpp",
|
||||
"tools/llvm-mca/*.h",
|
||||
"tools/llvm-mca/Views/*.cpp",
|
||||
"tools/llvm-mca/Views/*.h",
|
||||
]),
|
||||
copts = llvm_copts,
|
||||
stamp = 0,
|
||||
|
@ -25,15 +25,17 @@ posix_defines = [
|
||||
r'LTDL_SHLIB_EXT=\".so\"',
|
||||
r'LLVM_PLUGIN_EXT=\".so\"',
|
||||
"LLVM_ENABLE_THREADS=1",
|
||||
"HAVE_SYSEXITS_H=1",
|
||||
"HAVE_UNISTD_H=1",
|
||||
"HAVE_STRERROR_R=1",
|
||||
"HAVE_DEREGISTER_FRAME=1",
|
||||
"HAVE_LIBPTHREAD=1",
|
||||
"HAVE_PTHREAD_GETNAME_NP=1",
|
||||
"HAVE_PTHREAD_SETNAME_NP=1",
|
||||
"HAVE_PTHREAD_GETSPECIFIC=1",
|
||||
"HAVE_PTHREAD_H=1",
|
||||
"HAVE_PTHREAD_SETNAME_NP=1",
|
||||
"HAVE_REGISTER_FRAME=1",
|
||||
"HAVE_DEREGISTER_FRAME=1",
|
||||
"HAVE_SETENV_R=1",
|
||||
"HAVE_STRERROR_R=1",
|
||||
"HAVE_SYSEXITS_H=1",
|
||||
"HAVE_UNISTD_H=1",
|
||||
]
|
||||
|
||||
linux_defines = posix_defines + [
|
||||
|
@ -174,7 +174,7 @@
|
||||
#define HAVE_PTHREAD_GETSPECIFIC 1
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#define HAVE_PTHREAD_H 1
|
||||
/* HAVE_PTHREAD_H defined in Bazel */
|
||||
|
||||
/* Have pthread_mutex_lock */
|
||||
#define HAVE_PTHREAD_MUTEX_LOCK 1
|
||||
@ -186,7 +186,7 @@
|
||||
/* HAVE_SBRK defined in Bazel */
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#define HAVE_SETENV 1
|
||||
/* HAVE_SETENV defined in Bazel */
|
||||
|
||||
/* Define to 1 if you have the `setrlimit' function. */
|
||||
#define HAVE_SETRLIMIT 1
|
||||
|
@ -112,7 +112,7 @@ cc_library(
|
||||
|
||||
cc_test(
|
||||
name = "codegen_tests",
|
||||
size = "small",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
[
|
||||
"CodeGen/*.cpp",
|
||||
@ -167,7 +167,7 @@ cc_test(
|
||||
|
||||
cc_test(
|
||||
name = "debuginfo_tests",
|
||||
size = "small",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
[
|
||||
"DebugInfo/DWARF/*.cpp",
|
||||
@ -219,7 +219,7 @@ cc_test(
|
||||
|
||||
cc_test(
|
||||
name = "execution_engine_mcjit_tests",
|
||||
size = "small",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
[
|
||||
"ExecutionEngine/MCJIT/*.cpp",
|
||||
@ -245,7 +245,7 @@ cc_test(
|
||||
|
||||
cc_test(
|
||||
name = "execution_engine_orc_tests",
|
||||
size = "small",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
[
|
||||
"ExecutionEngine/Orc/*.cpp",
|
||||
@ -381,7 +381,7 @@ cc_test(
|
||||
|
||||
cc_test(
|
||||
name = "mi_tests",
|
||||
size = "small",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
["MI/*.cpp"],
|
||||
allow_empty = False,
|
||||
@ -525,9 +525,10 @@ cc_test(
|
||||
],
|
||||
)
|
||||
|
||||
# Note that the name of this test is important as it is used in the test itself.
|
||||
cc_test(
|
||||
name = "support_tests",
|
||||
size = "small",
|
||||
name = "SupportTests",
|
||||
size = "medium",
|
||||
srcs = glob(
|
||||
[
|
||||
"Support/*.cpp",
|
||||
|
Loading…
Reference in New Issue
Block a user