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

Try to make exename portable. Refactor searchForIncludePath. #5185

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Mar 19, 2025

Fixes #3812.

Ran into this while working on a PR. Turns out exename doesn't seem to properly work. Maybe this approach works better? Still trying to figure out the right approach for getExecutablePath.

Also use std::filesystem::path to set the include path instead of char manipulation.

This change preserves all APIs, still marking as breaking in case there are some differences in behavior.

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Mar 19, 2025
@fruffy fruffy force-pushed the fruffy/exename branch 2 times, most recently from e4df393 to 5d6bb23 Compare March 19, 2025 13:15
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy added the breaking-change This change may break assumptions of compiler back ends. label Mar 19, 2025
@fruffy fruffy marked this pull request as ready for review March 19, 2025 17:01
@fruffy fruffy requested review from ChrisDodd, asl and vlstill March 19, 2025 17:01
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy added run-ubuntu18 Use this tag to trigger a Ubuntu-18 CI run. run-validation Use this tag to trigger a Validation CI run. run-sanitizer Use this tag to run a Clang+Sanitzers CI run. run-static Use this tag to trigger static build CI run. labels Mar 19, 2025
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Copy link
Contributor

@asl asl left a comment

Choose a reason for hiding this comment

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

See comments

bool ParserOptions::searchForIncludePath(const char *&includePathOut,
std::vector<cstring> userSpecifiedPaths,
const std::vector<cstring> &userSpecifiedPaths,
const char *exename) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can exename be converted to std::filesystem::path while here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This would break downstream use of that function, figured I should do that in a separate PR. Ditto for all the cstring typing of variables that should be a path.

bool ParserOptions::searchForIncludePath(const char *&includePathOut,
std::vector<cstring> userSpecifiedPaths,
const std::vector<cstring> &userSpecifiedPaths,
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to vector of std::filesystem::path?

const char *separator = cwd[cwdLen - 1] == '/' ? "" : "/";
std::filesystem::path getExecutablePath(const std::filesystem::path &suggestedPath) {
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
// Find the path of the executable. We use a number of techniques that may fail or work on
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Figured we shouldn't depend on external dependencies for a utility like this. Particularly boost which we want to get rid of. Let me take a look at whereami

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Though there is bunch of domain knowledge here :(

@fruffy fruffy force-pushed the fruffy/exename branch 2 times, most recently from 87ef696 to 3d7dbe3 Compare March 20, 2025 19:48
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy requested a review from asl March 22, 2025 05:42
@fruffy
Copy link
Collaborator Author

fruffy commented Mar 22, 2025

The Ubuntu failure is unrelated, should be fixed with #5177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This change may break assumptions of compiler back ends. core Topics concerning the core segments of the compiler (frontend, midend, parser) run-sanitizer Use this tag to run a Clang+Sanitzers CI run. run-static Use this tag to trigger static build CI run. run-ubuntu18 Use this tag to trigger a Ubuntu-18 CI run. run-validation Use this tag to trigger a Validation CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exename does not work on Mac OS X
3 participants