Skip to content

Allow Arguments in -driver-use-frontend-path #22596

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

Merged
merged 1 commit into from
Feb 20, 2019

Conversation

gmittert
Copy link
Contributor

Windows doesn't know what a shebang is, so it's unable to run tests that
use -driver-use-frontend-path with a script. This allows the script
interpreter to be run as the executable with the script as its first
argument. e.g. --driver-use-frontend-path "python;my-script.py"

This fixes one of the tests on Windows as an example. I'll fix the rest in another PR. This is still compatible with just calling the script with a shebang on macOS/Linux.

@jrose-apple @compnerd

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Yuck and thank you.

@@ -191,7 +194,11 @@ class Driver {
const std::string &getSwiftProgramPath() const {
return DriverExecutable;
}


const ArrayRef<std::string> getSwiftProgramArgs() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for const; ArrayRefs are already by-value.

@@ -165,6 +165,9 @@ class Driver {
/// The original path to the executable.
std::string DriverExecutable;

// Extra args to pass to the driver executable
SmallVector<std::string, 10> DriverExecutableArgs;
Copy link
Contributor

Choose a reason for hiding this comment

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

This could probably be something like 2 or 4 with nothing lost in practice. (Yeah, I know there's only one of these, but still.)

DriverExecutable = A->getValue();
if (Args.hasArg(options::OPT_driver_use_frontend_path)) {
std::string commandString =
Args.getLastArgValue(options::OPT_driver_use_frontend_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why you changed this from using getLastArg. (It's going to do two searches now…not that we're particularly efficient about that right now.)

@gmittert gmittert force-pushed the AnArgumentAsideAnAnaconda branch from b41ffae to 82b219f Compare February 14, 2019 00:56
@gmittert
Copy link
Contributor Author

Yuck indeed :p. I've fixed up the things you've pointed out.

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -930,6 +942,8 @@ ToolChain::constructInvocation(const GenerateDSYMJobAction &job,
assert(context.Output.getPrimaryOutputType() == file_types::TY_dSYM);

ArgStringList Arguments;
for (auto &s : getDriver().getSwiftProgramArgs())
Arguments.push_back(s.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a frontend job.

@@ -950,6 +964,9 @@ ToolChain::constructInvocation(const VerifyDebugInfoJobAction &job,

// This mirrors the clang driver's --verify-debug-info option.
ArgStringList Arguments;
for (auto &s : getDriver().getSwiftProgramArgs())
Arguments.push_back(s.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

…nor this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Missed this one.

@gmittert gmittert force-pushed the AnArgumentAsideAnAnaconda branch from 82b219f to 0bb84f4 Compare February 14, 2019 04:42
@gmittert
Copy link
Contributor Author

Removed. In general, which jobs are considered frontend jobs?

@jrose-apple
Copy link
Contributor

I'm not sure that was exactly the right term, but in general you should only be doing this in places where DriverExecutable is being used as the executable.

@jrose-apple
Copy link
Contributor

Another rule would be "only the jobs that actually pass '-frontend'".

@gmittert gmittert force-pushed the AnArgumentAsideAnAnaconda branch 2 times, most recently from fc3f455 to 3c5be6c Compare February 15, 2019 00:30
@gmittert
Copy link
Contributor Author

Ah, I see, anything that set its ExecutableName to SWIFT_EXECUTABLE_NAME

Windows doesn't know what a shebang is, so it's unable to run tests that
use -driver-use-frontend-path with a script. This allows the script
interpreter to be run as the executable with the script as its first
argument. e.g. --driver-use-frontend-path "python;my-script.py"
@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@jrose-apple jrose-apple self-assigned this Feb 20, 2019
@jrose-apple
Copy link
Contributor

Uh, hm.

@swift-ci Please smoke test Linux

@jrose-apple
Copy link
Contributor

Looks like CMark is busted for some reason; we'll have to wait until that's fixed.

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test Linux

@jrose-apple jrose-apple merged commit 9eeabc9 into swiftlang:master Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants