Skip to content

Commit b1f13bc

Browse files
authored
gh-124932: Distinguish build prefix from host prefix in cross builds (#124933)
In Emscripten and 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. This change adds a distinction 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`. At present, this is only used for Emscripten.
1 parent 6742f14 commit b1f13bc

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

Makefile.pre.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ prefix= @prefix@
141141
# Install prefix for architecture-dependent files
142142
exec_prefix= @exec_prefix@
143143

144+
# For cross compilation, we distinguish between "prefix" (where we install the
145+
# files) and "host_prefix" (where getpath.c expects to find the files at
146+
# runtime)
147+
host_prefix= @host_prefix@
148+
host_exec_prefix= @host_exec_prefix@
149+
150+
144151
# Install prefix for data files
145152
datarootdir= @datarootdir@
146153

@@ -1740,8 +1747,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
17401747

17411748
Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS)
17421749
$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
1743-
-DPREFIX='"$(prefix)"' \
1744-
-DEXEC_PREFIX='"$(exec_prefix)"' \
1750+
-DPREFIX='"$(host_prefix)"' \
1751+
-DEXEC_PREFIX='"$(host_exec_prefix)"' \
17451752
-DVERSION='"$(VERSION)"' \
17461753
-DVPATH='"$(VPATH)"' \
17471754
-DPLATLIBDIR='"$(PLATLIBDIR)"' \
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
For cross builds, there is now support for having a different install
2+
``prefix`` than the ``host_prefix`` used by ``getpath.py``. This is set to ``/`` by
3+
default for Emscripten, on other platforms the default behavior is the same
4+
as before.

configure

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,25 @@ then
379379
fi
380380
AC_MSG_RESULT(["$MACHDEP"])
381381

382+
dnl For cross compilation, we distinguish between "prefix" (where we install the
383+
dnl files) and "host_prefix" (where we expect to find the files at runtime)
384+
385+
if test -z "$host_prefix"; then
386+
AS_CASE([$ac_sys_system],
387+
[Emscripten], [host_prefix=/],
388+
[host_prefix='${prefix}']
389+
)
390+
fi
391+
AC_SUBST([host_prefix])
392+
393+
if test -z "$host_exec_prefix"; then
394+
AS_CASE([$ac_sys_system],
395+
[Emscripten], [host_exec_prefix=$host_prefix],
396+
[host_exec_prefix='${exec_prefix}']
397+
)
398+
fi
399+
AC_SUBST([host_exec_prefix])
400+
382401
# On cross-compile builds, configure will look for a host-specific compiler by
383402
# prepending the user-provided host triple to the required binary name.
384403
#

0 commit comments

Comments
 (0)