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

Implement current_exe for AIX #104521

Closed
wants to merge 5 commits into from
Closed

Conversation

bzEq
Copy link
Contributor

@bzEq bzEq commented Nov 17, 2022

Added current_exe implementation for AIX. This implementation doesn't rely on system specific syscalls, I guess some other targets can also use it.

@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2022

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 17, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@bzEq bzEq marked this pull request as draft November 17, 2022 08:10
@rust-log-analyzer

This comment has been minimized.

if let Some(pstr) = path.to_str() && pstr.contains("/") {
return getcwd().map(|cwd| cwd.join(path))?.canonicalize();
}
// Search PATH to infer current_exe.
Copy link
Member

Choose a reason for hiding this comment

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

Are we searching PATH and PWD on other platforms today? I'm not sure we should do that here -- it increases the amount of work done and if it's not done on other platforms is somewhat inconsistent (and could have false positives much more easily).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we searching PATH and PWD on other platforms today?

I don't know much about other rare seen platforms. On AIX, we don't have information like /proc/self/exe in /proc filesystem. We are using similar method in LLVM on AIX right now, see https://github.com/llvm/llvm-project/blob/42b21ddaadd3545945f29a8ccdcc89779542c30e/llvm/lib/Support/Unix/Path.inc#L251. (Actually, we don't have /proc/curproc/file on AIX).

Copy link
Member

Choose a reason for hiding this comment

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

Right, but you're using argv[0] just above which is what we do on other platforms (AFAICT, looking in this file, for example).

I am inclined to leave it there unless there's strong motivation for doing this cwd/path traversal. current_exe is documented as fallible for a reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extended the one for fuchsia. Correct me if I still failed to get your point. :)

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum Dec 17, 2022

Choose a reason for hiding this comment

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

Apologies if I wasn't clear. I think we should remove the PATH searching from this function, just returning the passed argument. IOW, I think if just adding aix to the fuchsia function works, then that seems like the right initial implementation here. (Not adding any other code to it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should remove the PATH searching from this function, just returning the passed argument.

Could you please elaborate more about your concerns of searching in PATH here? Cuz on AIX, we don't have other methods to find the executable file of current process if argv0 is not an absolute path.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 5, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling addr2line v0.17.0
error: unexpected `cfg` condition value
   --> library/std/src/sys/unix/os.rs:454:34
    |
454 | #[cfg(any(target_os = "fuchsia", target_os = "aix"))]
    |
    |
    = note: expected values for `target_os` are: android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous
    = note: `-D unexpected-cfgs` implied by `-D warnings`
error: could not compile `std` due to previous error
Build completed unsuccessfully in 0:00:23

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 12, 2022
@workingjubilee workingjubilee added the O-aix OS: Big Blue's Advanced Interactive eXecutive.. label Feb 5, 2023
@bzEq
Copy link
Contributor Author

bzEq commented May 10, 2023

Hi @Mark-Simulacrum , this PR is subsumed by #109882, could you please help review that PR?

@bzEq bzEq closed this May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-aix OS: Big Blue's Advanced Interactive eXecutive.. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants