-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cygwin support in rustc #140154
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
Cygwin support in rustc #140154
Conversation
rustbot has assigned @compiler-errors. Use |
This comment was marked as outdated.
This comment was marked as outdated.
I'm looking forward to being able to try this, and I bet @tyan0 and others from Cygwin are too! |
This should be fixed now (llvm/llvm-project#136599), and
|
This comment was marked as outdated.
This comment was marked as outdated.
7ee303f
to
d23fa03
Compare
r? @jieyouxu |
Co-authored-by: Ookiineko <[email protected]>
The Miri subtree was changed cc @rust-lang/miri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine, I'll r+ after PR CI is green.
@bors r+ |
let fname_ptr = info.dli_fname.as_ptr(); | ||
#[cfg(not(target_os = "cygwin"))] | ||
let fname_ptr = { | ||
if info.dli_fname.is_null() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this can be null? I can't find that in the docs. Miri seems to assume it's never null...
(This is pre-existing, not new in this PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://man7.org/linux/man-pages/man3/dladdr.3.html
If the address specified in addr could not be matched to a shared
object, then these functions return 0. In this case, an error
message is not available via dlerror(3).
My read of that is that either it finds a shared object, in which case dli_fname is valid, or else it will return 0 (but not tell you why in dlerror).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dladdr
can return null, yes. That's handled above. I am talking about dli_fname
being null, which is different and which should not be possible according to the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a PR for this: #141239
Cygwin support in rustc This PR builds host rustc targeting cygwin. - [x] rust-lang/stacker#122 - [x] nagisa/rust_libloading#173 - [x] Detegr/rust-ctrlc#131 - [x] rust-random/getrandom#654 - [x] msys2/MSYS2-packages#5350 - [x] rust-lang#140886 - [x] rust-lang#140921 - [x] rust-lang#140973 Currently supported: * rustc * rustdoc * rustfmt * clippy Blocking: * cargo: blocked by rust-lang/socket2#568 * rust-analyzer: needs `cargo update`, fixed upstream ``` $ rustc --version --verbose rustc 1.88.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-pc-cygwin release: 1.88.0-dev LLVM version: 20.1.4 ```
Rollup of 6 pull requests Successful merges: - rust-lang#127013 (Add `f16` formatting and parsing) - rust-lang#140154 (Cygwin support in rustc) - rust-lang#140628 (std: stop using TLS in signal handler) - rust-lang#140966 (Remove #![feature(let_chains)] from library and src/librustdoc) - rust-lang#140994 (replace `cc_detect::cc2ar` with `cc::try_get_archiver`) - rust-lang#141127 (bump windows crate for compiler,bootstrap and tools) r? `@ghost` `@rustbot` modify labels: rollup
Cygwin support in rustc This PR builds host rustc targeting cygwin. - [x] rust-lang/stacker#122 - [x] nagisa/rust_libloading#173 - [x] Detegr/rust-ctrlc#131 - [x] rust-random/getrandom#654 - [x] msys2/MSYS2-packages#5350 - [x] rust-lang#140886 - [x] rust-lang#140921 - [x] rust-lang#140973 Currently supported: * rustc * rustdoc * rustfmt * clippy Blocking: * cargo: blocked by rust-lang/socket2#568 * rust-analyzer: needs `cargo update`, fixed upstream ``` $ rustc --version --verbose rustc 1.88.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-pc-cygwin release: 1.88.0-dev LLVM version: 20.1.4 ```
Rollup of 10 pull requests Successful merges: - rust-lang#127013 (Add `f16` formatting and parsing) - rust-lang#138940 (Stabilize the avx512 target features) - rust-lang#140154 (Cygwin support in rustc) - rust-lang#140490 (split `asm!` parsing and validation) - rust-lang#140628 (std: stop using TLS in signal handler) - rust-lang#140746 (name resolution for guard patterns) - rust-lang#140926 (Return value of coroutine_layout fn changed to Result with LayoutError) - rust-lang#141127 (bump windows crate for compiler,bootstrap and tools) - rust-lang#141214 (Miri subtree update) - rust-lang#141218 (gvn: avoid creating overlapping assignments) r? `@ghost` `@rustbot` modify labels: rollup
Cygwin support in rustc This PR builds host rustc targeting cygwin. - [x] rust-lang/stacker#122 - [x] nagisa/rust_libloading#173 - [x] Detegr/rust-ctrlc#131 - [x] rust-random/getrandom#654 - [x] msys2/MSYS2-packages#5350 - [x] rust-lang#140886 - [x] rust-lang#140921 - [x] rust-lang#140973 Currently supported: * rustc * rustdoc * rustfmt * clippy Blocking: * cargo: blocked by rust-lang/socket2#568 * rust-analyzer: needs `cargo update`, fixed upstream ``` $ rustc --version --verbose rustc 1.88.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-pc-cygwin release: 1.88.0-dev LLVM version: 20.1.4 ```
@bors retry (yield to rollup, sry) |
Cygwin support in rustc This PR builds host rustc targeting cygwin. - [x] rust-lang/stacker#122 - [x] nagisa/rust_libloading#173 - [x] Detegr/rust-ctrlc#131 - [x] rust-random/getrandom#654 - [x] msys2/MSYS2-packages#5350 - [x] rust-lang#140886 - [x] rust-lang#140921 - [x] rust-lang#140973 Currently supported: * rustc * rustdoc * rustfmt * clippy Blocking: * cargo: blocked by rust-lang/socket2#568 * rust-analyzer: needs `cargo update`, fixed upstream ``` $ rustc --version --verbose rustc 1.88.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-pc-cygwin release: 1.88.0-dev LLVM version: 20.1.4 ```
Rollup of 6 pull requests Successful merges: - rust-lang#127013 (Add `f16` formatting and parsing) - rust-lang#130887 (Safer implementation of RepeatN) - rust-lang#140154 (Cygwin support in rustc) - rust-lang#140874 (make `rustc_attr_parsing` less dominant in the rustc crate graph) - rust-lang#141094 (add regression test for rust-lang#101650) - rust-lang#141110 ([std] fix the presentation of `split_off_mut` and `split_off` documentation) r? `@ghost` `@rustbot` modify labels: rollup
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 4d051fb (parent) -> e42bbfe (this PR) Test differencesNo test diffs found Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard e42bbfe1f7c26f8760a99c4b1f27d33aba1040bb --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (e42bbfe): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary 0.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary -0.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 775.275s -> 774.961s (-0.04%) |
@@ -46,7 +46,7 @@ pub fn dylib_path() -> Vec<std::path::PathBuf> { | |||
/// Given an executable called `name`, return the filename for the | |||
/// executable for a particular target. | |||
pub fn exe(name: &str, target: &str) -> String { | |||
if target.contains("windows") || target.contains("cygwin") { | |||
if target.contains("windows") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this. I just had to re-discover this change because bootstrap panicked not finding rustc-main
when it was named rustc-main.exe
, cross-compiling from Windows to Cygwin. While Cygwin does have 'magic' that will let you access a file X.exe by the name X, some other host wouldn't know to do that. What was the problem that reverting this change addressed, and is there maybe some other way to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rustc wrapper of bootstrap failed to determine the correct parameters. The wrapper is executed like /foo/rustc /bar/rustc --baz
.
I think there should be other solutions, but it's only a bootstrap tool. So rely on the cygwin magic is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that bootstrap tool was the general way to cross-compile rust (build != host), and that should work for build != cygwin host = cygwin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it might be complex then... Although the bootstrap tool should provide a way to cross-compile, it's not that common to cross compile from Windows to a Unix platform (Cygwin). Yet it would be better if it can support that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux to Cygwin should work though? I might try that and see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see what the problem is - /proc/self/exe
's target is without the .exe
extension, so the comparison in bootstrap's rustc wrapper would not match on a Cygwin host if this function returned the name with .exe
appended. However, on a non-Cygwin host, bootstrap needs to know that executables for a Cygwin target will have a .exe
extension. I'm not sure how to reconcile these two different uses of exe
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux to Cygwin should work though?
The great pioneer @Ookiineko succeeded compiling rustc from Fedora to Cygwin.
This PR builds host rustc targeting cygwin.
ctrlc
,libloading
andnix
for rustc #140921Currently supported:
Blocking:
cargo update
, fixed upstream