From 8297bac5e5e04e0ecd75a91322eef34a4a05b4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 30 Apr 2024 14:33:09 +0200 Subject: [PATCH] python: avoid conflicting _FORTIFY_SOURCE values The compile flags are combined from python's build config (sysconfig module) and CFLAGS environment. If both define the _FORTIFY_SOURCE but to different values, the build will fail. This is the case on Arch, where Python's sysconfig has -D_FORTIFY_SOURCE=2, while Arch's makepkg.conf has -D_FORTIFY_SOURCE=3. Resolve the config by undefining _FORTIFY_SOURCE first, and use the value from the CFLAGS environment. Details: https://setuptools.pypa.io/en/latest/userguide/ext_modules.html Fixes https://github.com/QubesOS/qubes-core-agent-linux/pull/496#issuecomment-2084833750 --- python/setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index 3b87ff8..e942e44 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,8 +1,11 @@ - +import os from setuptools import setup, Extension extra_compile_args = [ "-fno-strict-aliasing", "-Werror" ] +if "-D_FORTIFY_SOURCE=" in os.environ.get("CFLAGS", ""): + os.environ["CFLAGS"] = "-Wp,-U_FORTIFY_SOURCE " + os.environ["CFLAGS"] + PATH_INCLUDES = "../include" PATH_LIBS = "../client"