astral-sh / astral-sh/python-build-standalone

Duplicate ffi symbols in Windows static builds

Open
#71 0 comments 0 reactions 0 assignees View on GitHub
bug platform:windows
Dominant language
Python
Stars
4.4k
Forks
314
Avg merge
1d 9h
Merged PRs (30d)
27

Description

The Windows static builds currently have multiple object files defining libffi symbols. As the build log demonstrates:

```
9>Lib:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\Lib.exe /OUT:"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCbuild\amd64\_ctypes.lib" libffi.lib /LIBPATH:"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\libffi\\" /NOLOGO /MACHINE:X64 /LTCG /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE "C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\python_nt.res"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\_ctypes.obj"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\callbacks.obj"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\callproc.obj"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\cfield.obj"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\malloc_closure.obj"
"C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\_ctypes\stgdict.obj"
18>Lib:
select.vcxproj -> C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCbuild\amd64\select.lib
FinalizeBuildStatus:
Deleting file "C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\select\select.tlog\unsuccessfulbuild".
Touching "C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\obj\39amd64_Release\select\select.tlog\select.lastbuildstate".
18>Done Building Project "C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\select.vcxproj" (Build target(s)).
24>Link:
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
9>malloc_closure.obj : warning LNK4006: ffi_closure_alloc already defined in libffi.lib(closures.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>malloc_closure.obj : warning LNK4006: ffi_closure_free already defined in libffi.lib(closures.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_void already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_uint8 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_sint8 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_uint16 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_sint16 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_uint32 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_sint32 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_uint64 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_sint64 already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_float already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_double already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
9>cfield.obj : warning LNK4006: ffi_type_pointer already defined in libffi.lib(types.obj); second definition ignored [C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCBuild\_ctypes.vcxproj]
_ctypes.vcxproj -> C:\Users\gps\AppData\Local\Temp\python-build-3uvcddyb\Python-3.9.2\PCbuild\amd64\_ctypes.lib
9>FinalizeBuildStatus:
```

This can cause linking failures unless `/FORCE:MULTIPLE` is used.

Ideally we would build with LNK4006 as a hard error. Although this may be difficult given how many errors we're seeing and how much we're abusing the Visual Studio build system.

This is related to https://github.com/indygreg/PyOxidizer/issues/360 (but we can work around this issue in PyOxidizer by using `/FORCE:MULTIPLE`).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.