Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 32-bit build is broken due to calling convention mismatches #376

Open
dtmdl opened this issue Oct 21, 2024 · 0 comments
Open

Windows 32-bit build is broken due to calling convention mismatches #376

dtmdl opened this issue Oct 21, 2024 · 0 comments

Comments

@dtmdl
Copy link

dtmdl commented Oct 21, 2024

Describe the bug
Attempting to build with 32-bit python on Windows fails due to calling convention mismatches (__cdecl vs __stdcall):

C:\...\AppData\Local\Temp\pip-build-env-rcjxvoxq\overlay\Lib\site-packages\setuptools\_distutils\dist.py:261: UserWarning: Unknown distribution option: 'test_suite'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build\lib.win32-cpython-311\pyrfc
copying src\pyrfc\_exception.py -> build\lib.win32-cpython-311\pyrfc
copying src\pyrfc\_utils.py -> build\lib.win32-cpython-311\pyrfc
copying src\pyrfc\__init__.py -> build\lib.win32-cpython-311\pyrfc
running build_ext
building 'pyrfc._cyrfc' extension
creating build\temp.win32-cpython-311\Release\src\pyrfc
"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.41.34120\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DSAPonNT -D_CRT_NON_CONFORMING_SWPRINTFS -D_CRT_SECURE_NO_DEPRECATES -D_CRT_NONSTDC_NO_DEPRECATE -D_AFXDLL -DWIN32 -D_WIN32_WINNT=0x0502 -DWIN64 -D_AMD64_ -DNDEBUG -DSAPwithUNICODE -DUNICODE -D_UNICODE -DSAPwithTHREADS -D_ATL_ALLOW_CHAR_UNSIGNED -D_LARGEFILE_SOURCE -D_CONSOLE -DSAP_PLATFORM_MAKENAME=ntintel -IC:\x\saprfc32\include "-IC:\Program Files (x86)\Python311-32\include" "-IC:\Program Files (x86)\Python311-32\Include" "-IC:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.41.34120\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpsrc/pyrfc/_cyrfc.cpp /Fobuild\temp.win32-cpython-311\Release\src/pyrfc/_cyrfc.obj -IC:\x\nwrfc750P_14-70002753\nwrfcsdk\include "-IC:\Program Files (x86)\Python311-32\Lib\inspect.py\Include" "-IC:\Program Files (x86)\Python311-32\Lib\inspect.py\Include\PC" /EHs /GL /Gy /J /MD /nologo /O2 /Oy- /we4552 /we4700 /we4789 /W3 /Z7
_cyrfc.cpp
src/pyrfc/_cyrfc.cpp(30499): error C2664: 'RFC_RC RfcInstallAuthorizationCheckHandler(RFC_ON_AUTHORIZATION_CHECK,RFC_ERROR_INFO *)': cannot convert argument 1 from 'RFC_RC (__cdecl *)(RFC_CONNECTION_HANDLE,RFC_SECURITY_ATTRIBUTES *,RFC_ERROR_INFO *)' to 'RFC_ON_AUTHORIZATION_CHECK'
src/pyrfc/_cyrfc.cpp(30499): note: None of the functions with this name in scope match the target type
C:\x\nwrfc750P_14-70002753\nwrfcsdk\include\sapnwrfc.h(2516): note: see declaration of 'RfcInstallAuthorizationCheckHandler'
src/pyrfc/_cyrfc.cpp(30499): note: while trying to match the argument list '(overloaded-function, RFC_ERROR_INFO *)'
src/pyrfc/_cyrfc.cpp(34040): error C2664: 'RFC_RC RfcInstallBgRfcHandlers(const SAP_UC *,RFC_ON_CHECK_UNIT,RFC_ON_COMMIT_UNIT,RFC_ON_ROLLBACK_UNIT,RFC_ON_CONFIRM_UNIT,RFC_ON_GET_UNIT_STATE,RFC_ERROR_INFO *)': cannot convert argument 2 from 'RFC_RC (__cdecl *)(RFC_CONNECTION_HANDLE,const RFC_UNIT_IDENTIFIER *)' to 'RFC_ON_CHECK_UNIT'
src/pyrfc/_cyrfc.cpp(34040): note: None of the functions with this name in scope match the target type
C:\x\nwrfc750P_14-70002753\nwrfcsdk\include\sapnwrfc.h(2448): note: see declaration of 'RfcInstallBgRfcHandlers'
src/pyrfc/_cyrfc.cpp(34040): note: while trying to match the argument list '(SAP_UC *, overloaded-function, overloaded-function, overloaded-function, overloaded-function, overloaded-function, RFC_ERROR_INFO *)'
src/pyrfc/_cyrfc.cpp(34328): error C2664: 'RFC_RC RfcInstallTransactionHandlers(const SAP_UC *,RFC_ON_CHECK_TRANSACTION,RFC_ON_COMMIT_TRANSACTION,RFC_ON_ROLLBACK_TRANSACTION,RFC_ON_CONFIRM_TRANSACTION,RFC_ERROR_INFO *)': cannot convert argument 2 from 'RFC_RC (__cdecl *)(RFC_CONNECTION_HANDLE,const SAP_UC *)' to 'RFC_ON_CHECK_TRANSACTION'
src/pyrfc/_cyrfc.cpp(34328): note: None of the functions with this name in scope match the target type
C:\x\nwrfc750P_14-70002753\nwrfcsdk\include\sapnwrfc.h(2401): note: see declaration of 'RfcInstallTransactionHandlers'
src/pyrfc/_cyrfc.cpp(34328): note: while trying to match the argument list '(SAP_UC *, overloaded-function, overloaded-function, overloaded-function, overloaded-function, RFC_ERROR_INFO *)'
src/pyrfc/_cyrfc.cpp(35141): error C2664: 'RFC_RC RfcInstallGenericServerFunction(RFC_SERVER_FUNCTION,RFC_FUNC_DESC_CALLBACK,RFC_ERROR_INFO *)': cannot convert argument 1 from 'RFC_RC (__cdecl *)(RFC_CONNECTION_HANDLE,RFC_FUNCTION_HANDLE,RFC_ERROR_INFO *)' to 'RFC_SERVER_FUNCTION'
src/pyrfc/_cyrfc.cpp(35141): note: None of the functions with this name in scope match the target type
C:\x\nwrfc750P_14-70002753\nwrfcsdk\include\sapnwrfc.h(2362): note: see declaration of 'RfcInstallGenericServerFunction'
src/pyrfc/_cyrfc.cpp(35141): note: while trying to match the argument list '(overloaded-function, overloaded-function, RFC_ERROR_INFO *)'
src/pyrfc/_cyrfc.cpp(48237): warning C4018: '<': signed/unsigned mismatch
src/pyrfc/_cyrfc.cpp(62459): warning C4551: function call missing argument list
src/pyrfc/_cyrfc.cpp(63060): warning C4551: function call missing argument list
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x86\\cl.exe' failed with exit code 2

This patch appears to fix the build (not yet tested it in action), but is a bit of a mess.
I can't work out how to apply __stdcall to a static method, so ripped all of the callbacks out into standalone functions.

Note there are also issues with a hardcoded /MACHINE:amd64 linker flag and suspicious WIN64 and AMD64 compiler flags.

pyrfc-32bit-build-fixes.patch

To Reproduce

  • pip install pyrfc==3.3.1

Environment

  • Windows 11 22H2
  • Python 3.11.9 (32-bit)
  • SAP NW RFC 7.50 PL 14 (Windows 32-bit)
  • No docker
  • Tried PyRFC 3.3.1 and git HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant