-
Notifications
You must be signed in to change notification settings - Fork 716
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
refactor: clean up CMakelists.txt #4779
Conversation
I actually can't replace the other shared lib with the one used for unit tests, because the fuzz tests need to be dynamically linked because they rely on LD_PRELOAD to clobber certain symbols.
no-missing-braces is required for GCC 4 support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not disagreeing with the section header, but you can get syntax highlighting on CMake file if you get extension on VS Code which made my life x10 easier.
Thank you for cleaning this up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the cleanup!
My suggestion for a PR like this would be to comment on your own PR in-line with explanations of the various changes, rather than summarizing in the description. I've found that helps when the reasoning behind line changes aren't clear, but a persistent code comment wouldn't make sense (particularly for deletes).
add_custom_command( | ||
TARGET testss2n POST_BUILD | ||
COMMAND | ||
objcopy --redefine-syms libcrypto.symbols lib/libtestss2n.a | ||
) | ||
endif() | ||
|
||
#run unit tests | ||
file (GLOB TEST_LD_PRELOAD "tests/LD_PRELOAD/*.c") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this because it is unused. I searched the entire codebase (not just CMakeLists.txt) and found that this library is only used when unit tests are run through make. See the PR overview for my thoughts on why we should totally delete this library.
|
||
add_library(testss2n STATIC ${TESTLIB_HEADERS} ${TESTLIB_SRC} ${EXAMPLES_SRC}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headers shouldn't be included as part of the add_library
directive. Generally the add_library
directive is just used for things that generate object files. Header should then be added through target_include_directories
, but that is already configured to add the tests/
path.
Description of changes:
I was reading through out CMakeLists.txt and noticed a number of odd/unused configurations. This PR removes them.
jk, GCC 4 strikes againWno-missing-braces
is not needed for libs2nget_filename_component
-fPIC
compile option on tests, since it is already specified as a public option on libs2n_POSIX_C_SOURCE=200809L
using the dedicatedtarget_compile_definition
syntax-fsanitize=fuzzer -lstdc++
using the dedicatedtarget_link_options
syntaxtarget_include_directories(${TEST_NAME} PRIVATE ./)
allocator_overrides
Call-outs:
Allocator Overrides
allocator_overrides
is never used when tests are run through CMake. Original motivation for the test can be found in these PRsFrom the above PRs, the goal with the allocator overrides was the help catch places that we were using uninitialized variables. My current take is the
-Wuninitialized
(which we currently use) and clang-static-analyze (which we don't) are more robust ways of catching these errors. As such, I would vote for fully removing the allocator overrides ones we have deprecated the make builds.Section Headers
I know that my big section header comments might be polarizing, but the motivation was as follows
That's why I think the very hefty section headers are justified. A single comment is just going to get lost in the wash of monocolored text.
Compile Options: Individual Lines
The compile options were getting very difficult to read. Additionally, having them on a single line makes the git blame much more useful.
Testing:
All CI should pass
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.