-
Notifications
You must be signed in to change notification settings - Fork 1.2k
build static foundation #873
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
Conversation
@swift-ci please test |
@weissi Good to see this being worked, I just have a couple of points:
but it may be useful to insert the others so that they dont need to be added to each build script that uses libFoundation. |
hey @spevans thanks very much for your comments, replies individually
Another change I was thinking about is to remove the ugly multiple inheritance and create a Any ideas how to improve this patch would be greatly appreciated. |
@weissi I was only suggesting it as the other repos (libdispatch and swift) take an option to build static libs. However I agree with you that its pretty easy to fix if it needs to be, and building both together does save on having to add another option into
autolink.sh:
|
@weissi Just to let you know that I was able to use this PR and some other changes I did to build a static version of |
@swift-ci please test |
@phausler can you review this change please? |
@spevans thanks for letting me know and sorry for not responding earlier 🤕. Would you want to add your changes to this PR and make it a shared one or rather open another one after this goes it (after potentially some changes). |
@weissi I'll do my changes in a separate PR since they are not finished yet, and I still need to check if some of the changes I made are acceptable 😀 |
overall the changes here look reasonable |
@weissi 1 quick question, is it possible to use different compile flags when compiling the
(there are some other changes as well) and pass |
BINARY_SUPPORT_DYLD, BINARY_SUPPORT_DLFCN, BINARY_SUPPORT_DLL all have to do with what CFBundle can do when loading a bundle not about when the library itself is compiled as static. |
@phausler Agreed, its just that I have been testing creating a fully statically linked TestFoundation and this meant not linking in libdl or using any dl functions. Of course it may end up that ultimately I may need to build a libFoundationStatic.a and libFoundationShared.a (as was done with the swift stdlib with libswiftImageInspectionShared.a and libswiftImageInspectionStatic.a) |
the issue I think that might be at hand here is the dropping of functions like the initialization routines ala __CFInitialize (which is a pre-requiste for making CF and consequently Foundation work) |
I actually managed to build TestFoundation as a fully static binary including libcurl and dependancies and it ran all of the tests successfully. Of course not everything is fully covered by the tests and I understand that plugin capability is lost but for Linux it seems to be ok. Obviously this wouldn't apply to Darwin |
If the tests run it is a good sign that __CFInitialize is being called; if it wasn't it would be crashing all over the place since we assume layouts are setup by that time. |
Yes __CFInitialize is not wrapped inside any BINARY_SUPPORT conditionals. The only code that seems to get excluded is dlopen() etc used for bundle & plugin loading. |
static libraries can still call dlopen; I don't see why we should disallow that when building as a |
Sorry, I was referring to using static libraries inside a statically linked binary but Ive just thought of a solution that doesnt require undef'ing the BINARY_SUPPORT conditionals anyway, so I'll stop wittering on now 😀 |
@spevans With the current implementation it'd be hard to pass additional compilation flags to the static version. The reason being that I use the same |
@weissi That's fine, I have thought of a different solution for static linking instead of using additional compilation flags so I dont have any issues with this PR. |
@phausler any reservations to merge this one? |
Let's give this a try. |
@swift-ci test and merge |
I guess this is generating warnings of the kind: |
The build.ninja has two rules for each target. Example: |
the first commit introduces a
StaticAndDynamicLibrary
product (sorry about the multiple inheritance 😨, more than happy to change if someone has a better idea) and which buildslibFoundation.a
on top oflibFoundation.so
.The other commit is just a simple fix, the
ar
command shouldn't be given the compiler flags.