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

KTOR-6754 Use static libcurl build with conan #4445

Merged
merged 4 commits into from
Nov 19, 2024
Merged

Conversation

whyoleg
Copy link
Contributor

@whyoleg whyoleg commented Nov 2, 2024

Subsystem
ktor-client-curl

Motivation
Simplify depending on libcurl.
Similar to #3981 but with different way of building libcurl

Solution
libcurl was built on GitHub actions via Conan and produced libraries are copied.

I have only Mac and linking for all targets was successful. Probably some flags will need to be adopted during libcurl building so that all features are supported.

@e5l e5l self-requested a review November 4, 2024 10:46
@whyoleg
Copy link
Contributor Author

whyoleg commented Nov 5, 2024

Some notes:

  • windows with curl works fine! looks like other failures are unrelated. Also, I see, that Native on Windows x64 is not run be default. Is it expected? Looks like there is some issue with environ there and so ktor-server-core linking error happens
  • linux: not sure, why there is an issue with linking there... I don't have linux PC at my side so can investigate only via CI. Also, for linux, it's possible to dynamically link to both curl and openssl, as it's probably will be available all the time, still, because of old GCC used in K/N it will be cumbersome to build final binary when users depend on ktor-client-curl - they will need curl and openssl compatible with old glibc :( That's why I decided to do static linking there
  • macOS: no openssl is used at all! Conan allows to build curl with out-of-the-box support, so it's nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: libz should be statically linked on mingw, without it, mingw build binaries will not work on Windows. Context: whyoleg/cryptography-kotlin#13

@e5l
Copy link
Member

e5l commented Nov 7, 2024

@whyoleg, could you check compilation errors on linux x64?

Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

fails locally for linuxX64

@e5l
Copy link
Member

e5l commented Nov 7, 2024

let me check if I can fix it

@e5l
Copy link
Member

e5l commented Nov 7, 2024

It looks like the problem is with version of open SSL or build flags. I have found similar issues referring to the version bump:
https://stackoverflow.com/questions/46768071/openssl-linking-undefined-reference-evp-md-ctx-new-and-fre
https://stackoverflow.com/questions/42789278/undefined-reference-to-des-ecb-encrypt-md4-init-md4-update-and-md4-final

@whyoleg, could you tell me what versions and flags are used to build libssl?

@e5l e5l mentioned this pull request Nov 7, 2024
@whyoleg
Copy link
Contributor Author

whyoleg commented Nov 7, 2024

could you tell me what versions and flags are used to build libssl?

Full information can be found in build log: /~https://github.com/whyoleg/openssl-builds/actions/runs/11719854910/job/32643991499
OpenSSL: 3.3.2
It was configure by running:

perl ./Configure "conan-Release-Linux-x86_64-gcc-8" no-shared --release --prefix=/ --libdir=lib --openssldir="/etc/ssl" threads PERL=perl no-unit-test no-tests -fPIC enable-fips no-md2 zlib --with-zlib-include="/home/runner/.conan2/p/b/zlib459920bf74d77/p/include" --with-zlib-lib="/home/runner/.conan2/p/b/zlib459920bf74d77/p/lib"

so mostly all default flags. Here are the options which are configurable with Conan.

I've also rerun the job to copy all transitive libraries (previously I've taken openssl from other build). Let's see if it will make any sense. UPDATE: no difference, same failure

Though, it's really strange, that it works locally on macOS. May be there is some native cache on CI?

@whyoleg
Copy link
Contributor Author

whyoleg commented Nov 7, 2024

@e5l I've disabled native caches via (kotlin.native.cacheKind.linuxX64=none) as suggested in error and now the linking issue is gone. So looks like this could be an issue at K/N side...

@e5l
Copy link
Member

e5l commented Nov 7, 2024

thanks, will check soon

@e5l e5l force-pushed the 3.1.0-eap branch 2 times, most recently from ce83e36 to ccb920f Compare November 14, 2024 10:25
@e5l e5l self-requested a review November 18, 2024 08:24
@e5l
Copy link
Member

e5l commented Nov 18, 2024

Hey @olme04, lgtm! Could you rebase it on 3.1.0-eap?

@whyoleg
Copy link
Contributor Author

whyoleg commented Nov 18, 2024

@e5l I've rebased on 3.1.0-eap and also moved kotlin.native.cacheKind.linuxX64=none flag to ktor-client-curl module, so that it will affect only it and looks like it works fine.
I will create an issue on YT and link it in comment message here

@e5l e5l merged commit 0ea62fc into ktorio:3.1.0-eap Nov 19, 2024
11 of 14 checks passed
@e5l
Copy link
Member

e5l commented Nov 19, 2024

Hey @whyoleg, thank you for the nice contribution! btw, it would be great to have an action in the Ktor repo, so we can regenerate dependencies from time to time

e5l pushed a commit that referenced this pull request Nov 19, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
@whyoleg
Copy link
Contributor Author

whyoleg commented Nov 19, 2024

it would be great to have an action in the Ktor repo

Do you want to do it using GitHub Actions or TC pipeline? I could help to setup both, or you could try to do it on your own based on my setup :)
I think it will be easier to discuss this if you will approach me in Slack.

BTW: this PR fixes https://youtrack.jetbrains.com/issue/KTOR-6754/Support-static-linking-for-curl-on-all-platforms - is it possible to link it somehow after it was merged? :)
Also probably those issues should be marked as obsolete/fixed:

Probably there could be others, I've checked this YT query: https://youtrack.jetbrains.com/issues/KTOR?q=curl

@89jd
Copy link

89jd commented Nov 19, 2024

Hi @e5l @whyoleg .

I have been away the past few weeks. This looks good!

I could have a look at setting up the pipeline to build curl if needed? Would be good to do this, as I started looking at getting curl with web sockets implemented too.

What do you think would be the best way to do it so that when the curl version changes it updates all the static libraries for all of the platforms?

e5l pushed a commit that referenced this pull request Nov 25, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Nov 26, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Nov 27, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Nov 28, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Nov 29, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Dec 3, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Dec 3, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Dec 6, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Dec 11, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Dec 11, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Dec 12, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Dec 12, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
@osipxd
Copy link
Member

osipxd commented Dec 12, 2024

@whyoleg, @e5l could you check if this failure on CI is connected to this PR?

@whyoleg
Copy link
Contributor Author

whyoleg commented Dec 12, 2024

@osipxd yes, this is the same error which was before I disabled the caches there.
And last build for this branch was successful.
Also, probably update to Kotlin 2.1.0 could solve the issue (and cache flag could be removed) as I see no issues with this task in PR with Kotlin update

@dtretyakov
Copy link
Contributor

@whyoleg thanks for your work. Is it possible to enable WebSockets in these curl builds?

@whyoleg
Copy link
Contributor Author

whyoleg commented Dec 19, 2024

@dtretyakov, yeah, sure: #4564
Tested, that at least some of the tests on macosArm64 for curl are working on your branch, so built libcurl is definitely supports web sockets:
image

@dtretyakov
Copy link
Contributor

@whyoleg thank you for such a fast update.

osipxd pushed a commit that referenced this pull request Dec 19, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
Stexxe pushed a commit that referenced this pull request Dec 24, 2024
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
e5l pushed a commit that referenced this pull request Jan 8, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Jan 8, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Jan 9, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Jan 9, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Jan 9, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
osipxd pushed a commit that referenced this pull request Jan 9, 2025
* Test libcurl build with conan

* Take both curl and openssl from the same build

* test no linux cache

* Move K/N linux cache disabling to just `ktor-client-curl` module
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.

5 participants