From 3775d3639827f1c41271bdfa8d5537331854bd66 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Sat, 9 Jan 2021 16:41:13 +0100 Subject: [PATCH 1/2] Do fuzzing linking in setup.py options, rather than post-hoc manually linking --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index dd1772ae0..17b08a427 100755 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ JPEG_ROOT = None LCMS_ROOT = None TIFF_ROOT = None ZLIB_ROOT = None - +FUZZING_BUILD = 'LIB_FUZZING_ENGINE' in os.environ if sys.platform == "win32" and sys.version_info >= (3, 10): import atexit @@ -346,6 +346,9 @@ class pil_build_ext(build_ext): extension.define_macros += define_macros if include_dirs is not None: extension.include_dirs += include_dirs + if FUZZING_BUILD: + extension.language = "c++" + extension.extra_link_args = ["--stdlib=libc++"] break def _remove_extension(self, name): @@ -840,9 +843,7 @@ class pil_build_ext(build_ext): def debug_build(): - return hasattr(sys, "gettotalrefcount") or os.environ.get( - "LIB_FUZZING_ENGINE", None - ) + return hasattr(sys, "gettotalrefcount") or FUZZING_BUILD files = ["src/_imaging.c"] From 77bf0aa67365edbdc74d300b2aa306b28aa86b22 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Sat, 9 Jan 2021 17:00:27 +0100 Subject: [PATCH 2/2] lint off --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 17b08a427..10992779e 100755 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ JPEG_ROOT = None LCMS_ROOT = None TIFF_ROOT = None ZLIB_ROOT = None -FUZZING_BUILD = 'LIB_FUZZING_ENGINE' in os.environ +FUZZING_BUILD = "LIB_FUZZING_ENGINE" in os.environ if sys.platform == "win32" and sys.version_info >= (3, 10): import atexit