8000 Improve ClangCL support by disabling, fixing warnings by alexreinking · Pull Request #5876 · halide/Halide · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve ClangCL support by disabling, fixing warnings #5876

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

Merged
merged 11 commits into from
Apr 7, 2021

Conversation

alexreinking
Copy link
Member
@alexreinking alexreinking commented Apr 2, 2021

Supersedes @emmenlau's #5858, which I guess didn't provide maintainers with write permissions to the PR branch.

Improves ClangCL support by disabling (or fixing) warnings its -Wall mode emits.

  • Removed a bunch of extra semicolons
  • Stopped passing linker script to ClangCL (which throws an unknown flag warning)
  • Be smarter about disabling introspection
  • Various code fixes (see my comments in review)
  • A bit of CMake clean-up near my edits.

@alexreinking alexreinking added the build Issues related to building Halide and with CI label Apr 2, 2021
@alexreinking alexreinking self-assigned this Apr 2, 2021
@alexreinking alexreinking added this to the v12.0.0 milestone Apr 2, 2021
@alexreinking alexreinking added the skip_buildbots Synonym for buildbot_test_nothing label Apr 2, 2021
@steven-johnson
Copy link
Contributor

Skipping buildbots because the changes have already been tested in the other PR and we don't test ClangCL on CI, anyway.

This will certainly break if we don't test it, but I guess that's ok for now ("best effort"). If we get better Windows testing capability it would be worth adding.

@alexreinking
Copy link
Member Author
alexreinking commented Apr 5, 2021

I'm wondering if a different approach here is appropriate... the only ClangCL-specific changes are:

  1. Disabling -Wall, which is smelly to me
  2. Disabling WITH_INTROSPECTION which could be solved outside of the buildsystem by sniffing _MSC_VER.

I wonder if a better approach is to fix/selectively disable warnings and disable introspection on MSVC-like compilers using the usual macros.

@steven-johnson -- any thoughts?

@alexreinking alexreinking marked this pull request as draft April 5, 2021 21:09
@steven-johnson
Copy link
Contributor

Disabling -Wall should never be necessary and is definitely a smell. (I overlooked this when I approved it.) Does ClangCL nto support it at all?

@alexreinking
Copy link
Member Author
alexreinking commented Apr 5, 2021

Disabling -Wall should never be necessary and is definitely a smell. (I overlooked this when I approved it.) Does ClangCL nto support it at all?

It does support -Wall, but it enables very, very many warnings. This is the new list of warnings to disable (some of these might be real or be easy to fix, I haven't dug deep):

-Wno-c++98-compat-pedantic
-Wno-c++98-compat
-Wno-cast-align
-Wno-comma
-Wno-deprecated-declarations
-Wno-documentation-unknown-command
-Wno-documentation
-Wno-double-promotion
-Wno-exit-time-destructors
-Wno-extra-semi-stmt
-Wno-extra-semi
-Wno-float-conversion
-Wno-float-equal
-Wno-global-constructors
-Wno-implicit-float-conversion
-Wno-implicit-int-conversion
-Wno-implicit-int-float-conversion
-Wno-missing-field-initializers
-Wno-missing-prototypes
-Wno-nonportable-system-include-path
-Wno-old-style-cast
-Wno-reserved-id-macro
-Wno-return-std-move-in-c++11
-Wno-shadow-field-in-constructor
-Wno-shadow-field
-Wno-shadow
-Wno-shorten-64-to-32
-Wno-sign-conversion
-Wno-switch-enum
-Wno-undef
-Wno-undefined-func-template
-Wno-unused-function
-Wno-unused-member-function
-Wno-unused-parameter
-Wno-unused-template

I wonder if clang-cl's -Wall is more of a -Weverything or even -Weverything -pedantic -Wextra -Weven_more_I_didnt_think_of.

Another wrinkle: ClangCL doesn't have exceptions enabled by default and it doesn't honor -fexceptions as a way of enabling them.

Comment on lines -286 to -287

return load;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. I wonder if this was a bad merge. Probably worth turning on this warning explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yow. I'm genuinely surprised this is merely a warning.

@@ -571,7 +571,7 @@ class LowerWarpShuffles : public IRMutator {

Expr wild = Variable::make(Int(32), "*");
vector<Expr> result;
int bits;
int bits = 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this isn't needed is extremely subtle: the function is_const_power_of_two_integer returns true iff it initializes bits. The first read of bits is guarded by short-circuit && below. ClangCL isn't clever enough to see this, and I don't blame it.

There's no downside to this (this is not performance-critical) and disabling uninitialized use warnings seems significantly worse.

return "";
#endif
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This emits an unreachable code warning.

@@ -529,7 +528,7 @@ struct TickStackEntry {
int line;
};

vector<TickStackEntry> tick_stack;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throws a warning about missing extern and that it should be static if module-local, which it is. No need to export this.

Comment on lines -1589 to 1594
#endif

#else
WasmModule wasm_module;
wasm_module.contents = new WasmModuleContents(module, arguments, fn_name, jit_externs, extern_deps);
return wasm_module;
#endif
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above: unreachable code.

@@ -1672,4 +1672,4 @@ Stmt vectorize_loops(const Stmt &stmt, const map<string, Function> &env, const T
}

} // namespace Internal
} // namespace Halide
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only file without a trailing newline.

@steven-johnson
Copy link
Contributor

I wonder if clang-cl's -Wall is more of a -Weverything or even -Weverything -pedantic -Wextra -Weven_more_I_didnt_think_of.

Ouch -- yeah, maybe it's intended to be equivalent of MSVC's warning-level-4, which is pretty insanely high IIRC.

Another wrinkle: ClangCL doesn't have exceptions enabled by default and it doesn't honor -fexceptions as a way of enabling them.

uh, what? how on earth would a clang-compatible(-ish) compiler omit this?

@alexreinking alexreinking changed the title Fix ClangCL Improve ClangCL support by disabling, fixing warnings Apr 6, 2021
@alexreinking alexreinking removed the skip_buildbots Synonym for buildbot_test_nothing label Apr 6, 2021
@alexreinking alexreinking marked this pull request as ready for review April 6, 2021 01:20
@@ -568,12 +568,12 @@ class Buffer {
Expr operator()(const Expr &first, Args... rest) const {
std::vector<Expr> args = {first, rest...};
return (*this)(args);
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, I'd actually love to enable whatever warnings complains about this, it's a minor pet peeve of mine

@steven-johnson
A36C Copy link
Contributor

Failures are unrelated (error in nightly LLVM13), ok to land

@alexreinking alexreinking merged commit ea76214 into master Apr 7, 2021
@alexreinking alexreinking deleted the bda_clang_build branch April 7, 2021 00:53
@alexreinking
Copy link
Member Author

Landing. Still need a way to reliably enable exceptions on ClangCL, but that can be done in another PR. This one's scope has crept far enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues related to building Halide and with CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0