Selectable library loaders, including link-time by bartbes · Pull Request #30 · love2d/lua-https · GitHub
Skip to content

Selectable library loaders, including link-time#30

Merged
MikuAuahDark merged 5 commits intolove2d:mainfrom
bartbes:selectable_library_loaders
Apr 20, 2024
Merged

Selectable library loaders, including link-time#30
MikuAuahDark merged 5 commits intolove2d:mainfrom
bartbes:selectable_library_loaders

Conversation

@bartbes
Copy link
Copy Markdown
Member

@bartbes bartbes commented Apr 7, 2024

Resolves #16, as per my proposal there. Alternative to #22.

I wanted to do the first commit for OpenSSL 3 support anyway, and it provided an alternative solution for #16. It does feel slightly more invasive than I'd like.

@TurtleP can you check whether this works for you?

bartbes added 5 commits April 7, 2024 11:53
Makes it easier to replace, centralises the platform-dependent logic, and means we can more easily re-use things like the templated LoadSymbol.
Which does not call dlsym or equivalents, but links directly against the library and dispatches on name.
This can be useful on platforms without (working) dlsym-implementations, without affecting the structure of lua-https too much.
Apparently on macOS we weren't building using c++11, causing a compile error because of a nullptr.
Considering the ubiquitous support for c++11 these days, just enable it.
@TurtleP
Copy link
Copy Markdown
Contributor

TurtleP commented Apr 7, 2024

@bartbes
Copy link
Copy Markdown
Member Author

bartbes commented Apr 7, 2024

I see you’ve set LIBRARY_LOADER, but that is a cmake-only variable. Is the define HTTPS_LIBRARY_LOADER_LINKTIME set? Otherwise LinktimeLibraryLoader.cpp will be ifdeffed out.

@TurtleP
Copy link
Copy Markdown
Contributor

TurtleP commented Apr 7, 2024

Ah, gotcha.. didn't see that part of it. It built the 3DS binary, will check if this works shortly.

@TurtleP
Copy link
Copy Markdown
Contributor

TurtleP commented Apr 7, 2024

Alright, it kind of works. I got the following error, which I vaguely remember how I solved it last time, but I'm not 100% sure. If memory serves it failed the connection test. I might be misremembering, though?

[LOVE] Error: [string "main.lua"]:5: No applicable HTTPS implementation found
stack traceback:
        [string "boot.lua"]:423: in function <[string "boot.lua"]:419>
        [C]: in function 'assert'
        [string "main.lua"]:5: in main chunk
        [C]: in function 'require'
        [string "boot.lua"]:391: in function <[string "boot.lua"]:143>
        [C]: in function 'xpcall'
        [string "boot.lua"]:433: in function <[string "boot.lua"]:426>
        [C]: in function 'xpcall'       1`

The version of cURL we have uses certificates that are placed on the SD Card, but I doubt it's expired by now, but I can also check that.

@TurtleP
Copy link
Copy Markdown
Contributor

TurtleP commented Apr 7, 2024

Digging further, it's not even enabling cURL as a backend:

HTTPSClient::Reply request(const HTTPSClient::Request& req)
{
    std::printf("request\n");
    for (size_t i = 0; clients[i]; ++i)
    {
        HTTPSClient& client = *clients[i];
        std::printf("client.valid()? %d\n", client.valid());
        if (client.valid())
            return client.request(req);
    }
    throw std::runtime_error("No applicable HTTPS implementation found");
}

This doesn't even print inside the for loop. I'm sure I missed something stupid, going to check the source a bit closer to see what it might be.

@TurtleP
Copy link
Copy Markdown
Contributor

TurtleP commented Apr 7, 2024

Copy link
Copy Markdown
Contributor

@MikuAuahDark MikuAuahDark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In overall, I think it looks good to me.

Comment thread src/CMakeLists.txt
@bartbes bartbes mentioned this pull request Apr 13, 2024
@MikuAuahDark MikuAuahDark merged commit c40585b into love2d:main Apr 20, 2024
@bartbes bartbes deleted the selectable_library_loaders branch April 21, 2024 11:50
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.

[Request] cURL compile-time option

3 participants