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
Improve usability of -l flag #38750
Improve usability of -l flag #38750
Conversation
Requesting review from @varungandhi-apple I have few queries:
|
That test has a When I wrote it in the bug report, I hadn't realized that this test was actually turned off. In the meantime, you could add new test file until that is turned back on.
I don't think there needs to be a separate test but you could modify this line:
To include a |
I tried writing the same test which I added, to a new file. Turns out its expecting -l boo for that case. Is it an expected behavior? The driver code has to take care of l flag while handling a repl/Interpret(not sure what that is). So I think it is ok to emit a space in this case. Or maybe it is assumed that there will never be a space after l flag? Please correct me if I am wrong.
This is done and works as expected! |
For places where you are checking some invocation of a different executable (such as checking the flags passed to clang, lldb or the linker) by the compiler, the output needs to omit the space, because that was the old behavior. The only change is in what the Swift compiler itself accepts. If the test requires |
I understand, this a wip commit fixing the memory leak you pointed out earlier. Will do a clang-format in the end when I figure out why its adding the space. Thank you for reviewing! |
This really seems like a very odd departure. None of the unix-ish compiler drivers support a separated |
I don't think that's really a good justification. Here's a snippet from
Requiring people to remember odd rules isn't helpful. Also, it's not the case that for people used to
Well then maybe this should be changed in Clang too... If we keep flag behaviors aside for a little bit and look at flag names, Swift has definitely prioritized internal consistency and readability/usability over consistency with Clang. Compare:
This change is in a similar vein, where the old thing continues to work but there is an incremental improvement.
Isn't that's a bigger departure from we have already today and other tools? I'm a little confused because it seems like you're not in favor of making this small change but you're in favor of making a larger change? I'm not opposed to making larger improvements (I haven't given too much thought to this particular proposal), but I think we should try to make small improvements too if possible until large improvements get made. |
The -l args values are handled by OPT_l and OPT_linker_option_Group, to do this have created a helper method under Toolchain
@varungandhi-apple : Did clang formatting, Figured out the arguments of -l is sent by linker_option_Group - handled it seperately. I do have one question l with a space seems to be a problem with lldb but while passing it to clang it is not a problem though (looks like clang can have space after -l flag). So is it necessary to do that? Thank you for reviewing. |
@varungandhi-apple correct, I'm against this change. I think that it is making a small change that really doesn't have much value (IMO). The separated In the case of swiftc, we do need For the linker flags, it makes more sense to change the behaviour more drastically rather than these small divergences that add up and we have to provide backwards support indefinitely. |
I know this is a subjective thing, so I tried to ask some other folks on what they thought (considering the possibility that I was over-valuing the change because I filed the JIRA). I got +1s from @jckarter and @beccadax on this change, even if it only improves usability by a small amount.
This isn't a concern (at least for me) and it could break downstream code. As I said earlier, I very much believe "Requiring people to remember odd rules isn't helpful". From the compiler's point of view, being specific about spaces in certain places and not others isn't really buying us anything.
I'm not suggesting changing the build rules though. If the concern here is that it will lead to issues when someone is changing the build, due to CMake reasons, then they can fix it then. Even with the current state, you will break things if you add a space after the |
It's not strictly necessary but I think it would be preferable to be consistent in our output. |
Since this is a driver change to option parsing, I think this needs a matching PR for apple/swift-driver. |
What do you think of spelling the separate version |
Yes will take a look into that! |
@varungandhi-apple pardon me for these amateur level questions. But using the guide provided I'm unable to build swift driver for linux.
This is an error I get when I use cmake to build yams. I am unable to use swift package manager (swift build) on yams, argument-parser etc as I just get Illegal Instruction (core dumped). Could you point me to any relevant information regarding building on linux. Thank you! P.S. I got swift core libs to build with --xctest flag. Its the other requirements that I am unable to build. Edit : I was able to compile swift driver on mac and start working on the pr. But still any help on linux would be nice! |
Sure, if you'd like to add the separately, that's fine by me. I don't see that as an alternative to this PR.
You don't need to apologize. If something is not working, that is something that we need to fix in the code or docs. It seems like there is a bug in the build for Linux, we shouldn't be crashing like this. I don't know of a solution off the top of my head, but I will take a look at it and get back to you. |
@swift-ci smoke test |
1 similar comment
@swift-ci smoke test |
Here's the failure on macOS:
|
@swift-ci smoke 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.
Here's the failure on macOS:
Fixed the failing part, could you trigger this again please?
I have fixed the failure on the swift-driver side as well. So please check for that as well
@swift-ci smoke test |
@varungandhi-apple the failing tests are not related to my pr(or maybe) do I have to do something for this? |
It looks like a build system problem. Let me retry. @swift-ci smoke test |
Merged since tests were passing. |
Matching Swift PR: apple/swift#38750
Adding space to -l flag causes swiftc to produce abstract error. This PR aims at improving usability to -l flag by allowing it to take a space.
Resolves SR-14122.