Skip to content

Experimental cygwin host support #15442

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

Closed
3 of 4 tasks
Berrysoft opened this issue Apr 21, 2025 · 7 comments · Fixed by #15600
Closed
3 of 4 tasks

Experimental cygwin host support #15442

Berrysoft opened this issue Apr 21, 2025 · 7 comments · Fixed by #15600
Labels
O-windows OS: Windows

Comments

@Berrysoft
Copy link
Contributor

Berrysoft commented Apr 21, 2025

I have built cargo targeting MSYS2(cygwin) successfully, and found it needs some patches. This is the tracking issue.

@jeremyd2019
Copy link

the plan is to wait for the last patch here to be merged & released, and then do a PR to update all the dependencies in Cargo.lock/Cargo.toml at once?

@Berrysoft
Copy link
Contributor Author

Yes. Just waiting for socket2.

@jeremyd2019
Copy link

Can you provide for a cargo novice a patch that would let me try to build cargo on Cygwin? I know there is a way to replace a crate with a reference to git which should work for socket2 but I don't know how to do that or rustix required updates (I tried but it kept fighting me over wanting 0.x instead of 1.x)

@Berrysoft
Copy link
Contributor Author

OK.

diff --git a/Cargo.toml b/Cargo.toml
index 8348c65bb..edb893c1a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,7 +49,7 @@ flate2 = { version = "1.1.1", default-features = false, features = ["zlib-rs"] }
 git2 = "0.20.0"
 git2-curl = "0.21.0"
 # When updating this, also see if `gix-transport` further down needs updating or some auth-related tests will fail.
-gix = { version = "0.71.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] }
+gix = { version = "0.72.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] }
 glob = "0.3.2"
 handlebars = { version = "6.3.1", features = ["dir_source"] }
 hex = "0.4.3"
@@ -255,7 +255,7 @@ cargo-test-support.workspace = true
 gix = { workspace = true, features = ["revision"] }
 # When building Cargo for tests, a safety-measure in `gix` needs to be disabled
 # to allow sending credentials over HTTP connections.
-gix-transport = { version = "0.46.0", features = ["http-client-insecure-credentials"] }
+gix-transport = { version = "0.47.0", features = ["http-client-insecure-credentials"] }
 same-file.workspace = true
 snapbox.workspace = true

@@ -276,3 +276,6 @@ all-static = ['vendored-openssl', 'curl/static-curl', 'curl/force-system-lib-on-

 [lints]
 workspace = true
+
+[patch.'crates-io']
+socket2 = { git = "https://github.com/rust-lang/socket2.git", branch = "v0.5.x" }

Apply the patch and run cargo update.

@BrianInglis
Copy link

Local patch applied by Cygwin OpenSSL maintainer to test release; see Test: openssl 3.0.16-2, mingw64-{i686,x86_64}-openssl-3.0.16-2 and
openssl and libcurl issue with cargo

@mati865
Copy link
Member

mati865 commented May 25, 2025

Have you confirmed Cargo links to OpenSSL DLL? There are some flags that rustc might use to avoid depending on system shared objects:

cargo/Cargo.toml

Lines 272 to 276 in 8d17219

[features]
vendored-openssl = ["openssl/vendored"]
vendored-libgit2 = ["libgit2-sys/vendored"]
# This is primarily used by rust-lang/rust distributing cargo the executable.
all-static = ['vendored-openssl', 'curl/static-curl', 'curl/force-system-lib-on-osx', 'vendored-libgit2']

@jeremyd2019
Copy link

jeremyd2019 commented May 26, 2025

Yes, it was a bit of a mess getting everything to link in my hack "cross-compile" configuration but it did finally work:

PATH="/cygdrive/v/rust/w:/cygdrive/d/test/msys64/clang64/bin:$PATH" \
PKG_CONFIG_SYSROOT_DIR="v:/cygllvm/cygwin64" \
PKG_CONFIG="$(cygpath -w /usr/bin/pkgconf.exe)" \
LIBGIT2_NO_VENDOR=1 \
OPENSSL_DIR="$(cygpath -w /usr)" \
OPENSSL_LIB_DIR="$(cygpath -w /usr/lib)" \
OPENSSL_STATIC=0 \
DESTDIR="$(cygpath -w "$PWD/build-Cygwin/dest-rust")" \
python x.py install --stage 2

and having an exe wrapper curl-config.exe in v:/rust/w (since /usr/bin/curl-config on Cygwin is a shell script)

$ llvm-readobj --coff-imports /usr/bin/cargo | grep Name:
  Name: cyggcc_s-seh-1.dll
  Name: cygcrypto-3.dll
  Name: cygcurl-4.dll
  Name: cygwin1.dll
  Name: cyggit2-1.9.dll
  Name: cygssl-3.dll
  Name: KERNEL32.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows OS: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants