On my machine, running ./setup.py build floods the screen with 206 irrelevant warnings from the system's stdlib.h, like this:
Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/stdlib.h:352:38: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/stdlib.h:352:38: note: insert '_Nullable' if the pointer may be null
int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/stdlib.h:352:38: note: insert '_Nonnull' if the pointer should never be null
int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
^
So it looks like clang is not properly recognizing some includes as the system's own; https://stackoverflow.com/questions/48096872/shouldnt-clang-suppress-warnings-from-a-header-file-in-usr-local-include describes how.
This is how I think it happened:
- This is probably important for reproduction. I have both Xcode "Command Line Tools" and Xcode proper installed.
setup.py side-steps the proper "-isystem" invocation and directly does _add_directory(include_dirs, os.path.join(sdk_path, "usr", "include")).
- Because
-isystem is not used, clang does not know it's a system include file.
- Because I have multiple SDKs, the
clang I use comes from /Applications/Xcode.app/Contents/Developer (according to xcode-select -p), which is a different one compared to the guy in /Library/Developer/CommandLineTools/usr/bin/. As a result, the -internal-isystem knowledge also fails.
This is how I think it should be fixed:
- Inject a CFLAG with the value of
[f"--system-header-prefix={sdk_path}"].
Now setuptools.CCompiler does not allow you to inject extra arguments, but setuptools.Extension does via the extra_compile_args member. Your modified build_ext should be able to do a dirty hack here: go through all the ext_modules to be built and give them some extra_compile_args (you're already doing it for fuzzing). You can even preserve the CFLAG suggestions from pkg-config this way, if you so wish.
Right, confirmed my cute little theory. I ran sudo xcode-select -s /Library/Developer/CommandLineTools so the clang is from the same place from my SDK. And it's quiet now.
It still needs a proper fix.
On my machine, running
./setup.py buildfloods the screen with 206 irrelevant warnings from the system'sstdlib.h, like this:So it looks like clang is not properly recognizing some includes as the system's own; https://stackoverflow.com/questions/48096872/shouldnt-clang-suppress-warnings-from-a-header-file-in-usr-local-include describes how.
This is how I think it happened:
setup.pyside-steps the proper "-isystem" invocation and directly does_add_directory(include_dirs, os.path.join(sdk_path, "usr", "include")).-isystemis not used,clangdoes not know it's a system include file.clangI use comes from/Applications/Xcode.app/Contents/Developer(according toxcode-select -p), which is a different one compared to the guy in/Library/Developer/CommandLineTools/usr/bin/. As a result, the-internal-isystemknowledge also fails.This is how I think it should be fixed:
[f"--system-header-prefix={sdk_path}"].Now
setuptools.CCompilerdoes not allow you to inject extra arguments, butsetuptools.Extensiondoes via theextra_compile_argsmember. Your modifiedbuild_extshould be able to do a dirty hack here: go through all theext_modulesto be built and give them someextra_compile_args(you're already doing it for fuzzing). You can even preserve the CFLAG suggestions frompkg-configthis way, if you so wish.Right, confirmed my cute little theory. I ran
sudo xcode-select -s /Library/Developer/CommandLineToolsso the clang is from the same place from my SDK. And it's quiet now.It still needs a proper fix.