This makes it a bit easier for our current users to move to LLD and avoid these framework-not-found errors.
I know there is an existing option to list the framework(s) to be ignored but in our user-case it is not practical to do that.
Differential D140225
[lld-macho] Provide an option to ignore framework-not-found errors coming from LC_LINKER_OPTIONS. oontvoo on Dec 16 2022, 9:56 AM. Authored by
Details
Diff Detail
Event TimelineComment Actions @keith Since you initially implemented these LC_LINKER_OPTION support, perhaps you could help reviewing this? Comment Actions I wonder if at this point we should just implement LD64's behavior with an off-by-default flag to be more strict? Specifically they ignore these failures and collect the missing ones and only print about them in the case the link fails
Comment Actions Honestly, I find LD64's behaviour a bit sketchy ... How would people feel about making these warnings (instead of errors)? (and of course, get rid of this new flag) Comment Actions From offline discussions, we have a few options: (in no particular order)
Comment Actions Making them warnings seems like a good compromise to me, since people can then use -fatal_warnings if they want to turn this into errors and we don't need a new flag. And if we do want a flag, we could add one to disable this particular warning -- warning-disabling flags have a ton of precedent, so that seems like a nice and cohesive approach to me. Comment Actions If we make them warnings, you would actually be able to disable the warning today by passing --ignore-auto-link-option=Foo as well, without any new flags Comment Actions I mean we could remove the somewhat special-purpose ignore-auto-link-option= flag then -- or rather, replace it with a no-warn-autolink flag. That wouldn't allow suppressing this on a per lib level, but that's probably fine? Comment Actions The benefit of per library opt outs is you can make sure new violations don't sneak in. But either way we can deal with that part separately from this if we want to add a new flag like that This comment was removed by int3. Comment Actions
My understanding is that some third-party/system libraries have these unsatisfied dependencies baked in, so it's not something that's always fixable in the build. We shouldn't require people to turn off -fatal_warnings in their builds to support third-party unfixable stuff. I'm leaning toward Vy's option #3 (extend existing flag, no new flags), though I think #1 is good too (would make it easier for people to drop in LLD into their builds) Comment Actions Hmm, unfortunately doesn't look like we have a majority here ... I guess how about we go with the option that requires the least API change which is #2 (ie., no new flag):
P.S: This should be the least disruptive, too, because missing libraries/frameworks are already *errors* today - so we're not going to pollute the build logs any more than they're already broken. @int3 You're good with this? :) (You've pointed out that we shouldn't require people to turn off warnings, but this proposed change would not introduce more warnings/errors than whatever already exists) Comment Actions I know I'd proposed this, but my reservation with #3 is that it's debatable how the the special * value interacts with others, eg., -ignore_linker_option=* -ignore_linker_option=foo -ignore_linker_option=bar could mean one of the two:
Furthermore, this means that once a build sets -ignore_linker_option=*, new missing frameworks/libraries from bad LC_LINKER_OPTIONs will be ignored. This is bad because invalid LC_LINKER_OPTIONs aren't exactly "free" . Ideally, I'd like to have a solution that:
With that in mind, option 2 seems a bit better. This comment was removed by int3. Comment Actions Okay, you've convinced me. But just to clarify some of what I said earlier:
Yes, but it still makes turning on -fatal_warnings harder. And I would like to be able to turn it on for most of our builds. (We are already looking at downgrading certain warnings internally to achieve this, but I would like to minimize the number of local patches.)
I was thinking that we would still emit a non-warning message when we encounter missing frameworks that aren't explicitly ignored. But you're right, this is a deviation from how the existing -ignore_linker_option flag works for explicit ignores. Anyway I realize that making them warnings isn't so bad because folks can use -ignore_linker_option to make the build warning-free. Turning on -fatal_warnings usually requires some build cleanup work anyway, so requiring people to figure out which libraries to ignore seems par for the course.
Please push back if things don't make sense 😅 I'm not always thinking straight... Comment Actions Updated diff to implement option #2, whic is to make missing frameworks/libraries warnings instead of errors. Thanks, all, for the inputs! Comment Actions Well, this patch can't make it any harder because it downgrades errors to warnings. In other words, such builds would be already broken - this would "unbreak" them, in exchange for some additional warnings Comment Actions added more tests for missing libaries (-l) too. Also included the files where the bad LC_LINKER_OPTION live to help debugging Comment Actions
Sorry I wasn't clear -- I meant that it makes it harder relative to the option where they aren't warnings at all. The point I want to make is that we shouldn't just use "this doesn't break existing builds that use LLD" as a guideline, since we are still trying to grow our userbase. We should try to make it as easy as possible to adopt LLD, and if someone has an existing build that uses ld64 together with -fatal_warnings enabled, we (ideally) shouldn't require them to disable it in order to switch.
Comment Actions addressed review comments:
Comment Actions After reading all this discussion, and seeing this well timed issue https://github.com/llvm/llvm-project/issues/59627 which is caused by this as well, I feel like we should take the opportunity to mirror ld64's behavior entirely, and potentially add a flag to opt-in to the more strict behavior that exists today. My opinion changed here since we talked about this last year because at least 5 people who have tried this have asked me about this specific issue. This issue is far more wide-spread than I originally thought in the community, and I don't think there's huge value in fixing these issues if your link succeeds anyways. Overall from this conversation it doesn't seem like anyone feels strongly enough about being strict on this issue that it justifies differing from ld64 and making adoption even just slightly harder. I submitted https://reviews.llvm.org/D140491 with that approach if folks agree Comment Actions It's really not a big deal 😃 (I'd just like to see a solution submitted the sooner the better) Keith's proposal LGTM , as long as we have that option to opt-in to the more strict because I still don't think bad limker-options are completely harmless. For one, they takes up space. For two, if our toolchains generate bad linker-options then we'd really like to know to fix the bug. |
would be nice to have an explanatory comment here about why we are only emitting a warning
could we also update the comment here? It probably should now say that LLD will warn on missing libraries (instead of completely disallowing them), but that the --ignore-auto-link-option is useful for squelching those warnings entirely.