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

precompile support for armv7l-linux-gnueabihf #302

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

cocoa-xu
Copy link
Contributor

@cocoa-xu cocoa-xu commented Oct 10, 2024

Long story short: ErlNapiSInt64 defined in erl_drv_nif.h becomes signed 32-bit integer when cross-compiling for an armv7l target on an x86_64 host.

The old but gold printf debugging 🫣

        case SQLITE_INTEGER: {
            int64_t value = sqlite3_column_int64(statement, i);
            sqlite_int64 v = value;
            printf("sqlite3_column_int64: int64_t %lld\r\n", value);
            printf("sqlite3_column_int64: sqlite_int64 %lld\r\n", v);
            printf("sizeof(ErlNapiSInt64): %ld\r\n", sizeof(ErlNapiSInt64));
            return enif_make_int64(env, v);
        }
sqlite3_column_int64: int64_t 20221010123504
sqlite3_column_int64: sqlite_int64 20221010123504
sizeof(ErlNapiSInt64): 4

So the potential solution is to compile it in an armv7l-linux-gnueabihf docker container.

Relevant issue: elixir-ecto/ecto_sql#638

@cocoa-xu
Copy link
Contributor Author

Actually, I might have a better solution

@cocoa-xu cocoa-xu marked this pull request as draft October 10, 2024 11:14
Signed-off-by: Cocoa <i@uwucocoa.moe>
@cocoa-xu cocoa-xu force-pushed the cx-armv7l-linux-gnueabihf branch from dda08fc to a79a6ba Compare October 10, 2024 12:36
@cocoa-xu cocoa-xu marked this pull request as ready for review October 10, 2024 12:36
@cocoa-xu
Copy link
Contributor Author

Now it should be much simpler, and it turns out we have to use the header files from the armv7l version of OTP.

@warmwaffles
Copy link
Member

Awesome. It will only be a matter of time before someone using an ARM based Windows machine asks for support.

@warmwaffles warmwaffles merged commit cdc0e6c into elixir-sqlite:main Oct 10, 2024
8 of 9 checks passed
@warmwaffles
Copy link
Member

Thank you @cocoa-xu I appreciate the investigation.

@cocoa-xu
Copy link
Contributor Author

Awesome. It will only be a matter of time before someone using an ARM based Windows machine asks for support.
Thank you @cocoa-xu I appreciate the investigation.

Not a problem! And let me know when we need to do precompile support for ARM based Windows!

@cocoa-xu cocoa-xu deleted the cx-armv7l-linux-gnueabihf branch October 10, 2024 12:56
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

Successfully merging this pull request may close these issues.

2 participants