-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Correct windows build flags for clang-cl/msvc-cl under opt/fastbuild/dbg #13133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bec2a2d
b556bd5
47634e8
dd5d011
3eff4c5
77c7249
49cf93c
1155f5c
3520884
7ede887
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,8 @@ build --host_javabase=@bazel_tools//tools/jdk:remote_jdk11 | |
| build --javabase=@bazel_tools//tools/jdk:remote_jdk11 | ||
| build --enable_platform_specific_config | ||
|
|
||
| # Enable position independent code, this option is not supported on Windows and default on on macOS. | ||
| # Enable position independent code (this is the default on macOS and Windows) | ||
| # (Workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/421) | ||
| build:linux --copt=-fPIC | ||
| build:linux --cxxopt=-std=c++17 | ||
| build:linux --conlyopt=-fexceptions | ||
|
|
@@ -284,27 +285,27 @@ build:windows --define signal_trace=disabled | |
| build:windows --define hot_restart=disabled | ||
| build:windows --define tcmalloc=disabled | ||
| build:windows --define manual_stamp=manual_stamp | ||
| build:windows --cxxopt="/std:c++17" | ||
|
|
||
| # Should not be required after upstream fix to bazel, | ||
| # and already a no-op to linux/macos builds | ||
| # see issue https://github.com/bazelbuild/rules_foreign_cc/issues/301 | ||
| # TODO(wrowe,sunjayBhatia): Resolve bugs upstream in curl and rules_foreign_cc | ||
| # See issue https://github.com/bazelbuild/rules_foreign_cc/issues/301 | ||
| build:windows --copt="-DCARES_STATICLIB" | ||
| build:windows --copt="-DNGHTTP2_STATICLIB" | ||
| build:windows --copt="-DCURL_STATICLIB" | ||
| build:windows --cxxopt="/std:c++17" | ||
|
|
||
| # Required to work around build defects on Windows MSVC cl | ||
| # Unguarded gcc pragmas in quiche are not recognized by MSVC | ||
| build:msvc-cl --copt="/wd4068" | ||
| # Allows 'nodiscard' function return values to be discarded | ||
| build:msvc-cl --copt="/wd4834" | ||
| # Allows inline functions to be undefined | ||
| build:msvc-cl --copt="/wd4506" | ||
| build:msvc-cl --copt="-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING" | ||
| # Override any clang preference if building msvc-cl | ||
| # Drop the determinism feature (-DDATE etc are a no-op in msvc-cl) | ||
| build:msvc-cl --action_env=USE_CLANG_CL="" | ||
| build:msvc-cl --define clang_cl=0 | ||
| build:msvc-cl --features=-determinism | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this is needed? it wasn't here before?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Three things going on. Config msvc-cl is no longer strictly needed, those flags moved to bazel/envoy_*.bzl When specifically requesting msvc-cl, we will disable clang-cl even if it the default in the dev's environment We mark the build non-deterministic because the DATE and other timestamp overrides do absolutely nothing in msvc-cl, and that build cannot be deterministic. We are in a different, better situation with clang-cl, it is very noisy about overriding these intrinsic macros, but the reassignment takes place.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok sgtm |
||
|
|
||
| # Windows build behaviors when using clang-cl | ||
| build:clang-cl --action_env=USE_CLANG_CL=1 | ||
| build:clang-cl --define clang_cl=1 | ||
|
|
||
| # Required to work around Windows clang-cl build defects | ||
| # Ignore conflicting definitions of _WIN32_WINNT | ||
| # Overriding __TIME__ etc is problematic (and is actually an invalid no-op) | ||
| # Override determinism flags (DATE etc) is valid on clang-cl compiler | ||
| build:clang-cl --copt="-Wno-macro-redefined" | ||
| build:clang-cl --copt="-Wno-builtin-macro-redefined" | ||
| build:clang-cl --action_env=USE_CLANG_CL=1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
wrowe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| index ec1cfa782..0c5a72f00 100644 | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -42,0 +42,5 @@ | ||
| +# revert CMake bug triggered by curl's defined max CMake policy version, see https://gitlab.kitware.com/cmake/cmake/-/issues/21288 | ||
| +if(POLICY CMP0091) | ||
| + cmake_policy(SET CMP0091 OLD) | ||
| +endif() | ||
| + | ||
| @@ -249,3 +254,6 @@ | ||
| - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
| - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") | ||
| - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") | ||
| + foreach(build_suffix "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) | ||
| + set(flags_var CMAKE_C_FLAGS${build_suffix}) | ||
| + if("${${flags_var}}" MATCHES "/MD") | ||
| + string(REGEX REPLACE "/MD" "/MT" ${flags_var} "${${flags_var}}") | ||
| + endif() | ||
| + endforeach() | ||
| diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt | ||
| index 911c9096d..ba6af1bf1 100644 | ||
| --- a/lib/CMakeLists.txt | ||
| +++ b/lib/CMakeLists.txt | ||
| @@ -91,4 +91,0 @@ add_library( | ||
| -if(MSVC AND NOT BUILD_SHARED_LIBS) | ||
| - set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) | ||
| -endif() | ||
| - | ||
Uh oh!
There was an error while loading. Please reload this page.