-
Notifications
You must be signed in to change notification settings - Fork 987
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
Support portable boot files on more platforms #732
Conversation
I like the idea of more support for executable-relative boot files. There are a many pitfalls to getting the current executable's path on Unix variants, though. For example, a fixed Here's the code that Racket uses: https://github.com/racket/racket/blob/master/racket/src/start/self_exe.inc I wonder whether it would make sense to put (a cleaner version of) this code in the Chez Scheme tree for use both by Chez Scheme and clients like Racket. This code has has been tested and refined for a while, at least. Or maybe there's another existing implementation that would be better to start with? |
It would be excellent to reuse battle-tested Racket version. And there are some problems we need to solve:
|
This Stack Overflow answer mentions a few OS interfaces that Racket isn't using: https://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe (eg for Solaris) but mostly aligns with the current Racket code. https://github.com/gpakosz/whereami seems to be the only other project that I've found that attempts to be as comprehensive. It's hard for me to tell the differences at a glance. |
Maybe Chez Scheme should provide a |
I found that Current executable file path detection method in 6f87bf7 is based on Racket version and LLVM version, with proper simplification for better readability. |
@ur4t What do you think of the approach at https://github.com/mflatt/ChezScheme/tree/selfexe, where "self_exe.c" is kept as a separate file? That way, Racket variants can use the same implementation, and the amount of code to maintain stays the same from my perspective (although it's more code for Chez Scheme). I saw that you had added |
A separate file is much clearer and actually reduces the maintenance burden, but maybe we should name it "self-exe.c" to keep consistent with other c files. I skimmed the patch, and found that there's no
Manpage of I chose to use Personally I think the simplified version is good for maintenance, but it is better to seperate the simplification into another PR. Modifications in this PR follows c99 standard, and I am considering utilizing features proposed by new standards such as c11 and c17 to reduce cross-platform efforts. Is there a compiler support guideline? |
I agree about "self-exe.c". Also, probably the function name Good point about I think that man page of Using I don't know whether the Chez Scheme implementors have already declared a particular C variant to use, but I think we should stick to C99. |
e45abfa adds a proxy function Currently no other improvement is implemented, to minimize difference between I do not know where to statement this PR in the release note, maybe a more precise workflow description is necessary. Is this PR ready to be merged? |
Thanks for this improvement! How about making No need to hold back on improvements to For the release notes, the note would be a new subsection at the top of "Functionality Changes". |
On Windows, `get_process_executable_path` always returns `char *`. On Unix, use this uniform approach, with symbolic links resolved: 1. use platform provided approach; 2. use argv[0] if it contains path separator; 3. search via `PATH`.
Now
Currently Feature macros On Racket side, CS part can remove |
Some last things I notice:
|
Fix build failure on FreeBSD. Fix compiler warning on Solaris. Improve documentation about `S_get_process_executable_path`.
Those issues are fixed in 012b295.
There is a rare circumstance under which resolving all symbolic links will create trouble: users expect to obtain a symlink to the path that was used to start the program, and not the eventual binary file. I think it is a good idea to keep a consistent behaviour with LLVM, which means to resolve all symbolic links via |
This now looks good to me. I've tried it out via #755 and also confirmed (as much as I can) that Racket can take advantage of "self-exe.c" for its own search. |
Support portable boot files (
%x
) on more platforms