tools/python: Pass linker to Python build process
authorElliott Mitchell <ehem+xen@m5p.com>
Mon, 12 Oct 2020 01:11:39 +0000 (18:11 -0700)
committerHans van Kranenburg <hans@knorrie.org>
Fri, 4 Nov 2022 19:25:46 +0000 (19:25 +0000)
Unexpectedly the environment variable which needs to be passed is
$LDSHARED and not $LD.  Otherwise Python may find the build `ld` instead
of the host `ld`.

Replace $(LDFLAGS) with $(SHLIB_LDFLAGS) as Python needs shared objects
it can load at runtime, not executables.

This uses $(CC) instead of $(LD) since Python distutils appends $CFLAGS
to $LDFLAGS which breaks many linkers.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
(cherry picked from commit 17d192e0238d6c714e9f04593b59597b7090be38)

[ Hans van Kranenburg ]
Fixed cherry-pick conflict because we have LIBEXEC_LIB=$(LIBEXEC_LIB) in
between in the same lines. The line wrap mess makes it a bit hard to
follow.

Gbp-Pq: Name 0028-tools-python-Pass-linker-to-Python-build-process.patch

tools/pygrub/Makefile
tools/python/Makefile

index 4cd1a95421a4d0167b6e69800761131d8c57334b..2950f375f1a732157f6a70f65c60b1a9fbf2143e 100644 (file)
@@ -3,21 +3,22 @@ XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
-PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
+PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
 .PHONY: all
 all: build
 .PHONY: build
 build:
-       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
+       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" \
+               LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py build
 
 .PHONY: install
 install: all
        $(INSTALL_DIR) $(DESTDIR)/$(bindir)
-       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" \
-               LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) \
-               setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
+               LDFLAGS="$(PY_LDFLAGS)" LIBEXEC_LIB=$(LIBEXEC_LIB) $(PYTHON) setup.py install \
+               --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
                 --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
        set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
                     "`readlink -f $(DESTDIR)/$(bindir)`" != \
index 8d22c03676571eb3d925178d24d3c0408bfed966..b675f5b4ded6cacbbcc9d61647eb1c58551322e5 100644 (file)
@@ -5,19 +5,20 @@ include $(XEN_ROOT)/tools/Rules.mk
 all: build
 
 PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
-PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
+PY_LDFLAGS = $(SHLIB_LDFLAGS) $(APPEND_LDFLAGS)
 INSTALL_LOG = build/installed_files.txt
 
 .PHONY: build
 build:
-       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" $(PYTHON) setup.py build
+       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py build
 
 .PHONY: install
 install:
        $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 
-       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) \
-               setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+       CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDSHARED="$(CC)" \
+               LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) setup.py install \
+               --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
                --root="$(DESTDIR)" --force
 
        $(INSTALL_PYTHON_PROG) scripts/convert-legacy-stream $(DESTDIR)$(LIBEXEC_BIN)