Skip to content

Commit aef5f84

Browse files
committed
Fixes for OpenBSD and WASI builds.
Keep srcdir as an absolute path if it was originally. Match host_prefix setting done by configure.ac. Fix AWK implementations of pyconf_env_var(), pyconf_check_header() and pyconf_check_decl().
1 parent b664467 commit aef5f84

5 files changed

Lines changed: 44 additions & 28 deletions

File tree

Tools/configure/conf_init.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ def setup_source_dirs(v):
5959
srcdir_abs = pyconf.abspath(srcdir_raw)
6060
builddir = pyconf.abspath(".")
6161
out_of_tree = srcdir_abs != builddir
62-
# Use a relative path for out-of-tree builds. An absolute srcdir would
63-
# break WASI/Emscripten where VPATH is baked into the binary but the
64-
# host path doesn't exist in the guest sandbox.
65-
srcdir_rel = pyconf.relpath(srcdir_abs, builddir) if out_of_tree else "."
66-
v.export("srcdir", srcdir_rel)
62+
# Match autoconf: preserve the path form that was given. If --srcdir
63+
# was absolute (e.g. /src), keep it absolute; if relative, keep it
64+
# relative. For in-tree builds, always use ".".
65+
if out_of_tree:
66+
srcdir = srcdir_raw
67+
else:
68+
srcdir = "."
69+
v.export("srcdir", srcdir)
6770
v.export("abs_srcdir", srcdir_abs)
6871
v.export("abs_builddir", builddir)
6972
pyconf.srcdir = srcdir_abs

Tools/configure/conf_platform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ def setup_host_prefix(v):
9292
v.export(
9393
"host_prefix",
9494
"/"
95-
if v.ac_sys_system in ("Emscripten", "WASI")
95+
if v.ac_sys_system == "Emscripten"
9696
else "${prefix}",
9797
)
9898

9999
if not v.host_exec_prefix:
100100
v.host_exec_prefix = (
101101
v.host_prefix
102-
if v.ac_sys_system in ("Emscripten", "WASI")
102+
if v.ac_sys_system == "Emscripten"
103103
else "${exec_prefix}"
104104
)
105105
v.export("host_exec_prefix")

Tools/configure/transpiler/pyconf.awk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ function _pyconf_ac_includes_default( result) {
591591
return result
592592
}
593593

594-
function pyconf_check_header(header, prologue, default_inc, define, cache_key, source, cv, rc) {
594+
function pyconf_check_header(header, prologue, default_inc, define, cache_key, extra_cflags, source, cv, rc) {
595595
if (define == "") define = _pyconf_header_to_define(header)
596596
if (cache_key == "") cache_key = "ac_cv_header_" header
597597
gsub(/-/, "_dash_", cache_key)
@@ -607,7 +607,7 @@ function pyconf_check_header(header, prologue, default_inc, define, cache_key, s
607607
source = _pyconf_confdefs() "\n" default_inc "\n#include <" header ">\nint main(void) { return 0; }"
608608
else
609609
source = _pyconf_confdefs() "\n" _pyconf_ac_includes_default() "#include <" header ">\nint main(void) { return 0; }"
610-
rc = _pyconf_compile_test(source, "")
610+
rc = _pyconf_compile_test(source, extra_cflags)
611611
CACHE[cache_key] = rc ? "yes" : "no"
612612
V[cache_key] = rc ? "yes" : "no"
613613
pyconf_result(rc ? "yes" : "no")
@@ -925,7 +925,7 @@ function pyconf_check_decl(name, includes, define, source, inc, cv, rc, _darr, _
925925
}
926926

927927
pyconf_checking("whether " name " is declared")
928-
inc = _pyconf_ac_includes_default()
928+
inc = ""
929929
if (includes != "") {
930930
_dn = split(includes, _darr, " ")
931931
for (_di = 1; _di <= _dn; _di++)
@@ -1417,7 +1417,10 @@ function pyconf_arg_with(name, default_val, help_text, metavar, var, false_is, k
14171417
}
14181418

14191419
function pyconf_env_var(name, help_text) {
1420-
# Record environment variable documentation
1420+
# Seed V[name] from the environment if not already set, mirroring
1421+
# Python's Vars.__getattr__ fallback to os.environ.
1422+
if (!(name in V) && name in ENV)
1423+
V[name] = ENV[name]
14211424
}
14221425

14231426
function pyconf_option_value(key) {

Tools/configure/transpiler/pysh_to_awk.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,13 +2519,16 @@ def _build_check_lib_expr(self, call: Call) -> A.FuncCall:
25192519
)
25202520

25212521
def _build_check_header_expr(self, call: Call) -> A.FuncCall:
2522-
"""Build pyconf_check_header(header, prologue, default_inc)."""
2522+
"""Build pyconf_check_header(header, prologue, default_inc, define,
2523+
cache_key, extra_cflags)."""
25232524
args: list[A.Expr] = [self._expr(a) for a in call.args]
25242525
extra_cflags = call.kwargs.get("extra_cflags")
25252526
if extra_cflags is not None:
2526-
# Append extra_cflags to CPPFLAGS-like position — use prologue
2527-
while len(args) < 2:
2527+
# Pad to position 6: header, prologue, default_inc, define,
2528+
# cache_key, extra_cflags
2529+
while len(args) < 5:
25282530
args.append(A.StringLit(""))
2531+
args.append(self._expr(extra_cflags))
25292532
return A.FuncCall("pyconf_check_header", args)
25302533

25312534
def _build_try_link_expr(self, call: Call) -> A.FuncCall:

configure-new

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ function _pyconf_ac_includes_default( result) {
602602
return result
603603
}
604604

605-
function pyconf_check_header(header, prologue, default_inc, define, cache_key, source, cv, rc) {
605+
function pyconf_check_header(header, prologue, default_inc, define, cache_key, extra_cflags, source, cv, rc) {
606606
if (define == "") define = _pyconf_header_to_define(header)
607607
if (cache_key == "") cache_key = "ac_cv_header_" header
608608
gsub(/-/, "_dash_", cache_key)
@@ -618,7 +618,7 @@ function pyconf_check_header(header, prologue, default_inc, define, cache_key, s
618618
source = _pyconf_confdefs() "\n" default_inc "\n#include <" header ">\nint main(void) { return 0; }"
619619
else
620620
source = _pyconf_confdefs() "\n" _pyconf_ac_includes_default() "#include <" header ">\nint main(void) { return 0; }"
621-
rc = _pyconf_compile_test(source, "")
621+
rc = _pyconf_compile_test(source, extra_cflags)
622622
CACHE[cache_key] = rc ? "yes" : "no"
623623
V[cache_key] = rc ? "yes" : "no"
624624
pyconf_result(rc ? "yes" : "no")
@@ -936,7 +936,7 @@ function pyconf_check_decl(name, includes, define, source, inc, cv, rc, _darr, _
936936
}
937937

938938
pyconf_checking("whether " name " is declared")
939-
inc = _pyconf_ac_includes_default()
939+
inc = ""
940940
if (includes != "") {
941941
_dn = split(includes, _darr, " ")
942942
for (_di = 1; _di <= _dn; _di++)
@@ -1428,7 +1428,10 @@ function pyconf_arg_with(name, default_val, help_text, metavar, var, false_is, k
14281428
}
14291429

14301430
function pyconf_env_var(name, help_text) {
1431-
# Record environment variable documentation
1431+
# Seed V[name] from the environment if not already set, mirroring
1432+
# Python's Vars.__getattr__ fallback to os.environ.
1433+
if (!(name in V) && name in ENV)
1434+
V[name] = ENV[name]
14321435
}
14331436

14341437
function pyconf_option_value(key) {
@@ -3218,7 +3221,7 @@ function u_detect_sqlite3( _i_f, _n_f, check_cflags, enable_loadable_sqlite_e
32183221
sqlite_inc = " -I" pyconf_srcdir "/Modules/_sqlite"
32193222
check_cflags = V["LIBSQLITE3_CFLAGS"] sqlite_inc
32203223
V["LIBSQLITE3_CFLAGS"] = V["LIBSQLITE3_CFLAGS"] " -I$(srcdir)/Modules/_sqlite"
3221-
if (pyconf_check_header("sqlite3.h", "")) {
3224+
if (pyconf_check_header("sqlite3.h", "", "", "", "", check_cflags)) {
32223225
V["have_sqlite3"] = "yes"
32233226
if (pyconf_compile_check("", "#include <sqlite3.h>\n#if SQLITE_VERSION_NUMBER < 3015002\n# error \"SQLite 3.15.2 or higher required\"\n#endif\nint main(void) { return 0; }", check_cflags)) {
32243227
V["have_supported_sqlite3"] = "yes"
@@ -3890,13 +3893,17 @@ function u_setup_platform_defines() {
38903893
pyconf_define("_DARWIN_C_SOURCE", 1, 0, "Define on Darwin to activate all library features")
38913894
}
38923895

3893-
function u_setup_source_dirs( builddir, out_of_tree, srcdir_abs, srcdir_raw, srcdir_rel) {
3896+
function u_setup_source_dirs( builddir, out_of_tree, srcdir, srcdir_abs, srcdir_raw) {
38943897
srcdir_raw = ((pyconf__srcdir_arg != "") ? pyconf__srcdir_arg : ((V["srcdir"] != "") ? V["srcdir"] : "."))
38953898
srcdir_abs = pyconf_abspath(srcdir_raw)
38963899
builddir = pyconf_abspath(".")
38973900
out_of_tree = ((srcdir_abs != builddir) ? "yes" : "no")
3898-
srcdir_rel = (((out_of_tree != "") && (out_of_tree != "no")) ? pyconf_relpath(srcdir_abs, builddir) : ".")
3899-
V["srcdir"] = srcdir_rel
3901+
if (((out_of_tree != "") && (out_of_tree != "no"))) {
3902+
srcdir = srcdir_raw
3903+
} else {
3904+
srcdir = "."
3905+
}
3906+
V["srcdir"] = srcdir
39003907
v_export("srcdir")
39013908
V["abs_srcdir"] = srcdir_abs
39023909
v_export("abs_srcdir")
@@ -4240,7 +4247,7 @@ function u_setup_framework( ac_default_prefix, fw_raw, val) {
42404247
if ((V["ac_sys_system"] == "Darwin")) {
42414248
val = "/Library/Frameworks"
42424249
} else if ((V["ac_sys_system"] == "iOS")) {
4243-
val = "Apple/iOS/Frameworks/$(MULTIARCH)"
4250+
val = "Platforms/Apple/iOS/Frameworks/$(MULTIARCH)"
42444251
} else {
42454252
pyconf_error("error: Unknown platform for framework build")
42464253
}
@@ -4320,9 +4327,9 @@ function u__setup_framework_ios() {
43204327
V["INSTALLTARGETS"] = "libinstall inclinstall sharedinstall"
43214328
V["prefix"] = V["PYTHONFRAMEWORKPREFIX"]
43224329
V["PYTHONFRAMEWORKINSTALLNAMEPREFIX"] = "@rpath/" V["PYTHONFRAMEWORKDIR"]
4323-
V["RESSRCDIR"] = "Apple/iOS/Resources"
4330+
V["RESSRCDIR"] = "Platforms/Apple/iOS/Resources"
43244331
delete _va33
4325-
_va33[1] = "Apple/iOS/Resources/Info.plist"
4332+
_va33[1] = "Platforms/Apple/iOS/Resources/Info.plist"
43264333
_va33[0] = 1
43274334
pyconf_config_files(_va33)
43284335
}
@@ -5939,11 +5946,11 @@ function u_setup_machdep( SUNOS_VERSION, ac_md_release, ac_md_system, _split_
59395946

59405947
function u_setup_host_prefix() {
59415948
if ((!((V["host_prefix"] != "") && (V["host_prefix"] != "no")))) {
5942-
V["host_prefix"] = (((V["ac_sys_system"] == "Emscripten") || (V["ac_sys_system"] == "WASI")) ? "/" : "${prefix}")
5949+
V["host_prefix"] = ((V["ac_sys_system"] == "Emscripten") ? "/" : "${prefix}")
59435950
v_export("host_prefix")
59445951
}
59455952
if ((!((V["host_exec_prefix"] != "") && (V["host_exec_prefix"] != "no")))) {
5946-
V["host_exec_prefix"] = (((V["ac_sys_system"] == "Emscripten") || (V["ac_sys_system"] == "WASI")) ? V["host_prefix"] : "${exec_prefix}")
5953+
V["host_exec_prefix"] = ((V["ac_sys_system"] == "Emscripten") ? V["host_prefix"] : "${exec_prefix}")
59475954
}
59485955
v_export("host_exec_prefix")
59495956
}
@@ -7323,7 +7330,7 @@ function u_detect_gdbm() {
73237330
V["have_gdbm"] = "no"
73247331
pyconf_env_var("GDBM_CFLAGS", "C compiler flags for gdbm")
73257332
pyconf_env_var("GDBM_LIBS", "additional linker flags for gdbm")
7326-
if (pyconf_check_header("gdbm.h", "")) {
7333+
if (pyconf_check_header("gdbm.h", "", "", "", "", V["GDBM_CFLAGS"])) {
73277334
if (pyconf_check_lib("gdbm", "gdbm_open", V["GDBM_CFLAGS"], V["GDBM_LIBS"])) {
73287335
V["have_gdbm"] = "yes"
73297336
V["GDBM_LIBS"] = ((V["GDBM_LIBS"] != "") ? V["GDBM_LIBS"] : "-lgdbm")

0 commit comments

Comments
 (0)