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
[SR-2250] Include Foundation framework instead of minimal NSObject.h #17615
Conversation
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
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 for working on this, Mani!
@@ -0,0 +1 @@ | |||
#include <objc/NSObject.h> |
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.
Hm, it's kind of weird to be putting this in PrintAsObjC/Inputs/ if tests from other folders are going to be using it too. Maybe it'd be better to put it in the normal "mock SDK" (test/Inputs/clang-importer-sdk/Frameworks/ or something) and have it include <Foundation.h>
there?
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.
Thank you for reviewing it. Yeah that makes sense, it felt weird to me also to point to this file from other tests. I'll move the file and and have it include <Foundation.h>
instead.
Thank you for your time to help me through it. There are currently three tests failing that I can't figure out why or how to get the root cause of it:
|
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 for continuing to work on this! Good catch removing the explicit -include Foundation.h
too.
test/lit.cfg
Outdated
@@ -384,6 +384,9 @@ config.substitutions.append(('%build-clang-importer-objc-overlays', | |||
config.substitutions.append(('%clang-importer-sdk-path', | |||
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk')))) | |||
|
|||
config.substitutions.append(('%clang-importer-sdk-frameworks', |
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 since this is always relative to %clang-importer-sdk-path
, it's fine not to have a separate substitution for it. Substitutions are additional complexity if we're not actually making use of the flexibility.
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.
Aw, didn't know about the complexity of it. The reason added it was that it seems in the swift files, path to clang-importer-sdk
is always hardcoded, like %S/../../Inputs/clang-importer-sdk/...
, wanted to prevent that. But sounds good. Seems in the lit.cfg
I can use clang-importer-sdk-path
, but in the files, have to give it a relative path. I'll update the code with these changes.
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 would expect %clang-importer-sdk-path/frameworks
to work in the individual files. What behavior are you seeing?
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.
That's what I also expected. It works fine with lit.local.cfg
as '-F %%clang-importer-sdk-path/frameworks '
but for using it in lit use cases like here, -F %clang-importer-sdk-path/frameworks
is turnt into -F 'path-to-swift-repo/test/Inputs/clang-importer-sdk/' /frameworks
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.
Hm. I would expect it to be -F 'path-to-swift-repo/test/Inputs/clang-importer-sdk/'/frameworks
(no space), which should still work. Are you sure you didn't have a typo? We have other examples of this kind of thing working.
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.
You're right, seems I was using different substitution that was causing that behavior. Thanks for the example, I went ahead and update the classes to use this pattern
We didn't really design the fake Foundation to work with C++, but I guess we need to now. For Empty.swift, adding |
Okay, let's try it! @swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
And, merged! Thank you, Mani! |
Amazing, very excited : ) Thanks for your help during this and look forward to bug you more on other tickets |
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
As suggested by Jordan, adding
Foundation
framework as a default instead ofNSObject.h
to prevent situations when only bridge types are used and Foundation never imports and causes an error on generated-Swift.h
file.Resolves SR-2250