spevans
(Simon Evans)
September 27, 2018, 9:35pm
1
Hopefully this is the correct category to post this.
Currently on Ubuntu Linux, the Swift toolchain uses the system provided libicu
which presents 2 problems:
The version of ICU is quite old on 14.04 and 16.04, which is the source of some bugs in scl-foundation. Currently some tests are disabled to prevent CI failures.
The way that libicu is built requires the use of dlopen()
, thus making it unusable in a statically linked executable.
I propose building libicu
by default as part of the Linux build. This will allow using the latest version and also it can be built without the use of dlopen()
.
Ideally I want to build with the version used by Darwin https://opensource.apple.com/tarballs/ICU/ICU-59152.0.1.tar.gz which I have had working before, however if there are reasons that version cant be used the offical version at https://github.com/unicode-org/icu could be used instead.
Does this sound reasonable?
For reference:
ICU versions for Linux/Darwin (from Add support for .withFractionalSeconds to ISO8601DateFormatter. by armadsen · Pull Request #1586 · apple/swift-corelibs-foundation · GitHub )
macOS 10.12 ships with ICU 57.1
macOS 10.13 ships with ICU 59.1
Ubuntu 14.04 ships with ICU 52.1
Ubuntu 16.04 ships with ICU 55.1
Ubuntu 18.04 ships with ICU 60.2
ICU Jiras:
opened 12:47AM - 03 May 18 UTC
closed 04:45PM - 30 Nov 18 UTC
bug
Foundation
| | |
|------------------|-----------------|…
|Previous ID | SR-7589 |
|Radar | None |
|Original Reporter | @shahmishal |
|Type | Bug |
|Status | Resolved |
|Resolution | Done |
Attachment: [Download](https://user-images.githubusercontent.com/2727770/164962707-0415e3c8-d5dd-457d-b01d-f7b36155b00a.gz)
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Foundation |
|Labels | Bug |
|Assignee | None |
|Priority | Medium |
Watchers: @shahmishal
md5: 13a2fa6074b61c7c519bdb03bbe2303a
</details>
**Issue Description:**
Branch: master
Job: <https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/4024/console>
``` java
Test Case 'TestNumberFormatter.test_currencyPluralMinimumIntegerDigits' started at 2018-05-02 13:20:50.410
/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/swift/utils/build-script-impl: line 262: 32177 Illegal instruction (core dumped) "$@"
/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/swift/utils/build-script: fatal error: command terminated with a non-zero exit status 132, aborting
/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
```
``` java
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/b'.
Program terminated with signal SIGILL, Illegal instruction.
#​0 0x00007efe1795fc85 in $S10Foundation15NumberFormatterC03_cfC033_1BC0B44B1C0E13F0CDB35A6621533205LLSo08CFNumberC3Refavg ()
from /home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/buildbot_incremental/foundation-linux-x86_64/Foundation/libFoundation.so
```
opened 01:17AM - 18 Nov 17 UTC
closed 07:50PM - 18 Jan 19 UTC
bug
Foundation
| | |
|------------------|-----------------|…
|Previous ID | SR-6431 |
|Radar | None |
|Original Reporter | @slavapestov |
|Type | Bug |
|Status | Resolved |
|Resolution | Done |
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Foundation |
|Labels | Bug |
|Assignee | @phausler |
|Priority | Medium |
md5: 6ab61fc152858f5a8ffb44ef7fb72bfa
</details>
**Issue Description:**
CoreFoundation/Locale.subproj/CFLocale.c:1504:37: error: use of undeclared identifier 'UMS_UK'; did you mean 'UMS_US'?
\*outMeasurementSystem = UMS_UK;
^\~\~\~\~\~
UMS_US
/usr/include/x86_64-linux-gnu/unicode/ulocdata.h:192:5: note: 'UMS_US' declared here
UMS_US, /\*\* Measurement system followed in the United States of America. \*/
^
<https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04/701/console>
opened 07:20PM - 16 Dec 15 UTC
closed 04:44PM - 30 Nov 18 UTC
bug
Foundation
| | |
|------------------|-----------------|…
|Previous ID | SR-250 |
|Radar | None |
|Original Reporter | @parkera |
|Type | Bug |
|Status | Resolved |
|Resolution | Done |
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Foundation |
|Labels | Bug |
|Assignee | None |
|Priority | Medium |
md5: 3431bdc9184e53733b7b6fa2a112e9c8
</details>
**Issue Description:**
I disabled the currency-related number formatter tests because they depend on ICU 5.5 or greater functionality in CF. We do not (yet) require this version of ICU on Linux, although we should. We may want to simply move forward to the Apple version of ICU so that we can pick up other dependencies.
This bug covers figuring out the process to get this dependency into place and then re-enabling the tests.
opened 02:45AM - 06 Oct 17 UTC
closed 05:04PM - 14 Nov 18 UTC
bug
Standard Library
| | |
|------------------|-----------------|…
|Previous ID | SR-6076 |
|Radar | None |
|Original Reporter | @YOCKOW |
|Type | Bug |
|Status | Resolved |
|Resolution | Done |
<details>
<summary>Environment</summary>
- Swift 4.0
- OS
- macOS: High Sierra
- Linux: Ubuntu 16.04
</details>
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Standard Library |
|Labels | Bug |
|Assignee | @milseman |
|Priority | Medium |
md5: 3e4be3a5ea4f496c18a2f04121ef3483
</details>
**relates to**:
* [SR-3582](https://bugs.swift.org/browse/SR-3582) Counting emoji flags
**Issue Description:**
\[Sample Code\]
``` java
let jp: Character = "\u{1F1EF}\u{1F1F5}" // Flag of Japan
let de: Character = "\u{1F1E9}\u{1F1EA}" // Flag of Germany
print("\(jp)".count) // Prints "1", of course
print("\(de)".count) // Prints "1", of course
print("\(jp)\(de)".count) // Prints "2" on macOS, but prints "1" on Linux
print("\(jp)\(de)\(jp)\(de)".count) // Prints "4" on macOS, but prints "1" on Linux
```
\[Note\]
- Results on macOS must be correct.
- There's no political intention to choose the flags.
opened 11:44AM - 31 Jul 17 UTC
bug
Foundation
| | |
|------------------|-----------------|…
|Previous ID | SR-5591 |
|Radar | None |
|Original Reporter | ddunn (JIRA User) |
|Type | Bug |
<details>
<summary>Environment</summary>
MacOS
However the tests need updating on MacOS so the failures would then occur on Linux
</details>
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Foundation |
|Labels | Bug |
|Assignee | mattrajca (JIRA) |
|Priority | Medium |
md5: 15e8dd51a957bed077f409e6ac58a219
</details>
**Issue Description:**
It seems the behavior of the .full property within the DateFormatter has changed on Darwin. Rather than returning 'GMT' for the timezone it now returns 'Greenwhich Mean Time' however on Linux 'GMT' is still being returned so this is causing failures in the tests on Darwin.
The tests need updating which will move these failures over to the Linux build and there they need fixing.
Static Linking Jiras:
opened 05:12PM - 01 Feb 17 UTC
bug
Linux
Compiler
Driver
| | |
|------------------|-----------------|…
|Previous ID | SR-3819 |
|Radar | None |
|Original Reporter | @weissi |
|Type | Bug |
Attachment: [Download](https://user-images.githubusercontent.com/2727770/164961876-5b9a7d60-48cc-45b2-8356-0b60c64c6d84.gz)
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 6 |
|Component/s | Compiler |
|Labels | Bug, Driver, Linux |
|Assignee | None |
|Priority | Medium |
md5: 52de48fd6048234a1c72d6a42d29e78d
</details>
**Issue Description:**
If ICU isn't compiled with `--disable-dyload` it'll need `-ldl` to be linked. That's a problem in Swift when producing a static executable:
$ echo 'print("Hello World")' > test.swift && swiftc -static-executable test.swift
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/libicuuc.a(putil.ao):function uprv_dl_open_55: error: undefined reference to 'dlopen'
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/libicuuc.a(putil.ao):function uprv_dlsym_func_55: error: undefined reference to 'dlsym'
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/libicuuc.a(putil.ao):function uprv_dl_close_55: error: undefined reference to 'dlclose'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
My Swift compiler is version
Swift version 3.1-dev (LLVM 5c165fb715, Clang e540ba0c30, Swift 3d3fdecbb4)
Target: x86_64-unknown-linux-gnu
which is master of 2017-02-01.
I already verified that it can be fixed the following way:
/tmp/jw-swift/usr/bin/swiftc -o main.o -c main.swift
"/usr/bin/ld.gold" "-z" "relro" "--hash-style=gnu" "--build-id" "-m" "elf_x86_64" "-static" "-o" "test" "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crt1.o" "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crti.o" "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/crtbeginT.o" "-L/tmp/jw-swift/usr/lib/swift_static/linux" "-L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0" "-L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../.." "-L/usr/lib/llvm-3.8/bin/../lib" "-L/lib" "-L/usr/lib" "/tmp/jw-swift/usr/lib/swift_static/linux/x86_64/swift_begin.o" "main.o" "-ldl" "-lswiftCore" "-lswiftImageInspectionStatic" "--defsym=__import_pthread_self=pthread_self" "--defsym=__import_pthread_once=pthread_once" "--defsym=__import_pthread_key_create=pthread_key_create" "-lpthread" "-licui18n" "-licuuc" "-licudata" "-lswiftCore" "-lswiftSwiftOnoneSupport" "/tmp/jw-swift/usr/lib/swift_static/linux/x86_64/swift_end.o" "-lstdc++" "-lm" "--start-group" "-lgcc" "-lgcc_eh" "-lc" -ldl "--end-group" "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/crtend.o" "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crtn.o"
the only difference between this and the standard invocation is the `-ldl` inbetween the `--start-group` and `--end-group` linker flags.
I'd be happy to fix this but I'm unsure where exactly to do that. Any pointers?
## Notes
$ icu-config --ldflags
-L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata
$ icu-config --ldflags-system
-ldl -lm
- I'm running Ubuntu 16.04
- it's not enough to just pass `-ldl` to `swiftc` (or `-Xlinker -ldl`)
- the `-ldl` NEEDS to be in between `ld.gold`'s `--start-group` and `--end-group` and I'm unsure how to get it there
- the addition of `-ldl` should obviously only happen if ICU is compiled without `--disable-dyload`.
opened 02:18AM - 30 Jan 16 UTC
| | |
|------------------|-----------------|…
|Previous ID | SR-648 |
|Radar | rdar://problem/32618121 |
|Original Reporter | jaybuff (JIRA User) |
|Type | Improvement |
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 34 |
|Component/s | Package Manager |
|Labels | Improvement |
|Assignee | None |
|Priority | Medium |
md5: a97136565bbf5fd9b15515ab552f61b8
</details>
**is blocked by**:
* [SR-2280](https://bugs.swift.org/browse/SR-2280) swiftc -static-stdlib option fails on Ubuntu 14.04 & 15.10
**is duplicated by**:
* [SR-727](https://bugs.swift.org/browse/SR-727) (emscripten support) Compile Swift code with statically linked stdlib
* [SR-10624](https://bugs.swift.org/browse/SR-10624) SwiftPM doesn't hand --swift-static-stdlib through
**relates to**:
* [SR-2280](https://bugs.swift.org/browse/SR-2280) swiftc -static-stdlib option fails on Ubuntu 14.04 & 15.10
* [SR-10625](https://bugs.swift.org/browse/SR-10625) tests for -static-*
* [SR-730](https://bugs.swift.org/browse/SR-730) Flag to statically link Swift standard library
**Issue Description:**
When I do swift build for a simple hello world swift program it ldd tells me that it is linked against libstdc++.so.6, libswiftCore.so and other .so files. I would like to ask swift build to produce a single file that is not dynamically linked against any shared objects.
5 Likes
lukasa
(Cory Benfield)
September 28, 2018, 9:17am
2
I want to sound a note of caution here: while this would work, it presents risks if you want to link (either directly or transitively) to the system libicu.
If this approach is taken, we need to ensure that the shipped ICU does not expose clashing symbols with the ICU provided by the system. This will likely require mangling them, which may be troublesome.
spevans
(Simon Evans)
September 28, 2018, 9:40am
3
libICU can be built with symbol mangling and this is how it is currently done on Ubuntu16.04, eg:
$ nm ~/swift-DEVELOPMENT-SNAPSHOT-2018-08-26-a-ubuntu16.04/usr/lib/swift/linux/libswiftCore.so |grep 'U ubrk'
U ubrk_close_55
U ubrk_following_55
U ubrk_open_55
U ubrk_preceding_55
U ubrk_setText_55
U ubrk_setUText_55
and on Ubuntu18.04
$ nm swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/linux/libswiftCore.so |grep 'U ubrk'
U ubrk_close_60
U ubrk_following_60
U ubrk_open_60
U ubrk_preceding_60
U ubrk_setText_60
In fact the libXML
used by swift-corelibs-foundation
will still link to the system ICU unless it is recompiled.
1 Like
It might be possible to define a custom U_ICU_ENTRY_POINT_RENAME
macro.
(See unicode/urename.h and unicode/uvernum.h )
I think we've talked about this before, but this is a direction I'd absolutely like to go with the support of the standard library team (so we're all on the same page on using one version of ICU).
5 Likes
+1, this is very much the desired direction for the standard library build on Linux.
I could't find a JIRA for it, so I opened: [SR-8876] Build recent ICU on Linux · Issue #3625 · apple/swift-corelibs-foundation · GitHub
4 Likes
Ben_Cohen
(Ben Cohen)
September 28, 2018, 6:45pm
7
+1 from me.
This also might help move us to a position where we don't have to create a toolchain per version of Ubuntu. Not sure what other factors are forcing that, but this is a big one.
6 Likes
allevato
(Tony Allevato)
September 29, 2018, 12:46am
8
Huge +1. I've mentioned this in a couple PRs and JIRAs but the Unicode.Scalar.Properties
APIs are difficult to trust on Linux without a known version of ICU being built into the standard library. On Apple platforms we can at least make specific properties @available
based on OS releases that map to ICU versions, but we don't have that ability for Linux, so there's no way (without something extreme, like checking the ICU version at runtime) to distinguish between "this property is false" vs. "this property isn't supported" in client code.
davedelong
(Dave DeLong)
September 29, 2018, 6:24am
9
Personally I would love to have access to libicu even outside of Linux.
spevans
(Simon Evans)
October 2, 2018, 9:56pm
10
What would be the next step if we were to go with Apple's fork? Does it just need a git repo to be created and initialised with the contents of https://opensource.apple.com/tarballs/ICU/ICU-59152.0.1.tar.gz ?
The latest Apple platforms (macOS 10.14, iOS 12, tvOS 12, watchOS 5) are using ICU 62 , which isn't available from https://opensource.apple.com/ yet. So that might be a reason to choose http://site.icu-project.org/download or https://github.com/unicode-org/icu .
Apple's fork has some additions, but are any of them needed for stdlib or corelibs?
Has anyone got any updates on this? It looks like having a standard way to compile ICU together with the toolchain would definitely help in unifying the build process for other Linux distributions, Android toolchain and WebAssembly toolchain. While developing WebAssembly toolchain I currently clone GitHub - unicode-org/icu: The new home of the ICU project source code. at one level above the workspace directory and then link icu/icu4c
from that clone to ${WORKSPACE}/icu
, but that's not very convenient. It would be great if utils/update-checkout
script could clone or download the correct version of ICU and put in a place that the current build infrastructure can agree on across all platforms.
spevans
(Simon Evans)
October 28, 2018, 6:55pm
13
2 Likes
pvieito
(Pedro José Pereira Vieito)
October 28, 2018, 6:55pm
14
Yes, having official Linux Swift packages usable in any distro would be a huge step. Other languages distribute a single package for all Linux distros instead of one per Ubuntu release.
1 Like
Right, there are multiple possibilities I see here:
bundling libicu allows Swift compiler to be used on Linux distros that don't have a specific version of libicu installed. But there are still a couple of other dependencies like Glibc that won't allow us to run the compiler on musl distros like Alpine, right?
statically linked self-contained ELF executables compiled from Swift packages. I assume these would link with the bundled libicu? And would also require some support from SwiftPM as well? These binaries would still link with Glibc, but statically, which would allow a user to just copy it to an Alpine instance and run there without a problem, I guess?
hggz
December 19, 2019, 8:49pm
16
Any update on this? Would this allow us to build / use swift on Alpine?
spevans
(Simon Evans)
December 20, 2019, 12:44pm
17
This was implemented for Swift 5. If you are building on Linux you can add the --libicu
option to the build script and it will build libICU as part of the build.
The option has also been added into the buildbot_linux
preset so it will build automatically if that preset it used - this is how CI builds and tests it.