joanibal / pyAVL

python wrapper of AVL's fortran layer made using f2py
8 stars 4 forks source link

Fix windows builds - link error #9

Open joanibal opened 1 year ago

joanibal commented 1 year ago

On Windows the build repeatedly fails at the linking stage with the following error.

"gfortran"  -o libavl.cp39-win_amd64.pyd libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavl-f2pywrappers.f.obj libavl.cp39-win_amd64.pyd.p/src_aero.f.obj libavl.cp39-win_amd64.pyd.p/src_aic.f.obj libavl.cp39-win_amd64.pyd.p/src_ainput.f.obj libavl.cp39-win_amd64.pyd.p/src_airutil.f.obj libavl.cp39-win_amd64.pyd.p/src_amake.f.obj libavl.cp39-win_amd64.pyd.p/src_amass.f.obj libavl.cp39-win_amd64.pyd.p/src_amode.f.obj libavl.cp39-win_amd64.pyd.p/src_aoper.f.obj libavl.cp39-win_amd64.pyd.p/src_aoutput.f.obj libavl.cp39-win_amd64.pyd.p/src_asetup.f.obj libavl.cp39-win_amd64.pyd.p/src_atpforc.f.obj libavl.cp39-win_amd64.pyd.p/src_atrim.f.obj libavl.cp39-win_amd64.pyd.p/src_autil.f.obj libavl.cp39-win_amd64.pyd.p/src_avl.f.obj libavl.cp39-win_amd64.pyd.p/src_cdcl.f.obj libavl.cp39-win_amd64.pyd.p/src_getvm.f.obj libavl.cp39-win_amd64.pyd.p/src_hidden.f.obj libavl.cp39-win_amd64.pyd.p/src_matrix-lapackdp.f.obj libavl.cp39-win_amd64.pyd.p/src_second.f.obj libavl.cp39-win_amd64.pyd.p/src_sgutil.f.obj libavl.cp39-win_amd64.pyd.p/src_spline.f.obj libavl.cp39-win_amd64.pyd.p/src_userio.f.obj libavl.cp39-win_amd64.pyd.p/src_eispack.f.obj libavl.cp39-win_amd64.pyd.p/306a480927d86681adc867cd3f47a3309803b56d_.._.._f2py_src_fortranobject.c.obj "-Lc:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0" "-LC:/rtools40/ucrt64/lib/gcc/x86_64-w64-mingw32/10.3.0" "-Lc:/rtools40/ucrt64/bin/../lib/gcc" "-LC:/rtools40/ucrt64/lib/gcc" "-Lc:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib" "-LC:/rtools40/ucrt64/x86_64-w64-mingw32/lib" "-Lc:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../lib" "-LC:/rtools40/ucrt64/lib" "-Lc:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib" "-Lc:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../.." "-Wl,--allow-shlib-undefined" "-shared" "-Wl,--start-group" "-Wl,--out-implib=libavl.cp39-win_amd64.dll.a" "-lucrt" "-static" "lib_fortranobject.a" "-mcmodel=medium" "c:/opt/64/lib/libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0.dll.a" "-defaultlib:advapi32" "c:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/libgfortran.a" "-defaultlib:advapi32" "C:\Users\runneradmin\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\python.3.9.13\tools\python39.dll" "-lgfortran" "-lm" "-Wl,--end-group"
    c:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o: in function `_CRT_INIT':
    D:/a/rtools-testing/rtools-testing/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtdll.c:122:(.text+0x4d): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_Sleep' defined in .idata$5 section in c:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib\libkernel32.a(dqoks01409.o)
    D:/a/rtools-testing/rtools-testing/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtdll.c:90:(.text+0xc2): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_Sleep' defined in .idata$5 section in c:/rtools40/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib\libkernel32.a(dqoks01409.o)
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x17ef): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyArg_ParseTupleAndKeywords' defined in .idata$5 section in d000001.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x17fb): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyErr_Occurred' defined in .idata$5 section in d000014.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x1831): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_Py_BuildValue' defined in .idata$5 section in d000045.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x187f): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyArg_ParseTupleAndKeywords' defined in .idata$5 section in d000001.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x188b): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyErr_Occurred' defined in .idata$5 section in d000014.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x18c1): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_Py_BuildValue' defined in .idata$5 section in d000045.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x190f): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyArg_ParseTupleAndKeywords' defined in .idata$5 section in d000001.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x191b): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against symbol `__imp_PyErr_Occurred' defined in .idata$5 section in d000014.o
    libavl.cp39-win_amd64.pyd.p/meson-generated_.._libavlmodule.c.obj:libavlmodule.c:(.text+0x1951): additional relocation overflows omitted from the output

    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    INFO: autodetecting backend as ninja
    INFO: calculating backend command to run: C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-r5a546wj\overlay\Scripts\ninja.EXE
    error: subprocess-exited-with-error

Based on this stack overflow post this issue is related to translating 64 bit memory address to 32 bit addresses. The linker relocates data in the .o based on its new memory address in the linked program. A similar operation (R_X86_64_PC32) occurs in the linux .o files so the operation itself may not be the issue.

I tried..

So possible next steps

joanibal commented 8 months ago

Once the windows builds are working again we'll need to add the sym linking to the dynamic libraries for windows. This post talks about creating sym links without admin privileges.