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

Rust build fails on Solaris after: Implement file_lock feature #132921

Closed
psumbera opened this issue Nov 11, 2024 · 6 comments · Fixed by #132977
Closed

Rust build fails on Solaris after: Implement file_lock feature #132921

psumbera opened this issue Nov 11, 2024 · 6 comments · Fixed by #132977
Labels
C-bug Category: This is a bug. O-illumos the other shiny OS O-solaris Operating system: Solaris T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@psumbera
Copy link
Contributor

Solaris OS doesn't support flock() and thus Rust fails to build after #130999 :

d2cdc76256313e8f23f585107c43badb49d5473d is the first bad commit
commit d2cdc76256313e8f23f585107c43badb49d5473d
Author: Christopher Berner [<[email protected]>](mailto:[email protected])
Date:   Sun Sep 22 16:58:44 2024 -0700

    Implement file_lock feature
    
    This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and
    unlock() to File gated behind the file_lock feature flag

with following error:

error: linking with `gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-sysroot/lib/rustlib/x86_64-pc-solaris/bin:/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0/lib/rustlib/x86_64-pc-solaris/bin:/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0/lib/rustlib/x86_64-pc-solaris/bin:/usr/gnu/bin/:/usr/gcc/13/bin:/usr/bin" VSLANG="1033" "gcc" "-m64" "/tmp/rustczm3gUt/symbols.o" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/deps/rustc_main-f7e62c1025f5dce2.rustc_main.39965e3472e7b77a-cgu.0.rcgu.o" "-Wl,-z,ignore" "-Wl,-Bdynamic" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/deps/librustc_driver-60ae461c5c39901a.so" "-Wl,-Bstatic" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-sysroot/lib/rustlib/x86_64-pc-solaris/lib/libcompiler_builtins-579d025a05650947.rlib" "-Wl,-Bdynamic" "-lrt" "-ldl" "-lm" "-lkstat" "-lsocket" "-lz" "-lstdc++" "-lsendfile" "-llgrp" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lsendfile" "-llgrp" "-L" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/build/psm-daa576ffce68f706/out" "-L" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/build/blake3-2e711e7084babad6/out" "-L" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/build/blake3-2e711e7084babad6/out" "-L" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/build/rustc_llvm-2c65a157dbd38377/out" "-L" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/llvm/lib" "-o" "/builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/deps/rustc_main-f7e62c1025f5dce2" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: Undefined            first referenced
           symbol                  in file
          flock                               /builds/psumbera/rust-lang-build/build/x86_64-pc-solaris/stage0-rustc/x86_64-pc-solaris/release/deps/librustc_driver-60ae461c5c39901a.so
          ld: fatal: symbol referencing errors
          collect2: error: ld returned 1 exit status
@psumbera psumbera added the C-bug Category: This is a bug. label Nov 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 11, 2024
@saethlin saethlin added O-solaris Operating system: Solaris T-libs Relevant to the library team, which will review and decide on the PR/issue. O-illumos the other shiny OS and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 12, 2024
@cberner
Copy link
Contributor

cberner commented Nov 12, 2024

Oh, sorry about that breakage. Is there a way for me to test all the Tier 2 targets to make sure they compile? I can send a PR to fix this, but don't have a Solaris machine for testing

@psumbera
Copy link
Contributor Author

For Solaris fcntl locking can be considered. But this will not work within one process. The semantic is different against flock().

You should be able to play with Solaris via https://portal.cfarm.net/machines/list/ (cfarm215 and cfarm216). But previous registration is needed.

@cberner
Copy link
Contributor

cberner commented Nov 13, 2024

Thanks, I requested an account there.

@cberner
Copy link
Contributor

cberner commented Nov 13, 2024

Still waiting for access, so I haven't been able to test this fix. It seems pretty trivial though, so hopefully it's correct

@ivmarkov
Copy link
Contributor

ivmarkov commented Nov 13, 2024

@cberner The new flock API also broke ESP-IDF (another Tier 2 target a Tier 3 target - a single-process embedded one).

As per here, the flock API specifically would never be supported on the ESP-IDF as it is a single-process OS and flock is all about multi-process locking.

The fix in #132977 should take care of the issue for ESP IDF as well I think, simply because it only enables the flock APIs for a few explicitly enumerated platforms, and ESP-IDF is not one of these.

@cberner
Copy link
Contributor

cberner commented Nov 13, 2024

Yep, I didn't realize how many OSs use the unix implementation directory in the standard library, in my original PR. I think #132977 will fix all of them, like you said

@bors bors closed this as completed in 3f9f7c4 Nov 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 15, 2024
Rollup merge of rust-lang#132977 - cberner:fix_solaris, r=tgross35

Fix compilation error on Solaris due to flock usage

PR 130999 added the file_lock feature, but libc does not define flock() for the Solaris platform leading to a compilation error.

Additionally, I went through all the Tier 2 platforms and read through their documentation to see whether flock was implemented. This turned up 5 more Unix platforms where flock is not supported, even though it may exist in the libc crate.

Fixes rust-lang#132921

Related to rust-lang#130999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-illumos the other shiny OS O-solaris Operating system: Solaris T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants