For building ICU (on Linux at least) you just need the icu directory at the 
same level as the other swift source directories and then the `—libicu` option 
should build it and the `—install-libicu` option should install the libs in 
usr/lib/swift/linux/ and usr/lib/swift_static/linux/

Static stdlib linking on ELF platforms is controlled by the file 
$ cat ~/swift/usr/lib/swift_static/linux/static-stdlib-args.lnk                 
                                                                                
                                                                               
-ldl
-lpthread
-latomic
-lswiftCore
-latomic
-lswiftImageInspectionShared
/usr/lib/x86_64-linux-gnu/libicui18n.a
/usr/lib/x86_64-linux-gnu/libicuuc.a
/usr/lib/x86_64-linux-gnu/libicudata.a
-Xlinker
-export-dynamic
-Xlinker
--exclude-libs
-Xlinker
ALL


This file is created at build time by the script 
utils/gen-static-stdlib-link-args which tries to work out what libicu paths to 
use. For the above file it is using the .a files to link as part of 
`-static-stdlib`. If building ICU as part of the build process, instead of the 
.a files it should list 

-licui18n
-licuuc
-licudata

Since the compile automatically points to the libs in swift_static. I think the 
generator script might need to be modified for FreeBSD as I dont think -ldl is 
valid on FreeBSD.

That script is called by lib/Driver/CMakeLists.txt. Although it should work on 
any ELF platform it does have a check to only allow it to run on Linux, this 
was because I didnt have any other platform to test against and didnt want to 
break it for other ELF platforms, so you may need to remove that.

One other thing to check when compiling swift-corelibs-foundation on Linux is 
you may need the change in this unmerged PR 
https://github.com/apple/swift-corelibs-foundation/pull/722 which uses the 
correct header files for ICU if compiling ICU from source using pkgconfig - I 
dont know what the non-Linux equivalent would be.

Hope that helps

si





> On 26 May 2017, at 01:33, Michael Ilseman <milse...@apple.com> wrote:
> 
> With https://github.com/apple/swift/pull/9684 the Swift standard library 
> depends on ICU on Darwin in addition to Linux, where it has always had that 
> dependency. While our Linux bots have been happy with the changes, I’m not 
> familiar with the build configurations involving the build-your-own-ICU path, 
> nor with FreeBSD, Cygwin, Android, etc. I would like to make sure that all 
> supported configurations still work, can someone help me with this? 
> 
> Additionally, the standard library can be built as a static library. In this 
> configuration, user programs that link against the static library should also 
> be told explicitly to link against ICU (e.g. “-licu*”). On Darwin, the least 
> evil approach was autolinking by emitting a linker option via inline asm in 
> the shims library. Is there an approach that would work for Linux? An 
> alternative solution could be adding the flags in the Swift driver itself, 
> but that would mean that any build systems that bypass the Swift driver would 
> also need to be updated to pass those same flags.
> 
> 

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

Reply via email to