Building Foundation with SwiftPM


(Robert F Dickerson) #1

This has probably been discussed in the past, but wanted to revisit the
idea of using native Swift tools to build Foundation. I brought this up in
the Slack group, and it seemed to be warmly received- although probably
still not simple because of some cyclical dependency issues in the build
process.

But, I think that there would be a lot of value in being able to build
Foundation (and CoreFoundation) only using SwiftPM, in other words, simply
with `swift build`.

Now that SwiftPM is improving its ability to pass in compilation flags more
easily and C module compilation. I think that the project could be
restructured to make this work. What would be the obstacles for getting
this working?


(Tony Parker) #2

When we were first bringing up the project we had a hack that forced the compiler to do incremental builds of the Swift files. However, it turned out that it wasn’t really safe or supported.

If there is some way to actually turn that on now in a way that allows quick turnaround (probably sacrificing things like whole module optimization and stuff), I would be in favor of enabling it.

- Tony

···

On Jan 30, 2017, at 4:49 PM, Robert F Dickerson via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

This has probably been discussed in the past, but wanted to revisit the idea of using native Swift tools to build Foundation. I brought this up in the Slack group, and it seemed to be warmly received- although probably still not simple because of some cyclical dependency issues in the build process.

But, I think that there would be a lot of value in being able to build Foundation (and CoreFoundation) only using SwiftPM, in other words, simply with `swift build`.

Now that SwiftPM is improving its ability to pass in compilation flags more easily and C module compilation. I think that the project could be restructured to make this work. What would be the obstacles for getting this working?

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Philippe Hausler) #3

So there are a few issues that would be a bit tricky to deal with:

SwiftPM uses Foundation so you would have to devise some way to build SwiftPM either without Foundation (which seems sub-optimal or replication of effort/code), directly importing parts of Foundation into the code-base for SwiftPM which might result in a synchronization issue of code, or a last-build result re-build of Foundation used in SwiftPM which seems like a pain when it comes to first time setup.

Foundation’s build environment is a bit tricky since it is not just plain C, we have assembly and some really funky linker tricks that might pose an issue. Also it might be a bit difficult to build CoreFoundation as it’s own target (as it stands now you can technically build CF without swift and use that independently on Linux - which elides the need to publish a separate CFLite).

From previous build infrastructure efforts that I have undertaken; the general consensus is that using SwiftPM would be nice but it doesn’t offer enough of a compelling reason to switch and complicate the rest of the Swift build process (which is already very complex).

Now the other alternative is that Foundation could be built with cmake. That has been something I have explored and it shows some promise. However as for fish to fry, it is a very small one.

Now I think fixing the dirty file bits from the build script might be a good thing to fix even without changing the build infrastructure. I have tried to fix this problem a few times but it ends up getting really complex really quickly.

If you want to dive into the current build system or perhaps look at cmake let me know if there are things that I can help out to clarify.

P.S. what slack server are you discussing this on? I was un-aware of any slack servers setup for swift.

···

On Jan 30, 2017, at 4:49 PM, Robert F Dickerson via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

This has probably been discussed in the past, but wanted to revisit the idea of using native Swift tools to build Foundation. I brought this up in the Slack group, and it seemed to be warmly received- although probably still not simple because of some cyclical dependency issues in the build process.

But, I think that there would be a lot of value in being able to build Foundation (and CoreFoundation) only using SwiftPM, in other words, simply with `swift build`.

Now that SwiftPM is improving its ability to pass in compilation flags more easily and C module compilation. I think that the project could be restructured to make this work. What would be the obstacles for getting this working?

<ecblank.gif> <ecblank.gif>
<ecblank.gif>
<ecblank.gif>
<ecblank.gif>
<ecblank.gif> <ecblank.gif>

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Ankit Aggarwal) #4

So there are a few issues that would be a bit tricky to deal with:

SwiftPM uses Foundation so you would have to devise some way to build
SwiftPM either without Foundation (which seems sub-optimal or replication
of effort/code), directly importing parts of Foundation into the code-base
for SwiftPM which might result in a synchronization issue of code, or a
last-build result re-build of Foundation used in SwiftPM which seems like a
pain when it comes to first time setup.

Foundation’s build environment is a bit tricky since it is not just plain
C, we have assembly and some really funky linker tricks that might pose an
issue. Also it might be a bit difficult to build CoreFoundation as it’s own
target (as it stands now you can technically build CF without swift and use
that independently on Linux - which elides the need to publish a separate
CFLite).

Note that you can have C and Swift targets in SwiftPM (and also statically
link them) but I guess it will be difficult to get around the assembly and
linker tricks. We do allow passing arbitrary compiler flags during
invocation which are a workaround until we have a build settings story.

From previous build infrastructure efforts that I have undertaken; the
general consensus is that using SwiftPM would be nice but it doesn’t offer
enough of a compelling reason to switch and complicate the rest of the
Swift build process (which is already very complex).

Daniel mentioned that we could add support for building Foundation with
SwiftPM but not do it in the overall Swift build process, which I think
makes sense and might be a nice thing for beginners. It is also very
convenient for regular development, for e.g. most of the time I use a trunk
snapshot from swift.org to develop SwiftPM. There are hardly any issues
esp. since Swift 3 and syntax stability. And of course there is Swift CI to
catch any issue before merging.

Now the other alternative is that Foundation could be built with cmake.
That has been something I have explored and it shows some promise. However
as for fish to fry, it is a very small one.

Now I think fixing the dirty file bits from the build script might be a
good thing to fix even without changing the build infrastructure. I have
tried to fix this problem a few times but it ends up getting really complex
really quickly.

If you want to dive into the current build system or perhaps look at cmake
let me know if there are things that I can help out to clarify.

P.S. what slack server are you discussing this on? I was un-aware of any
slack servers setup for swift.

SwiftPM has an "unofficial" slack team, you can join here:
http://swift-package-manager.herokuapp.com
More info here:
https://lists.swift.org/pipermail/swift-build-dev/Week-of-Mon-20160530/000497.html

···

On Tue, Jan 31, 2017 at 8:13 AM, Philippe Hausler via swift-corelibs-dev < swift-corelibs-dev@swift.org> wrote:

On Jan 30, 2017, at 4:49 PM, Robert F Dickerson via swift-corelibs-dev < > swift-corelibs-dev@swift.org> wrote:

This has probably been discussed in the past, but wanted to revisit the
idea of using native Swift tools to build Foundation. I brought this up in
the Slack group, and it seemed to be warmly received- although probably
still not simple because of some cyclical dependency issues in the build
process.

But, I think that there would be a lot of value in being able to build
Foundation (and CoreFoundation) only using SwiftPM, in other words, simply
with `swift build`.

Now that SwiftPM is improving its ability to pass in compilation flags
more easily and C module compilation. I think that the project could be
restructured to make this work. What would be the obstacles for getting
this working?

<ecblank.gif> <ecblank.gif>
<ecblank.gif>
<ecblank.gif>
<ecblank.gif>
<ecblank.gif> <ecblank.gif>

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev