Skip to content

Commit 319cba7

Browse files
grahamedgecombewanda-phi
authored andcommitted
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.
1 parent 2a8cfde commit 319cba7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ ifeq ($(ENABLE_PYOSYS),1)
152152
PYTHON_VERSION_TESTCODE := "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));print(t)"
153153
PYTHON_VERSION := $(shell $(PYTHON_EXECUTABLE) -c ""$(PYTHON_VERSION_TESTCODE)"")
154154
PYTHON_MAJOR_VERSION := $(shell echo $(PYTHON_VERSION) | cut -f1 -d.)
155+
156+
ENABLE_PYTHON_CONFIG_EMBED ?= $(shell $(PYTHON_EXECUTABLE)-config --embed --libs > /dev/null && echo 1)
157+
ifeq ($(ENABLE_PYTHON_CONFIG_EMBED),1)
158+
PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config --embed
159+
else
155160
PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config
161+
endif
162+
156163
PYTHON_PREFIX := $(shell $(PYTHON_CONFIG) --prefix)
157164
PYTHON_DESTDIR := $(PYTHON_PREFIX)/lib/python$(PYTHON_VERSION)/site-packages
158165

0 commit comments

Comments
 (0)