Bug 243606

Summary: editors/vim fails to build with PYTHON3
Product: Ports & Packages Reporter: Roman Bogorodskiy <novel>
Component: Individual Port(s)Assignee: Adam Weinberger <adamw>
Status: Closed FIXED    
Severity: Affects Only Me CC: python
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Roman Bogorodskiy freebsd_committer 2020-01-26 08:58:37 UTC
package name: vim-8.2.0076
building for: FreeBSD current-local-job-01 13.0-CURRENT FreeBSD 13.0-CURRENT 1300076 amd64

Fails to build with the following error:

  cc -L/usr/local/lib -L/usr/local/lib -L.   -fstack-protector-strong  -rdynamic -Wl,-R/usr/local/lib/perl5/5.30/mach/CORE   -fstack-protector-strong  -L/usr/local/lib -Wl,--as-needed  -o vim objects/arabic.o  objects/arglist.o  objects/autocmd.o  objects/beval.o  objects/buffer.o  objects/change.o  objects/blob.o  objects/blowfish.o  objects/cindent.o  objects/cmdexpand.o  objects/cmdhist.o  objects/crypt.o  objects/crypt_zip.o  objects/debugger.o  objects/dict.o  objects/diff.o  objects/digraph.o  objects/drawline.o  objects/drawscreen.o  objects/edit.o  objects/eval.o  objects/evalbuffer.o  objects/evalfunc.o  objects/evalvars.o  objects/evalwindow.o  objects/ex_cmds.o  objects/ex_cmds2.o  objects/ex_docmd.o  objects/ex_eval.o  objects/ex_getln.o  objects/fileio.o  objects/filepath.o  objects/findfile.o  objects/fold.o  objects/getchar.o  objects/hardcopy.o  objects/hashtab.o  objects/highlight.o  objects/if_cscope.o  objects/if_xcmdsrv.o  objects/indent.o  objects/insexpand.o  objects/list.o  objects/map.o  objects/mark.o  objects/memline.o  objects/menu.o  objects/misc1.o  objects/misc2.o  objects/mouse.o  objects/move.o  objects/mbyte.o  objects/normal.o  objects/ops.o  objects/option.o  objects/optionstr.o  objects/os_unix.o  objects/pathdef.o  objects/popupmenu.o  objects/popupwin.o  objects/profiler.o  objects/pty.o  objects/quickfix.o  objects/regexp.o  objects/register.o  objects/scriptfile.o  objects/screen.o  objects/search.o  objects/session.o  objects/sha256.o  objects/sign.o  objects/sound.o  objects/spell.o  objects/spellfile.o  objects/spellsuggest.o  objects/syntax.o  objects/tag.o  objects/term.o  objects/terminal.o  objects/testing.o  objects/textprop.o  objects/ui.o  objects/undo.o  objects/usercmd.o  objects/userfunc.o  objects/version.o  objects/viminfo.o  objects/window.o  objects/bufwrite.o  objects/gui.o objects/gui_gtk.o objects/gui_gtk_x11.o  objects/gui_gtk_f.o  objects/gui_beval.o objects/gui_gtk_gresources.o  objects/vterm_encoding.o objects/vterm_keyboard.o objects/vterm_mouse.o objects/vterm_parser.o objects/vterm_pen.o objects/vterm_screen.o objects/vterm_state.o objects/vterm_unicode.o objects/vterm_vterm.o      objects/if_perl.o objects/if_perlsfio.o    objects/if_python3.o    objects/if_ruby.o    objects/netbeans.o  objects/channel.o  objects/xdiffi.o  objects/xemit.o  objects/xprepare.o  objects/xutils.o  objects/xhistogram.o  objects/xpatience.o objects/charset.o  objects/json.o  objects/main.o  objects/memfile.o  objects/message.o     -L/usr/local/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lpthread -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -lSM -lICE -lXpm  -lXt -lX11  -lXdmcp -lSM -lICE    -lm -lelf  -pthread -lncurses      -Wl,-R/usr/local/lib/perl5/5.30/mach/CORE -pthread -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/local/lib/perl5/5.30/mach/CORE -lperl -lpthread -lm -lcrypt -lutil    -L/usr/local/lib/python3.7/config-3.7dm -lpython3.7dm -lcrypt -ldl -lutil -lm    -lruby26 -lm -lpthread -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib
ld: error: undefined symbol: _PyObject_DebugFree
>>> referenced by if_python3.c
>>>               objects/if_python3.o:(call_PyObject_Free)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
link.sh: Linking failed

Builds fine if I unset PYTHON3.

This could be related to the DEBUG option I have for most of the ports, but vim itself does not seem to have this options. I haven't try to rebuild without DEBUG yet because it involves rebuilding quite a number of ports.

Full log is here: https://people.freebsd.org/~novel/misc/vim-8.2.0076.log
Comment 1 Adam Weinberger freebsd_committer 2020-01-27 18:14:25 UTC
AFAIK it is in fact related to python being built with DEBUG. Unfortunately, that's all that I know at this moment.
Comment 2 Adam Weinberger freebsd_committer 2020-01-27 18:16:03 UTC
Try this: https://github.com/puremourning/vim/blob/master/configure_vimenv#L33

Add those flags to CFLAGS and let me know if it works for you.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2020-01-28 03:57:24 UTC
@Roman Pythons ABI changes when build with/without DEBUG, which can cause issues like these. As far as upstream vim is concerned, its configure should detect the Python ABI and/or the various *FLAGS settings via pkg-config

Longer term, unless there's user value in having both Python version bindings installed, the vim port should probably be using USES=python:<version-spec>, declaring the range of versions it supports, and a single PYTHON option instead of dedicated and separate PYTHON2/PYTHON3 options
Comment 4 Adam Weinberger freebsd_committer 2020-01-28 05:25:04 UTC
(In reply to Kubilay Kocak from comment #3)

I asked about that publicly in the past, and people said that some of their plugins only supported python{2,3}. I've no opposition to it.
Comment 5 Roman Bogorodskiy freebsd_committer 2020-01-28 15:34:15 UTC
(In reply to Adam Weinberger from comment #2)

That does work.
Comment 6 commit-hook freebsd_committer 2020-02-04 14:03:32 UTC
A commit references this bug:

Author: adamw
Date: Tue Feb  4 14:03:01 UTC 2020
New revision: 525167
URL: https://svnweb.freebsd.org/changeset/ports/525167

  vim: Update to patchlevel 205 and add PYTHON option

  When python is built with DEBUG, vim fails to build. In fixing this
  case, note that vim will now fail to build if python or vim is build
  with DEBUG and the other isn't.

  This also highlighted that python support is being kludged. The
  PYTHON2 and PYTHON3 options have been combined into a single PYTHON
  option that builds with the default python. Consequently, it is no
  longer possible to build vim with both py2 and py3 support. I can't
  name any modern high-usage python-based plugin that requires 2.7,
  so hopefully this only messes up things for a very small minority.

  Thanks to koobs for the prompt to combine these options. I've been
  wanting to do this for a while now.

  PR:		243606
  Submitted by:	novel

Comment 7 Adam Weinberger freebsd_committer 2020-02-04 14:04:54 UTC
Should be fixed now. Thanks for this PR!
Comment 8 Roman Bogorodskiy freebsd_committer 2020-04-11 14:16:23 UTC
It still fails to build for me:

/usr/local/lib -L/usr/local/lib       
ld: error: undefined symbol: _PyObject_DebugFree                                                          
>>> referenced by if_python3.c                                                                            
>>>               objects/if_python3.o:(call_PyObject_Free)                                               
cc: error: linker command failed with exit code 1 (use -v to see invocation)                              
link.sh: Linking failed
*** Error code 1 

I have the following in make.conf:

#### /usr/local/etc/poudriere.d/current-make.conf ####

devel_llvm60_UNSET=     DEBUG
devel_llvm70_UNSET=     DEBUG
textproc_php72-xml_UNSET_FORCE= DEBUG
java_openjdk8_UNSET=    DEBUG
www_chromium_UNSET=     DEBUG

For python37 I have:
---Begin OPTIONS List---
===> The following configuration options are available for python37-3.7.7:
     DEBUG=on: Build with debugging support
     IPV6=on: IPv6 protocol support
     NLS=off: Enable gettext support for the locale module
     PYMALLOC=on: Enable specialized mallocs
====> Hash Algorithm (PEP-456): you can only select none or one of them
     FNV=off: Modified Fowler-Noll-Vo Algorithm
     SIPHASH=off: SipHash24 Algorithm
===> Use 'make config' to modify these settings
---End OPTIONS List---

There seem to be no dedicated DEBUG option however.
Comment 9 Roman Bogorodskiy freebsd_committer 2020-04-11 14:41:27 UTC
(In reply to Roman Bogorodskiy from comment #8)

No dedicated DEBUG option for vim*
Comment 10 Adam Weinberger freebsd_committer 2020-04-11 15:37:18 UTC
I'm not sure what to do about that.