Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci-targets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ linux:
- options:
- freethreaded+debug
- freethreaded+pgo+lto
- pgo+lto+asan
minimum-python-version: "3.13"
run: true

Expand Down
2 changes: 1 addition & 1 deletion cpython-unix/build-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():

# Construct possible options, we use a set here for canonical ordering
options = set()
options.update({"debug", "noopt", "pgo", "lto", "pgo+lto"})
options.update({"debug", "noopt", "pgo", "lto", "pgo+lto", "pgo+lto+asan"})
options.update({f"freethreaded+{option}" for option in options})
options.update({f"{option}+static" for option in options})
parser.add_argument(
Expand Down
16 changes: 10 additions & 6 deletions cpython-unix/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
MACOS_ALLOW_FRAMEWORKS = {"CoreFoundation"}


def add_target_env(env, build_platform, target_triple, build_env):
def add_target_env(env, build_platform, target_triple, build_env, build_options):
add_env_common(env)

settings = get_target_settings(TARGETS_CONFIG, target_triple)
Expand Down Expand Up @@ -93,6 +93,10 @@ def add_target_env(env, build_platform, target_triple, build_env):
extra_target_cflags.append("--rtlib=compiler-rt")
extra_target_ldflags.append("--rtlib=compiler-rt")

if "asan" in build_options:
extra_target_cflags.append("-fsanitize=address")
env["ASAN_OPTIONS"] = "detect_leaks=0"

if build_platform.startswith("linux_"):
machine = platform.machine()

Expand Down Expand Up @@ -272,7 +276,7 @@ def simple_build(
if "static" in build_options:
env["STATIC"] = 1

add_target_env(env, host_platform, target_triple, build_env)
add_target_env(env, host_platform, target_triple, build_env, build_options)

# for OpenSSL, set the OPENSSL_TARGET environment variable
if entry.startswith("openssl-"):
Expand Down Expand Up @@ -379,7 +383,7 @@ def build_libedit(
"LIBEDIT_VERSION": DOWNLOADS["libedit"]["version"],
}

add_target_env(env, host_platform, target_triple, build_env)
add_target_env(env, host_platform, target_triple, build_env, build_options)

build_env.run("build-libedit.sh", environment=env)
build_env.get_tools_archive(dest_archive, "deps")
Expand Down Expand Up @@ -440,7 +444,7 @@ def build_cpython_host(
"PYTHON_VERSION": python_version,
}

add_target_env(env, host_platform, target_triple, build_env)
add_target_env(env, host_platform, target_triple, build_env, build_options)

# Set environment variables allowing convenient testing for Python
# version ranges.
Expand Down Expand Up @@ -837,7 +841,7 @@ def build_cpython(
if "static" in parsed_build_options:
env["CPYTHON_STATIC"] = "1"

add_target_env(env, host_platform, target_triple, build_env)
add_target_env(env, host_platform, target_triple, build_env, build_options)

build_env.run("build-cpython.sh", environment=env)

Expand Down Expand Up @@ -979,7 +983,7 @@ def main():

# Construct possible options
options = set()
options.update({"debug", "noopt", "pgo", "lto", "pgo+lto"})
options.update({"debug", "noopt", "pgo", "lto", "pgo+lto", "pgo+lto+asan"})
options.update({f"freethreaded+{option}" for option in options})
options.update({f"{option}+static" for option in options})
parser.add_argument(
Expand Down
Loading