-
Notifications
You must be signed in to change notification settings - Fork 65
[WIP] Fix macOS libcachesim installation #183
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
base: develop
Are you sure you want to change the base?
[WIP] Fix macOS libcachesim installation #183
Conversation
3b2977d
to
6c03548
Compare
6c03548
to
fd5388d
Compare
The SonarCloud failures are not my failures; these already existed but had not been triggered due to the CI configuration. They were now triggered due to the repository-wide reformat to conform to the clang-format style. Either way, the warnings shown on SonarCloud are not very useful, complaining about strlen being unsafe. Yeah, it can be unsafe, this is C code :) |
a8ef48a
to
f5d972e
Compare
8ad145a
to
4394a8a
Compare
…ive, no-whole-archive)
4394a8a
to
81b6c39
Compare
|
Problem
The problem is that the installation of
libcachesim
fails on macOS due to too many errors caught by Clang that are otherwise ignored by the less strict GCC. This MR addresses issues listed in Issue #182 and fixes further issues encountered along the way.Issue 1: Code quality CI never triggers
The
code-quality.yaml
includes aclang-tidy
formatter that seemed to not run previously due to its configuration. After ensuring that all C and C++ files are captured (c4f9bfb), the whole repository was reformatted (225b07e) to conform to clang-tidy. As the repository-wide reformatting affected a lot of files without changing their functionality, the commit is ignored from git blame (fd5388d).Issue 2: Incorrect format specifiers
A common error reported by Clang was incorrect format specifiers used with the
printf
function. The solution for this was simply to correct the format specifier (32bad8f). An example of the error is shown here:Issue 3: Unqualified calls to
std::move
The file
splaytree.hpp
contained unqualified calls tostd::move
. The fix was simple and just required a change from invokingstd::move
instead ofmove
(25b3b43). An example of the error is shown here:Issue 4: Use of deprecated
sprintf
functionThe
sprintf
function is reported to be deprecated and insecure, so it is replaced bysnprintf
(5d2b445). An example of the error is shown here:Issue 5: Unused variables
There are some unused variables that have been removed (fdf9406). An example of the error is shown here:
Issue 6: C++ constructs used in C scope
The
split_by_char
function inbin/mrcProfiler/cli_parser.cpp
returns an instance of typestd::vector<std::string>
. The problem here is that this function is declared within anextern "C" {...}
block, so is treated as a C function type eventhough its return type is unsupported (only supported in C++). The fix here is to move the function outside of the extern block (7e835f5). An example of the error is shown here:Issue 7: Variadic argument list (...) with optional arguments is not handled correctly
The header file
inclue/libCacheSim/macro.h
defines some macros for assertions with optional arguments. The problem here is that this only works if__VA_ARGS__
is not empty. Otherwise, it leaves a dangling comma likeCHECK_CONDITION(x, ==, NULL, FMT, )
and causes compilation errors on Clang (GCC silently ignores these). The solution is to wrap the comma in__VA_OPT__
likeCHECK_CONDITION(x, ==, NULL, FMT __VA_OPT__(,) __VA_ARGS__)
, so the expansion only adds a comma when__VA_ARGS__
is not empty, else no dangling comma (da4b717). An example of the error is shown here:Issue 7: Unsupported linker options for macOS
There are three linker options used in
CMakeLists.txt
files across the project that are unsupported by Clang:export-dynamic
,whole-archive
, andno-whole-archive
. Thus, logic has been added around these instances to ensure these options are only linked when run on Linux systems (33b614f). An example of the error is shown here:Issue 8: Specific GCC flags not recognised by Clang
The C file
bin/cachesim/sim.c
contains GCC-specific#pragma
directives used to temporarily surpress the compiler warning-Wformat-truncation
. The problem is that Clang does not recognize GCC-specific warnings. To fix this, preprocessor checks are applied to ensure the pragma is only applied for real GCC (ca5af76). An example of the error is shown here:Issue 9: Linker issue with
_create_cache
functionThe linker issue indicated that the definition of the
_create_cache
function could not be found. The problem here is that the C fileplugin.c
which contains the_create_cache
function was never compiled and linked and caused an unresolved symbol error. To solve this, thecache/CMakeLists.txt
was modified to includeplugin.c
in the source list for thecachelib
target (5dca341). An example of the error is shown here:Issue 10: GNU-style variadic arguments not supported by Clang
GNU-style variadic arguments are used in the project, which Clang warns about by default. To resolve this by suppressing these warnings about zero-argument variadic macros, the compiler flag
-Wno-gnu-zero-variadic-macro-arguments
is added to bothCMAKE_C_FLAGS
andCMAKE_CXX_FLAGS
inCMakeLists.txt
(37f80d2). An example of the error is shown here:Issue 11: Library
zstd
not foundThe
zstd
library was not found on macOS due to the path in which the library exists. Since brew is used to install packages on macOS, the path is different than the default path. To correctly handle this difference, the package managerpkg-config
is used to link thezstd
library correctly (e05e0df). An example of the error is shown here: