Skip to content
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

Apply warning and error compile flags only to 1P code #7241

Merged
merged 5 commits into from
Jan 24, 2025
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Jan 23, 2025

Move all the configuration of error and warning flags to after we have
added the third_party subdirectory and declared all of the 3P targets.
This ensures that only the basic configuration that e.g. affects ABI is
applied to the 3P code. This will make it easier to add 3P code that
does not compile cleanly with all the warnings and errors we enable for
our own code.

Move the unit test source under src/ so that all of our 1P code and none
of our 3P code is under src/, then move the configuration of all the
error and warning flags to src/CMakeLists.txt so it only applies to 1P
code. This will make it easier to add 3P code that does not compile
cleanly with all the warnings and errors we enable for our own code.
@tlively tlively requested a review from kripken January 23, 2025 23:19
@tlively
Copy link
Member Author

tlively commented Jan 23, 2025

@kripken, this uses the architecture you suggested in #7235.

@tlively
Copy link
Member Author

tlively commented Jan 24, 2025

Right, so it doesn't appear that this actually works. CMAKE_CXX_FLAGS includes all the expected flags when we descend into the 1P source subdirectories, but it seems that the point at which its value matters is when the target is defined by add_library or add_executable. The tests are failing here because -DBUILD_LLVM_DWARF is not being passed when compiling the libbinaryen sources because the binaryen target was declared before all the 1P flags were added to CMAKE_CXX_FLAGS.

We have a few options:

@tlively
Copy link
Member Author

tlively commented Jan 24, 2025

Ok, this is vastly simplified now. The fact that CMAKE_CXX_FLAGS takes effect at the moment a target is declared made it obvious that we just needed to set all the warning and error flags after visiting third_party and before visiting our own code.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice!

(cmake... i'll never understand it)

@tlively tlively merged commit ee0191a into main Jan 24, 2025
13 checks passed
@tlively tlively deleted the cmake-1p-flags branch January 24, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants