Skip to content

Commit

Permalink
pythongh-124932: Cross builds: Distinguish between build prefix and h…
Browse files Browse the repository at this point in the history
…ost prefix

In Emscripten and wasi builds, and presumably for other cross builds, the build
file system and the host file system look different. For instance, we may want
to install into `cross-build/$TARGET/lib` and then mount that as `/lib` in the
host file system. `wasi.py` has to mess around with setting `PYTHONPATH`
because `prefix` is set to a path from the build machine. It would simplify
this if we distinguish between:

* `prefix` -- the path in the build file system where we want to install the files
* `host_prefix` -- the path in the host file system where getpath.c will look for the files

And similarly for `exec_prefix` and `host_exec_prefix`.
  • Loading branch information
hoodmane committed Oct 3, 2024
1 parent 656b7a3 commit 49b66c9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ prefix= @prefix@
# Install prefix for architecture-dependent files
exec_prefix= @exec_prefix@

# For cross compilation, we distinguish between "prefix" (where we install the
# files) and "host_prefix" (where getpath.c expects to find the files at
# runtime)
host_prefix= @host_prefix@
host_exec_prefix= @host_exec_prefix@


# Install prefix for data files
datarootdir= @datarootdir@

Expand Down Expand Up @@ -1737,8 +1744,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \

Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS)
$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
-DPREFIX='"$(prefix)"' \
-DEXEC_PREFIX='"$(exec_prefix)"' \
-DPREFIX='"$(host_prefix)"' \
-DEXEC_PREFIX='"$(host_exec_prefix)"' \
-DVERSION='"$(VERSION)"' \
-DVPATH='"$(VPATH)"' \
-DPLATLIBDIR='"$(PLATLIBDIR)"' \
Expand Down
29 changes: 29 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ then
fi
AC_MSG_RESULT(["$MACHDEP"])

dnl For cross compilation, we distinguish between "prefix" (where we install the
dnl files) and "host_prefix" (where we expect to find the files at runtime)

if test -z "$host_prefix"; then
AS_CASE([$ac_sys_system],
[Emscripten], [host_prefix=/],
[WASI], [host_prefix=/],
[host_prefix=$prefix]
)
fi
AC_SUBST([host_prefix])

if test -z "$host_exec_prefix"; then
AS_CASE([$ac_sys_system],
[Emscripten], [host_exec_prefix=$host_prefix],
[WASI], [host_exec_prefix=$host_prefix],
[host_exec_prefix=$exec_prefix]
)
fi
AC_SUBST([host_exec_prefix])

# On cross-compile builds, configure will look for a host-specific compiler by
# prepending the user-provided host triple to the required binary name.
#
Expand Down

0 comments on commit 49b66c9

Please sign in to comment.