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 -file-compilation-dir #40735
Conversation
e5e911a
to
ce7377e
Compare
@swift-ci test |
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.
seems proper to me
Clang has quite a few flags here that imply different things, both for mappings like the IMO it is worth considering introducing the equivalent of |
Build failed |
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, this is a nice improvement! Some comments inline.
lib/Driver/ToolChains.cpp
Outdated
@@ -334,6 +334,8 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI, | |||
auto OptArg = inputArgs.getLastArgNoClaim(options::OPT_O_Group); | |||
if (!OptArg || OptArg->getOption().matches(options::OPT_Onone)) | |||
arguments.push_back("-enable-anonymous-context-mangled-names"); | |||
|
|||
inputArgs.AddAllArgs(arguments, options::OPT_debug_compilation_dir); |
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.
Does this code need to be added to the Swift implementation of the driver, too? (I haven't looked at the Swift driver code recently so I'm not sure)
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.
Yes, I think so. My plan is to address this in the follow up PR.
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.
I think it may be preferable to do both at once, to keep the implementations in sync at all times.
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.
Created a PR for Swift-implemented driver.
23fba6c
to
dd128cc
Compare
Could you please add a test to ensure that the Windows path separator is handled properly? ( |
The existing |
Yes, I would. If you note the |
Do you suggest one test for unix and another one for Windows style paths? eg:
|
e303397
to
e8d2e7e
Compare
bumping this. @pofat what do you think? |
@keith the page linked to for |
Wouldn't we want both? Seems odd that clang would have multiple flags but Swift wouldn't. |
Sorry it's Fair question for sure, I think clang's setup has gotten a bit complex related to this stuff, so it wasn't that they have many separate flags intentionally, but more because they can't ever remove any for backwards compatibility but that's just my take. For reference clang has:
Where the |
Hi @kastiglione @keith, how about having both flags? Personally, I would like to have this flag done in this PR, then do Not sure what's the best strategy to decide what flags should migrate to Swift. Probably just follow what Clang has, IMO. |
I will defer to the swift maintainers in general here, but my thought was just instead of doing a 1:1 copy from clang we could try to reduce the user facing complexity here, unless we can come up with compelling reasons for them to be separate. |
@swift-ci please smoke test |
2. Implement the logic: Configure DebugCompilationDir with the path specified by the flag, otherwise with current working directory. 3. Add test case
2. Use %target-swiftc_driver for test case instead 3. Add test case for absolute path 4. Code clean
2. Add a test case for path `.` 3. Use regular expression for file path separator 4. Remove std::string() constructor 5. Remove ArgumentIsPath flag
25fc8e5
to
a76960e
Compare
Thanks for the clear explanation of all options! Took option 2 and updated this PR. Also fixed the failed windows test. |
03e6a31
to
3ec1c0b
Compare
2. Fix windows test case
3ec1c0b
to
70c4b38
Compare
@swift-ci test |
The tests and the PR still mention |
@kastiglione I am sorry, might undo some old code while pushing. All fixed. |
Build failed |
@swift-ci test |
@swift-ci test Windows Platform |
can you update the flag for the swift-driver PR as well, in case that results in a separate set of eyes? |
Sure, I can. Working on it. |
Done updating |
@swift-ci test Windows Platform |
Thanks! I am working on fix the failed windows test case. Will update once I fix it. |
@swift-ci please smoke test |
@kastiglione failed windows test is fixed. Would you like to review it? |
@adrian-prantl @kastiglione can you help me merger this PR? Thank you! |
This PR adds a new flag
-file-compilation-dir
, which does the same thing as-ffile-compilation-dir
in Clang.swiftc -g -ffile-compilation-dir=. path/to/foo.swift
gives us identical debug info paths regardless of what location we compiled the file from. It's useful to debug correctly using object files built on different machines in different locations.There's also a long-existed TODO comment.
Resolves SR-5694