This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: importing _ctypes failed: undefined symbol: ffi_call_win32
Type: compile error Stage: resolved
Components: Build Versions: Python 3.4, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: ctypes module doesn't build on FreeBSD, RHEL (x86) - Undefined symbol "ffi_call_win32"
View: 23042
Assigned To: Nosy List: Arfrever, davin, doko, georg.brandl, larry, lemburg, pitrou, siming85
Priority: release blocker Keywords: 3.4regression

Created on 2014-10-14 19:59 by siming85, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
configure.log siming85, 2014-10-15 13:45 configure log on RHEL6.4
make.log siming85, 2014-10-15 13:47 make log on RHEL 6.4
rpm.log siming85, 2014-10-15 13:50 rhel 6.4 rpm information
Messages (16)
msg229342 - (view) Author: Siming Yuan (siming85) * Date: 2014-10-14 19:59
Compiling Python 3.4.2 32-bit using GCC under RHEL6.4 and RHEL5.5 yields to crash:

*** WARNING: renaming "_ctypes" since importing it failed: build/lib.linux-x86_64-3.4/ undefined symbol: ffi_call_win32

Why is it referring to a win32 api when i'm compiling under Linux?

This failure causes pip installation to also fail due to missing ctypes module.

FYI - 3.4.1 under exact same env. builds fine.
msg229343 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-14 20:00
Similar issue on old FreeBSD versions: issuee #22521.
msg229346 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2014-10-14 20:15
This appears to be caused by the update to libffi version 3.1 in 3.4.2.
msg229428 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2014-10-15 10:11
could somebody attach a build log from such a system? and the libffi config.log?
msg229446 - (view) Author: Siming Yuan (siming85) * Date: 2014-10-15 13:45
attached python 3.4.2 configure log on RHEL6.4
msg229448 - (view) Author: Siming Yuan (siming85) * Date: 2014-10-15 13:47
make log from RHEL 6.4 for python 3.4.2.

Also got this on the STDERR:

$ make > ../make.log
build/temp.linux-x86_64-3.4/opt/python-3.4.2/Python-3.4.2/Modules/_ctypes/libffi/src/x86/ffi.o: In function `ffi_prep_closure_loc':
/opt/python-3.4.2/Python-3.4.2/Modules/_ctypes/libffi/src/x86/ffi.c:679: undefined reference to `ffi_closure_FASTCALL'
/usr/bin/ld: build/temp.linux-x86_64-3.4/opt/python-3.4.2/Python-3.4.2/Modules/_ctypes/libffi/src/x86/ffi.o: relocation R_386_GOTOFF against undefined hidden symbol `ffi_closure_FASTCALL' can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
msg229449 - (view) Author: Siming Yuan (siming85) * Date: 2014-10-15 13:50
configure arguments:

BASECFLAGS=-m32 LDFLAGS=-m32 CFLAGS=-m32 ./configure --prefix=/opt/python-3.4.2/ > ../configure.log

attached system rpm information. no additional binaries/PATHs/LD_LIB_PATHs
msg229451 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2014-10-15 14:20
> checking build system type... x86_64-unknown-linux-gnu
> checking host system type... x86_64-unknown-linux-gnu

and using -m32 explicitly.

so you'll get what you deserve ;-)
msg229453 - (view) Author: Siming Yuan (siming85) * Date: 2014-10-15 14:30
[siyuan@siyuan-lnx:siyuan-ott]$ lsb_release -a    
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	RedHatEnterpriseWorkstation
Description:	Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
Release:	6.4
Codename:	Santiago
[siyuan@siyuan-lnx:siyuan-ott]$ uname -a  
Linux siyuan-lnx 2.6.32-358.0.1.el6.x86_64 #1 SMP Wed Feb 20 11:05:23 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

:( there's nothing special..
msg235536 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2015-02-07 23:50
What does "-m32" mean?
msg235537 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-08 00:03
"-m32" means "compile a 32-bit build though I'm on a 64-bit platform". I'm not sure why Matthias says this is "getting what you deserve", since everytime I've tried, "-m32" worked properly for building Python.
msg238508 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-03-19 13:16
Comparing this to issue23042, this same behavior appears on i386 releases of FreeBSD 8.3 and 10.1 (the i386-RELEASE means it's 32-bit as opposed to 64-bit build).  Given that this issue is being triggered here with -m32 (triggers building of 32-bit binaries) and yet we don't appear to be having this issue on 64-bit builds, that could be a useful clue.
msg238509 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2015-03-19 13:18
This is likely also related to issue23042.

The precompiler #ifdefs were mixed up, causing Win32 code to be compiled in on other platforms as well.
msg238523 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-03-19 14:01
There is now a proposed patch on issue23042 which, having gone through those changes, may well address this issue too.

Testing that patch on multiple platforms (including the RHEL variants relevant here) would be much appreciated.

Thanks goes to @lemburg for doing the investigative work and providing the diffs that occurred to the Modules/_ctypes/libffi/src/x86/ffi.c file in the past -- that work made the patch possible to sort out.
msg238532 - (view) Author: Siming Yuan (siming85) * Date: 2015-03-19 15:30
@davin @lemburg
just tested with the provided patch in, the partch works.

dupe the bug?
msg238533 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-03-19 15:32
@siyuan:  Duping it -- thanks for trying that patch out so quickly!
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66824
2015-03-19 22:23:30berker.peksagsetstatus: open -> closed
resolution: duplicate
stage: resolved
2015-03-19 15:32:35davinsetsuperseder: ctypes module doesn't build on FreeBSD, RHEL (x86) - Undefined symbol "ffi_call_win32"
messages: + msg238533
2015-03-19 15:30:29siming85setmessages: + msg238532
2015-03-19 14:26:47vstinnersetnosy: - vstinner
2015-03-19 14:01:06davinsetmessages: + msg238523
2015-03-19 13:18:04lemburgsetnosy: + lemburg
messages: + msg238509
2015-03-19 13:16:26davinsetnosy: + davin
messages: + msg238508
2015-02-08 00:03:02pitrousetnosy: + pitrou
messages: + msg235537
2015-02-07 23:50:48larrysetmessages: + msg235536
2014-10-15 14:30:13siming85setmessages: + msg229453
2014-10-15 14:20:05dokosetmessages: + msg229451
2014-10-15 13:50:25siming85setfiles: + rpm.log

messages: + msg229449
2014-10-15 13:47:02siming85setfiles: + make.log

messages: + msg229448
2014-10-15 13:45:50siming85setfiles: + configure.log

messages: + msg229446
2014-10-15 10:13:11pitrousetpriority: normal -> release blocker
nosy: + larry

versions: + Python 3.5
2014-10-15 10:11:11dokosetmessages: + msg229428
2014-10-15 00:05:46Arfreversetnosy: + Arfrever
2014-10-14 20:15:04georg.brandlsetkeywords: + 3.4regression
nosy: + georg.brandl, doko
messages: + msg229346

2014-10-14 20:00:56vstinnersetnosy: + vstinner
messages: + msg229343
2014-10-14 19:59:45siming85create