-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Allow Arguments in -driver-use-frontend-path #22596
Conversation
There was a problem hiding this 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.
include/swift/Driver/Driver.h
Outdated
@@ -191,7 +194,11 @@ class Driver { | |||
const std::string &getSwiftProgramPath() const { | |||
return DriverExecutable; | |||
} | |||
|
|||
|
|||
const ArrayRef<std::string> getSwiftProgramArgs() const { |
There was a problem hiding this comment.
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.
include/swift/Driver/Driver.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.)
b41ffae
to
82b219f
Compare
Yuck indeed :p. I've fixed up the things you've pointed out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
lib/Driver/ToolChains.cpp
Outdated
@@ -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()); |
There was a problem hiding this comment.
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.
lib/Driver/ToolChains.cpp
Outdated
@@ -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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…nor this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this one.
82b219f
to
0bb84f4
Compare
Removed. In general, which jobs are considered frontend jobs? |
I'm not sure that was exactly the right term, but in general you should only be doing this in places where |
Another rule would be "only the jobs that actually pass '-frontend'". |
fc3f455
to
3c5be6c
Compare
Ah, I see, anything that set its |
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"
3c5be6c
to
2884902
Compare
@swift-ci Please smoke test |
Uh, hm. @swift-ci Please smoke test Linux |
Looks like CMark is busted for some reason; we'll have to wait until that's fixed. |
@swift-ci Please smoke test Linux |
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