techknowlogick / xgo

Go CGO cross compiler
MIT License
478 stars 79 forks source link

C-shared library generated with xgo build not working for mac ARM (M1)machine #207

Open pandurangpatil opened 1 year ago

pandurangpatil commented 1 year ago

Repository - https://github.com/Privado-Inc/goastgen/tree/xgo-build-trial (Sharing a branch where I tried the build, as the main branch, we are now taking a different approach without using c-shared binary).

I tried generating the c-shared binary on my mac machine

image

It worked well sample working Java code is here - https://github.com/Privado-Inc/goastgen/blob/xgo-build-trial/sample-client/Sample.java

However when I tried with binary generated from the build through GirHub release actions we tried. With above sample replacing the .dylib didn't work it just killed the process. (I did tried making the build using xgo installed over separate AWS Ubuntu machine and making the build for mac M1 chip (arm64). With the same result)

I tried look at what other system dependencies these libraries have using otool. Following are the details for lib generated on my machine and the one generated from the GitHub action build.

Lib generated on my machine.

lib-goastgen_darwin_arm64.dylib:
    lib-goastgen_darwin_arm64.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

Lib generated from the GitHub build

lib-goastgen-darwin-10.12-arm64.dylib:
    lib-goastgen-darwin-10.12-arm64.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
    /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

The error I am getting with the build generated using xgo

image
pandurangpatil commented 1 year ago

I think issue #208 and this ticket is related

woshiqiandui commented 1 year ago

I have encountered a problem similar to yours. sqlite3 could't run normally