aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Edgecombe <gpe@grahamedgecombe.com>2019-11-19 19:46:15 +0000
committerMarcin Koƛcielnicki <mwk@0x04.net>2019-12-20 10:23:18 +0100
commit319cba70d37eafdb8bbd3ddf6a0f9c238d53d0c2 (patch)
tree8767250c5eb5c08c756f20fd058db3dbd9f40e99
parent2a8cfdebbba39782304afdf91b8fcfbf0bd58eb0 (diff)
downloadyosys-319cba70d37eafdb8bbd3ddf6a0f9c238d53d0c2.tar.gz
yosys-319cba70d37eafdb8bbd3ddf6a0f9c238d53d0c2.tar.bz2
yosys-319cba70d37eafdb8bbd3ddf6a0f9c238d53d0c2.zip
Fix linking with Python 3.8
The behaviour of python-config --libs has changed in Python 3.8. For example, compare the output of it with Python 3.7 and 3.8 on an ArchLinux system: $ python3.7-config --libs -lpython3.7m -lcrypt -lpthread -ldl -lutil -lm $ python3.8-config --libs -lcrypt -lpthread -ldl -lutil -lm -lm $ The lack of -lpython in the latter case causes the linker to fail when attempting to build Yosys against Python 3.8. Passing the new --embed flag to python-config adds -lpython, just like earlier versions of Python: $ python3.8-config --embed --libs -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm $ This commit adds code for automatically detecting support for the --embed flag. If it is supported, it is passed to all python-config invocations. This fixes building against Python 3.8.
-rw-r--r--Makefile7
1 files changed, 7 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index c60e0afa6..a85f6350c 100644
--- a/Makefile
+++ b/Makefile
@@ -152,7 +152,14 @@ ifeq ($(ENABLE_PYOSYS),1)
PYTHON_VERSION_TESTCODE := "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));print(t)"
PYTHON_VERSION := $(shell $(PYTHON_EXECUTABLE) -c ""$(PYTHON_VERSION_TESTCODE)"")
PYTHON_MAJOR_VERSION := $(shell echo $(PYTHON_VERSION) | cut -f1 -d.)
+
+ENABLE_PYTHON_CONFIG_EMBED ?= $(shell $(PYTHON_EXECUTABLE)-config --embed --libs > /dev/null && echo 1)
+ifeq ($(ENABLE_PYTHON_CONFIG_EMBED),1)
+PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config --embed
+else
PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config
+endif
+
PYTHON_PREFIX := $(shell $(PYTHON_CONFIG) --prefix)
PYTHON_DESTDIR := $(PYTHON_PREFIX)/lib/python$(PYTHON_VERSION)/site-packages