From 18970d1e2719d86197de7e94cc7ec38a3c00e70a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 13:56:06 -0700 Subject: [PATCH 01/14] Add separate freertos crate --- Cargo.lock | 11 +++++- Cargo.toml | 1 + ffi/diplomat/Cargo.toml | 14 ++----- ffi/diplomat/src/lib.rs | 13 ++----- ffi/freertos/Cargo.toml | 38 +++++++++++++++++++ .../freertos_glue.rs => freertos/src/lib.rs} | 21 ++++++++++ tools/scripts/ffi.toml | 2 +- 7 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 ffi/freertos/Cargo.toml rename ffi/{diplomat/src/freertos_glue.rs => freertos/src/lib.rs} (55%) diff --git a/Cargo.lock b/Cargo.lock index c93f27af08d..5c76c0b0e5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,12 +1070,10 @@ dependencies = [ name = "icu_capi" version = "0.1.0" dependencies = [ - "cortex-m", "diplomat", "diplomat-runtime", "dlmalloc", "fixed_decimal", - "freertos-rust", "icu_decimal", "icu_locale_canonicalizer", "icu_locid", @@ -1230,6 +1228,15 @@ dependencies = [ "writeable", ] +[[package]] +name = "icu_freertos" +version = "0.1.0" +dependencies = [ + "cortex-m", + "freertos-rust", + "icu_capi", +] + [[package]] name = "icu_list" version = "0.5.0" diff --git a/Cargo.toml b/Cargo.toml index 610180d35e9..ec247e4e3d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ members = [ "experimental/segmenter_lstm", "ffi/diplomat", "ffi/ecma402", + "ffi/freertos", "provider/adapters", "provider/blob", "provider/core", diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index bc6554fe5de..98f9b940343 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -31,17 +31,16 @@ all-features = true # Omit most optional dependency features from permutation testing skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. -# wearos/freertos/x86tiny are not relevant in normal environments, +# x86tiny is not relevant in normal environments, # smaller_static gets tested on the FFI job anyway -denylist = ["bench", "wearos", "freertos", "x86tiny", "smaller_static"] +denylist = ["bench", "x86tiny", "smaller_static"] [lib] -crate-type = ["staticlib", "rlib"] +crate-type = ["rlib"] path = "src/lib.rs" [features] default = ["provider_fs", "provider_static"] -wearos = ["smaller_static", "freertos"] provider_fs = ["icu_provider_fs", "icu_provider_fs/deserialize_json"] provider_static = ["icu_testdata"] @@ -54,9 +53,6 @@ smaller_static = ["provider_static"] # Enables size-optimized builds on x86_64 x86tiny = ["dlmalloc"] -# Enables no_std builds for freertos -freertos = ["freertos-rust", "cortex-m"] - [dependencies] fixed_decimal = { path = "../../utils/fixed_decimal", features = ["ryu"] } icu_decimal = { path = "../../components/decimal/" } @@ -87,10 +83,6 @@ log = { version = "0.4" } [target.'cfg(not(any(target_arch = "wasm32", target_os = "none")))'.dependencies] icu_provider_fs = { path = "../../provider/fs/", optional = true } -[target.'cfg(target_os = "none")'.dependencies] -freertos-rust = { version = "0.1.2", optional = true } -cortex-m = { version = "0.7.3", optional = true } - # Unfortunately, --crate-type cannot be set per-target # (https://github.com/rust-lang/cargo/issues/4881) # and emscripten has link errors when compiling icu_capi due to diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index e9986b7e463..4c04073cc0e 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -15,10 +15,7 @@ )] #![allow(clippy::upper_case_acronyms)] #![cfg_attr( - any( - all(feature = "freertos", not(feature = "x86tiny")), - all(feature = "x86tiny", not(feature = "freertos")), - ), + any(feature = "x86tiny", target_os = "none"), feature(alloc_error_handler) )] @@ -37,7 +34,7 @@ // Needed to be able to build cdylibs/etc // // Renamed so you can't accidentally use it -#[cfg(all(not(feature = "freertos"), not(feature = "x86tiny")))] +#[cfg(all(not(target_os = "none"), not(feature = "x86tiny")))] extern crate std as rust_std; extern crate alloc; @@ -57,8 +54,6 @@ pub mod segmenter_line; #[cfg(target_arch = "wasm32")] mod wasm_glue; -#[cfg(all(feature = "freertos", not(feature = "x86tiny")))] -mod freertos_glue; - -#[cfg(all(feature = "x86tiny", not(feature = "freertos")))] +#[cfg(all(feature = "x86tiny", not(target_os = "none")))] mod x86tiny_glue; + diff --git a/ffi/freertos/Cargo.toml b/ffi/freertos/Cargo.toml new file mode 100644 index 00000000000..b328737ebd2 --- /dev/null +++ b/ffi/freertos/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "icu_freertos" +description = "C interface to ICU4X" +version = "0.1.0" +authors = ["The ICU4X Project Developers"] +edition = "2018" +resolver = "2" +repository = "https://github.com/unicode-org/icu4x" +license-file = "LICENSE" +categories = ["internationalization"] +# Keep this in sync with other crates unless there are exceptions +include = [ + "src/**/*", + "examples/**/*", + "benches/**/*", + "tests/**/*", + "include/**/*", + "Cargo.toml", + "LICENSE", + "README.md" +] + +[package.metadata.docs.rs] +all-features = true + +[lib] +crate-type = ["staticlib", "rlib"] +path = "src/lib.rs" + +[dependencies] +icu_capi = { version = "0.1", path = "../diplomat" } + +[target.'cfg(target_os = "none")'.dependencies] +freertos-rust = { version = "0.1.2" } +cortex-m = { version = "0.7.3" } + +[features] +wearos = ["icu_capi/smaller_static"] diff --git a/ffi/diplomat/src/freertos_glue.rs b/ffi/freertos/src/lib.rs similarity index 55% rename from ffi/diplomat/src/freertos_glue.rs rename to ffi/freertos/src/lib.rs index a0bae9c3b52..c9c32e9ddae 100644 --- a/ffi/diplomat/src/freertos_glue.rs +++ b/ffi/freertos/src/lib.rs @@ -2,6 +2,27 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +// https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations +#![no_std] +#![cfg_attr( + not(test), + deny( + clippy::indexing_slicing, + clippy::unwrap_used, + clippy::expect_used, + clippy::panic + ) +)] +#![allow(clippy::upper_case_acronyms)] + +#![feature(alloc_error_handler)] + +extern crate alloc; + +// Necessary to for symbols to be linked in +extern crate icu_capi; + use alloc::alloc::Layout; use core::panic::PanicInfo; use cortex_m::asm; diff --git a/tools/scripts/ffi.toml b/tools/scripts/ffi.toml index f53ebfa6fe2..8d4c083f4f9 100644 --- a/tools/scripts/ffi.toml +++ b/tools/scripts/ffi.toml @@ -143,7 +143,7 @@ category = "ICU4X FFI" toolchain = "nightly-2021-12-22" env = { "RUSTFLAGS" = "-Ctarget-cpu=cortex-m33 -Cpanic=abort" } command = "cargo" -args = ["build", "--package", "icu_capi", +args = ["build", "--package", "icu_freertos", "--target", "thumbv8m.main-none-eabihf", "--no-default-features", "--features=wearos", "--release", From 84ca87ff93a2d49549f1b2d72b6d5a622e666d65 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 14:39:28 -0700 Subject: [PATCH 02/14] Add icu_capi_staticlib --- Cargo.lock | 7 +++ Cargo.toml | 1 + ffi/capi_staticlib/Cargo.toml | 49 +++++++++++++++++++ ffi/capi_staticlib/src/lib.rs | 21 ++++++++ ffi/diplomat/Cargo.toml | 7 +-- ffi/diplomat/c/examples/fixeddecimal/Makefile | 8 +-- .../c/examples/fixeddecimal_tiny/Makefile | 36 +++++++------- ffi/diplomat/c/examples/locale/Makefile | 8 +-- ffi/diplomat/c/examples/pluralrules/Makefile | 8 +-- .../cpp/examples/fixeddecimal/Makefile | 8 +-- .../cpp/examples/fixeddecimal_wasm/Makefile | 24 ++++----- ffi/diplomat/cpp/examples/locale/Makefile | 8 +-- .../cpp/examples/pluralrules/Makefile | 8 +-- ffi/diplomat/cpp/examples/properties/Makefile | 8 +-- ffi/diplomat/cpp/examples/segmenter/Makefile | 8 +-- 15 files changed, 141 insertions(+), 68 deletions(-) create mode 100644 ffi/capi_staticlib/Cargo.toml create mode 100644 ffi/capi_staticlib/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 5c76c0b0e5e..021c0777396 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1091,6 +1091,13 @@ dependencies = [ "writeable", ] +[[package]] +name = "icu_capi_staticlib" +version = "0.1.0" +dependencies = [ + "icu_capi", +] + [[package]] name = "icu_casemapping" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index ec247e4e3d2..41f5cb7b0b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ members = [ "experimental/segmenter", "experimental/segmenter_lstm", "ffi/diplomat", + "ffi/capi_staticlib", "ffi/ecma402", "ffi/freertos", "provider/adapters", diff --git a/ffi/capi_staticlib/Cargo.toml b/ffi/capi_staticlib/Cargo.toml new file mode 100644 index 00000000000..00731075dd3 --- /dev/null +++ b/ffi/capi_staticlib/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "icu_capi_staticlib" +description = "C interface to ICU4X" +version = "0.1.0" +authors = ["The ICU4X Project Developers"] +edition = "2018" +resolver = "2" +repository = "https://github.com/unicode-org/icu4x" +license-file = "LICENSE" +categories = ["internationalization"] +# Keep this in sync with other crates unless there are exceptions +include = [ + "src/**/*", + "examples/**/*", + "benches/**/*", + "tests/**/*", + "include/**/*", + "Cargo.toml", + "LICENSE", + "README.md" +] + +[package.metadata.docs.rs] +all-features = true + +[lib] +crate-type = ["staticlib", "rlib"] +path = "src/lib.rs" + +[dependencies] +icu_capi = { version = "0.1", path = "../diplomat", default-features = false } + + +# Please keep features/cargo-all-features lists in sync with the icu_capi crate +[features] +default = ["provider_fs", "provider_static"] +provider_fs = ["icu_capi/provider_fs"] +provider_static = ["icu_capi/provider_static"] +smaller_static = ["icu_capi/smaller_static"] +# Enables size-optimized builds on x86_64 +x86tiny = ["icu_capi/x86tiny"] + +[package.metadata.cargo-all-features] +# Omit most optional dependency features from permutation testing +skip_optional_dependencies = true +# Bench feature gets tested separately and is only relevant for CI. +# x86tiny is not relevant in normal environments, +# smaller_static gets tested on the FFI job anyway +denylist = ["bench", "x86tiny", "smaller_static"] diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs new file mode 100644 index 00000000000..137c8d1664e --- /dev/null +++ b/ffi/capi_staticlib/src/lib.rs @@ -0,0 +1,21 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +//! This exists as a separate crate to work around +//! cargo being unable to conditionally compile crate-types. + +// https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations +#![no_std] +#![cfg_attr( + not(test), + deny( + clippy::indexing_slicing, + clippy::unwrap_used, + clippy::expect_used, + clippy::panic + ) +)] + +// Necessary to for symbols to be linked in +extern crate icu_capi; diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index 98f9b940343..c69c8765be7 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -39,17 +39,12 @@ denylist = ["bench", "x86tiny", "smaller_static"] crate-type = ["rlib"] path = "src/lib.rs" +# Please keep the features list in sync with the icu_capi_staticlib crate [features] default = ["provider_fs", "provider_static"] - provider_fs = ["icu_provider_fs", "icu_provider_fs/deserialize_json"] provider_static = ["icu_testdata"] smaller_static = ["provider_static"] - -# Only 1 of the following features can be set. Doing so disables std and -# replaces the global allocator and panic handler with something else. -# If multiple of these features are set, it is as if none of them are set. - # Enables size-optimized builds on x86_64 x86tiny = ["dlmalloc"] diff --git a/ffi/diplomat/c/examples/fixeddecimal/Makefile b/ffi/diplomat/c/examples/fixeddecimal/Makefile index 2be695ea80e..7b334d3e709 100644 --- a/ffi/diplomat/c/examples/fixeddecimal/Makefile +++ b/ffi/diplomat/c/examples/fixeddecimal/Makefile @@ -13,11 +13,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.c - gcc test.c ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + gcc test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile b/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile index e0ca82d6aae..f467e4ea040 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile @@ -17,47 +17,47 @@ CLANG := clang-12 LLD := lld-12 -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi.a: $(ALL_RUST) - RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +nightly-2021-12-22 panic-abort-build --target x86_64-unknown-linux-gnu --no-default-features --features x86tiny +../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib.a: $(ALL_RUST) + RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +nightly-2021-12-22 panic-abort-build -p icu_capi_staticlib --target x86_64-unknown-linux-gnu --no-default-features --features x86tiny -../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi.a: $(ALL_RUST) - RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +nightly-2021-12-22 panic-abort-build --target x86_64-unknown-linux-gnu --no-default-features --features x86tiny --features smaller_static --release +../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi_staticlib.a: $(ALL_RUST) + RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +nightly-2021-12-22 panic-abort-build -p icu_capi_staticlib --target x86_64-unknown-linux-gnu --no-default-features --features x86tiny --features smaller_static --release # Naive target: no optimizations, full std -optim0.elf: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.c - $(GCC) test.c ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g -o optim0.elf +optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + $(GCC) test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o optim0.elf # optim.elf: gcc with maximum link-time code stripping (gc-sections and strip-all) -optim1.elf: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.c - $(GCC) -fdata-sections -ffunction-sections test.c ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g -o optim1.elf -Wl,--gc-sections -Wl,--strip-all +optim1.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + $(GCC) -fdata-sections -ffunction-sections test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o optim1.elf -Wl,--gc-sections -Wl,--strip-all # optim2.elf: clang single-step with gc-sections -optim2.elf: ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi.a $(ALL_HEADERS) test.c - $(CLANG) -flto -fdata-sections -ffunction-sections test.c ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi.a -g -o optim2.elf -Wl,--gc-sections +optim2.elf: ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + $(CLANG) -flto -fdata-sections -ffunction-sections test.c ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib.a -g -o optim2.elf -Wl,--gc-sections optim3.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim3.o # optim3.elf: clang two-step with lld, debug mode -optim3.elf: optim3.o ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi.a - $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim3.elf optim3.o ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi.a -Wl,--gc-sections +optim3.elf: optim3.o ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib.a + $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim3.elf optim3.o ../../../../../target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib.a -Wl,--gc-sections optim4.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim4.o # optim4.elf: clang two-step with lld, release mode with debug symbols -optim4.elf: optim4.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi.a - $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim4.elf optim4.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi.a -Wl,--gc-sections +optim4.elf: optim4.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi_staticlib.a + $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim4.elf optim4.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi_staticlib.a -Wl,--gc-sections optim5.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -o optim5.o # optim5.elf: clang two-step with lld, release mode stripped of debug symbols -optim5.elf: optim5.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi.a - $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim5.elf optim5.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi.a -Wl,--gc-sections -Wl,--strip-all +optim5.elf: optim5.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi_staticlib.a + $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim5.elf optim5.o ../../../../../target/x86_64-unknown-linux-gnu/release/libicu_capi_staticlib.a -Wl,--gc-sections -Wl,--strip-all build: optim0.elf optim1.elf optim2.elf optim3.elf optim4.elf optim5.elf diff --git a/ffi/diplomat/c/examples/locale/Makefile b/ffi/diplomat/c/examples/locale/Makefile index c904261cf33..e398ff3e454 100644 --- a/ffi/diplomat/c/examples/locale/Makefile +++ b/ffi/diplomat/c/examples/locale/Makefile @@ -13,11 +13,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.c - gcc test.c ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + gcc test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/c/examples/pluralrules/Makefile b/ffi/diplomat/c/examples/pluralrules/Makefile index c904261cf33..e398ff3e454 100644 --- a/ffi/diplomat/c/examples/pluralrules/Makefile +++ b/ffi/diplomat/c/examples/pluralrules/Makefile @@ -13,11 +13,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.c - gcc test.c ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c + gcc test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/cpp/examples/fixeddecimal/Makefile b/ffi/diplomat/cpp/examples/fixeddecimal/Makefile index 864edeaa29c..51c154a72fc 100644 --- a/ffi/diplomat/cpp/examples/fixeddecimal/Makefile +++ b/ffi/diplomat/cpp/examples/fixeddecimal/Makefile @@ -15,11 +15,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile b/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile index 0a935583f16..dbe29e9665b 100644 --- a/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile +++ b/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile @@ -15,20 +15,20 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a: $(ALL_RUST) - RUSTFLAGS="-Cpanic=abort" cargo +nightly-2021-12-22 build --release -p icu_capi --target wasm32-unknown-emscripten -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort +../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a: $(ALL_RUST) + RUSTFLAGS="-Cpanic=abort" cargo +nightly-2021-12-22 build --release -p icu_capi_staticlib --target wasm32-unknown-emscripten -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort -web-version.html: ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a $(ALL_HEADERS) test.cpp - $(EMCC) -std=c++17 test.cpp ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a -ldl -lpthread -lm -g -o web-version.html --bind --emrun -sENVIRONMENT=web -sWASM=1 -sEXPORT_ES6=1 -sMODULARIZE=1 +web-version.html: ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(EMCC) -std=c++17 test.cpp ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o web-version.html --bind --emrun -sENVIRONMENT=web -sWASM=1 -sEXPORT_ES6=1 -sMODULARIZE=1 -node-version.js: ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a $(ALL_HEADERS) test.cpp - $(EMCC) -std=c++17 test.cpp ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a -ldl -lpthread -lm -g -o node-version.js --bind -sWASM=1 -sENVIRONMENT=node -sWASM_ASYNC_COMPILATION=0 -DNOMAIN +node-version.js: ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(EMCC) -std=c++17 test.cpp ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o node-version.js --bind -sWASM=1 -sENVIRONMENT=node -sWASM_ASYNC_COMPILATION=0 -DNOMAIN build: web-version.html node-version.js @@ -51,6 +51,6 @@ clean: rm -f web-version.js rm -f node-version.js rm -f node-version.wasm - rm -f ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi.a - rm -f ../../../../../target/debug/libicu_capi.a + rm -f ../../../../../target/wasm32-unknown-emscripten/release/libicu_capi_staticlib.a + rm -f ../../../../../target/debug/libicu_capi_staticlib.a rm -f a.out diff --git a/ffi/diplomat/cpp/examples/locale/Makefile b/ffi/diplomat/cpp/examples/locale/Makefile index 38a8e8d627a..02393a4b731 100644 --- a/ffi/diplomat/cpp/examples/locale/Makefile +++ b/ffi/diplomat/cpp/examples/locale/Makefile @@ -15,11 +15,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/cpp/examples/pluralrules/Makefile b/ffi/diplomat/cpp/examples/pluralrules/Makefile index 38a8e8d627a..02393a4b731 100644 --- a/ffi/diplomat/cpp/examples/pluralrules/Makefile +++ b/ffi/diplomat/cpp/examples/pluralrules/Makefile @@ -15,11 +15,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/cpp/examples/properties/Makefile b/ffi/diplomat/cpp/examples/properties/Makefile index 864edeaa29c..51c154a72fc 100644 --- a/ffi/diplomat/cpp/examples/properties/Makefile +++ b/ffi/diplomat/cpp/examples/properties/Makefile @@ -15,11 +15,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out diff --git a/ffi/diplomat/cpp/examples/segmenter/Makefile b/ffi/diplomat/cpp/examples/segmenter/Makefile index 864edeaa29c..51c154a72fc 100644 --- a/ffi/diplomat/cpp/examples/segmenter/Makefile +++ b/ffi/diplomat/cpp/examples/segmenter/Makefile @@ -15,11 +15,11 @@ $(ALL_RUST): $(ALL_HEADERS): -../../../../../target/debug/libicu_capi.a: $(ALL_RUST) - cargo build -p icu_capi +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) + cargo build -p icu_capi_staticlib -p icu_capi_staticlib -a.out: ../../../../../target/debug/libicu_capi.a $(ALL_HEADERS) test.cpp - $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi.a -ldl -lpthread -lm -g +a.out: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.cpp + $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g build: a.out From 6b03f9808be4c3f4eda779ed384fdfed40ae9042 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 14:57:52 -0700 Subject: [PATCH 03/14] Add icu_capi_cdylib --- Cargo.lock | 7 +++++ Cargo.toml | 1 + ffi/capi_cdylib/Cargo.toml | 49 +++++++++++++++++++++++++++++ ffi/capi_cdylib/src/lib.rs | 29 +++++++++++++++++ ffi/capi_staticlib/src/lib.rs | 7 +++++ ffi/diplomat/Cargo.toml | 17 ---------- ffi/diplomat/src/crate_type_hack.rs | 10 ------ ffi/diplomat/src/lib.rs | 1 - ffi/diplomat/wasm/lib/paths.mjs | 2 +- ffi/diplomat/wasm/lib/wasm.mjs | 2 ++ ffi/freertos/src/lib.rs | 2 -- tools/scripts/wasm.toml | 12 +++---- 12 files changed, 102 insertions(+), 37 deletions(-) create mode 100644 ffi/capi_cdylib/Cargo.toml create mode 100644 ffi/capi_cdylib/src/lib.rs delete mode 100644 ffi/diplomat/src/crate_type_hack.rs diff --git a/Cargo.lock b/Cargo.lock index 021c0777396..36916f93c4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1091,6 +1091,13 @@ dependencies = [ "writeable", ] +[[package]] +name = "icu_capi_cdylib" +version = "0.1.0" +dependencies = [ + "icu_capi", +] + [[package]] name = "icu_capi_staticlib" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 41f5cb7b0b2..566d1e84cc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ "experimental/crabbake/derive", "experimental/segmenter", "experimental/segmenter_lstm", + "ffi/capi_cdylib", "ffi/diplomat", "ffi/capi_staticlib", "ffi/ecma402", diff --git a/ffi/capi_cdylib/Cargo.toml b/ffi/capi_cdylib/Cargo.toml new file mode 100644 index 00000000000..13276887b92 --- /dev/null +++ b/ffi/capi_cdylib/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "icu_capi_cdylib" +description = "C interface to ICU4X" +version = "0.1.0" +authors = ["The ICU4X Project Developers"] +edition = "2018" +resolver = "2" +repository = "https://github.com/unicode-org/icu4x" +license-file = "LICENSE" +categories = ["internationalization"] +# Keep this in sync with other crates unless there are exceptions +include = [ + "src/**/*", + "examples/**/*", + "benches/**/*", + "tests/**/*", + "include/**/*", + "Cargo.toml", + "LICENSE", + "README.md" +] + +[package.metadata.docs.rs] +all-features = true + +[lib] +crate-type = ["cdylib", "rlib"] +path = "src/lib.rs" + +[dependencies] +icu_capi = { version = "0.1", path = "../diplomat", default-features = false } + + +# Please keep features/cargo-all-features lists in sync with the icu_capi crate +[features] +default = ["provider_fs", "provider_static"] +provider_fs = ["icu_capi/provider_fs"] +provider_static = ["icu_capi/provider_static"] +smaller_static = ["icu_capi/smaller_static"] +# Enables size-optimized builds on x86_64 +x86tiny = ["icu_capi/x86tiny"] + +[package.metadata.cargo-all-features] +# Omit most optional dependency features from permutation testing +skip_optional_dependencies = true +# Bench feature gets tested separately and is only relevant for CI. +# x86tiny is not relevant in normal environments, +# smaller_static gets tested on the FFI job anyway +denylist = ["bench", "x86tiny", "smaller_static"] diff --git a/ffi/capi_cdylib/src/lib.rs b/ffi/capi_cdylib/src/lib.rs new file mode 100644 index 00000000000..7ad92180c13 --- /dev/null +++ b/ffi/capi_cdylib/src/lib.rs @@ -0,0 +1,29 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + + +//! This exists as a separate crate to work around +//! cargo being unable to conditionally compile crate-types. +//! +//! https://github.com/rust-lang/cargo/issues/4881 +//! +//! This leads to problems like emscripten being unable to link +//! because symbols like log_js are not defined even if the crate_type +//! is not actually desired. As a workaround, the capi_staticlib and capi_dylib +//! crates exist as endpoints to be built when those respective library types are needed. + +// https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations +#![no_std] +#![cfg_attr( + not(test), + deny( + clippy::indexing_slicing, + clippy::unwrap_used, + clippy::expect_used, + clippy::panic + ) +)] + +// Necessary to for symbols to be linked in +extern crate icu_capi; diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs index 137c8d1664e..c4ef0b9251d 100644 --- a/ffi/capi_staticlib/src/lib.rs +++ b/ffi/capi_staticlib/src/lib.rs @@ -4,6 +4,13 @@ //! This exists as a separate crate to work around //! cargo being unable to conditionally compile crate-types. +//! +//! https://github.com/rust-lang/cargo/issues/4881 +//! +//! This leads to problems like emscripten being unable to link +//! because symbols like log_js are not defined even if the crate_type +//! is not actually desired. As a workaround, the capi_staticlib and capi_dylib +//! crates exist as endpoints to be built when those respective library types are needed. // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations #![no_std] diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index c69c8765be7..085006c24a6 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -77,20 +77,3 @@ log = { version = "0.4" } [target.'cfg(not(any(target_arch = "wasm32", target_os = "none")))'.dependencies] icu_provider_fs = { path = "../../provider/fs/", optional = true } - -# Unfortunately, --crate-type cannot be set per-target -# (https://github.com/rust-lang/cargo/issues/4881) -# and emscripten has link errors when compiling icu_capi due to -# symbols like log_js being undefined. There is no way to ask Cargo -# to only build a particular crate type for an invocation -# -# As a workaround, we define an example crate that just reexports icu_capi, -# but is built as a cdylib. Due to how Cargo invocations work around examples, -# `--features` is still passed down to `icu_capi`, but the end result is an -# `icu_capi_cdylib.wasm`/`icu_capi_cdylib.so`/etc file that is for all intents -# and purposes identical to the file one would get from adding "cdylib" to -# `crate-type` above. -[[example]] -name = "icu_capi_cdylib" -path = "src/crate_type_hack.rs" -crate-type = ["cdylib"] diff --git a/ffi/diplomat/src/crate_type_hack.rs b/ffi/diplomat/src/crate_type_hack.rs deleted file mode 100644 index 77e8eba94b8..00000000000 --- a/ffi/diplomat/src/crate_type_hack.rs +++ /dev/null @@ -1,10 +0,0 @@ -// This file is part of ICU4X. For terms of use, please see the file -// called LICENSE at the top level of the ICU4X source tree -// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - -// See comment in icu_capi's Cargo.toml -// -// This is essentially a hack that allows icu_capi to be compiled -// to arbitrary `--crate-type`s without having to add a `--crate-type` -// to the list in Cargo.toml -extern crate icu_capi; diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index 4c04073cc0e..da3c66f3202 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -56,4 +56,3 @@ mod wasm_glue; #[cfg(all(feature = "x86tiny", not(target_os = "none")))] mod x86tiny_glue; - diff --git a/ffi/diplomat/wasm/lib/paths.mjs b/ffi/diplomat/wasm/lib/paths.mjs index 19d5ad233d9..47f8f0a2f96 100644 --- a/ffi/diplomat/wasm/lib/paths.mjs +++ b/ffi/diplomat/wasm/lib/paths.mjs @@ -7,6 +7,6 @@ import * as url from "url"; export const TOP_DIR = path.resolve(path.join(path.dirname(url.fileURLToPath(import.meta.url)), "../../../../")); -export const WASM_PATH = path.resolve(path.join(TOP_DIR, "target/wasm32-unknown-unknown/release/examples/icu_capi_cdylib.wasm")); +export const WASM_PATH = path.resolve(path.join(TOP_DIR, "target/wasm32-unknown-unknown/release/icu_capi_cdylib.wasm")); export const TESTDATA_POSTCARD_PATH = path.resolve(path.join(TOP_DIR, "provider/testdata/data/testdata.postcard")); diff --git a/ffi/diplomat/wasm/lib/wasm.mjs b/ffi/diplomat/wasm/lib/wasm.mjs index 71af0b31711..0edd610f55c 100644 --- a/ffi/diplomat/wasm/lib/wasm.mjs +++ b/ffi/diplomat/wasm/lib/wasm.mjs @@ -37,6 +37,8 @@ if (typeof fetch === 'undefined') { const pathsToTry = [ "./icu_capi.wasm", "../../../../wasmpkg/icu_capi.wasm", + "./icu_capi_cdylib.wasm", + "../../../../wasmpkg/icu_capi_cdylib.wasm", ]; let loadedWasm; for (const path of pathsToTry) { diff --git a/ffi/freertos/src/lib.rs b/ffi/freertos/src/lib.rs index c9c32e9ddae..beb21bbc3b2 100644 --- a/ffi/freertos/src/lib.rs +++ b/ffi/freertos/src/lib.rs @@ -2,7 +2,6 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations #![no_std] #![cfg_attr( @@ -15,7 +14,6 @@ ) )] #![allow(clippy::upper_case_acronyms)] - #![feature(alloc_error_handler)] extern crate alloc; diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml index c6b4ec9d150..d7be4f3ad05 100644 --- a/tools/scripts/wasm.toml +++ b/tools/scripts/wasm.toml @@ -10,7 +10,7 @@ category = "ICU4X WASM" install_crate = { rustup_component_name = "rust-src" } toolchain = "nightly-2021-12-22" command = "cargo" -args = ["wasm-build-dev", "--package", "icu_capi", "--example", "icu_capi_cdylib"] +args = ["wasm-build-dev", "--package", "icu_capi_cdylib"] [tasks.wasm-build-release] description = "Build WASM FFI into the target directory (release mode)" @@ -20,7 +20,7 @@ toolchain = "nightly-2021-12-22" # We don't care about panics in release mode because most incorrect inputs are handled by result types. env = { "RUSTFLAGS" = "-C panic=abort -C opt-level=s" } command = "cargo" -args = ["wasm-build-release", "--package", "icu_capi", "--example", "icu_capi_cdylib"] +args = ["wasm-build-release", "--package", "icu_capi_cdylib"] [tasks.wasm-build-examples] description = "Build WASM examples into the target directory" @@ -47,14 +47,14 @@ args = ["-p", "wasmpkg"] description = "Copy the WASM files from dev into wasmpkg" category = "ICU4X WASM" command = "cp" -args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/debug/examples/icu_capi_cdylib.wasm", "wasmpkg/icu_capi.wasm"] +args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/debug/icu_capi_cdylib.wasm", "wasmpkg/icu_capi.wasm"] dependencies = ["wasm-build-dev", "wasm-dir"] [tasks.wasm-wasm-release] description = "Copy the WASM files from release into wasmpkg" category = "ICU4X WASM" command = "cp" -args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/release/examples/icu_capi_cdylib.wasm", "wasmpkg/icu_capi.wasm"] +args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/release/icu_capi_cdylib.wasm", "wasmpkg/icu_capi.wasm"] dependencies = ["wasm-build-release", "wasm-dir"] [tasks.wasm-cpp-emscripten] @@ -95,8 +95,8 @@ for json_message in ${json_messages} if ${is_compiler_artifact} and ${is_example} # Copy the wasm file to the output directory filename = basename ${json_obj.executable} - # We have the icu_capi_cdylib hack example, which is not a real "example" - # and won't produce an executable here. We should filter it out. + # Some examples may not be real "example"s + # and won't produce executables. We should filter them out. empty = is_empty ${filename} if not ${empty} out_path = concat wasmpkg/ ${filename} From 3288139d6698a83f4fef809b588326d04e1e093c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 15:16:03 -0700 Subject: [PATCH 04/14] Add README for FFI --- ffi/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ffi/README.md diff --git a/ffi/README.md b/ffi/README.md new file mode 100644 index 00000000000..c36e23debb5 --- /dev/null +++ b/ffi/README.md @@ -0,0 +1,11 @@ +# ICU4X FFI crates + +This folder contains various FFI crates for ICU4X. + +The primary ICU4X FFI API is generated via [diplomat](https://github.com/rust-diplomat/diplomat/) and can be found under `ffi/diplomat` (crate name `icu_capi`), alongside generated C, C++, and WASM bindings. + +Due to [cargo #4881](https://github.com/rust-lang/cargo/issues/4881), it's not possible for `crate-type`s to be selectively built, and this can cause problems when designing FFI crates to be built on different platforms. For that reason, the `ffi/diplomat` `icu_capi` crate only builds as an `rlib` and should not be used directly when performing FFI. Instead, the `icu_capi_staticlib` (`ffi/capi_staticlib`) or `icu_capi_cdylib` (`ffi/capi_cdylib`) crates should be built to get the appropriate staticlib or cdylib target. + +Some platforms and build systems will have special bindings: currently we have one such case: FreeRTOS. If you wish to build ICU4X for FreeRTOS, use the `ffi/freertos` (`icu_freertos`) crate. + +The `ffi/ecma402` (`icu4x_ecma402`) crate contains an implementation of the [`ecma402_traits`](https://docs.rs/ecma402_traits) traits, enabling compatibility testing against ICU. From cbaf12baeabc110d80719afb776abb5956d98049 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 15:17:35 -0700 Subject: [PATCH 05/14] generate readmes --- ffi/capi_cdylib/README.md | 15 +++++++++++++++ ffi/capi_cdylib/src/lib.rs | 3 +-- ffi/capi_staticlib/README.md | 15 +++++++++++++++ ffi/freertos/README.md | 7 +++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 ffi/capi_cdylib/README.md create mode 100644 ffi/capi_staticlib/README.md create mode 100644 ffi/freertos/README.md diff --git a/ffi/capi_cdylib/README.md b/ffi/capi_cdylib/README.md new file mode 100644 index 00000000000..ddf9db1cf9a --- /dev/null +++ b/ffi/capi_cdylib/README.md @@ -0,0 +1,15 @@ +# icu_capi_cdylib [![crates.io](https://img.shields.io/crates/v/icu_capi_cdylib)](https://crates.io/crates/icu_capi_cdylib) + +This exists as a separate crate to work around +cargo being unable to conditionally compile crate-types. + +https://github.com/rust-lang/cargo/issues/4881 + +This leads to problems like emscripten being unable to link +because symbols like log_js are not defined even if the crate_type +is not actually desired. As a workaround, the capi_staticlib and capi_dylib +crates exist as endpoints to be built when those respective library types are needed. + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/ffi/capi_cdylib/src/lib.rs b/ffi/capi_cdylib/src/lib.rs index 7ad92180c13..c4ef0b9251d 100644 --- a/ffi/capi_cdylib/src/lib.rs +++ b/ffi/capi_cdylib/src/lib.rs @@ -2,10 +2,9 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - //! This exists as a separate crate to work around //! cargo being unable to conditionally compile crate-types. -//! +//! //! https://github.com/rust-lang/cargo/issues/4881 //! //! This leads to problems like emscripten being unable to link diff --git a/ffi/capi_staticlib/README.md b/ffi/capi_staticlib/README.md new file mode 100644 index 00000000000..dfe39d48878 --- /dev/null +++ b/ffi/capi_staticlib/README.md @@ -0,0 +1,15 @@ +# icu_capi_staticlib [![crates.io](https://img.shields.io/crates/v/icu_capi_staticlib)](https://crates.io/crates/icu_capi_staticlib) + +This exists as a separate crate to work around +cargo being unable to conditionally compile crate-types. + +https://github.com/rust-lang/cargo/issues/4881 + +This leads to problems like emscripten being unable to link +because symbols like log_js are not defined even if the crate_type +is not actually desired. As a workaround, the capi_staticlib and capi_dylib +crates exist as endpoints to be built when those respective library types are needed. + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/ffi/freertos/README.md b/ffi/freertos/README.md new file mode 100644 index 00000000000..99aed3f798c --- /dev/null +++ b/ffi/freertos/README.md @@ -0,0 +1,7 @@ +# icu_freertos [![crates.io](https://img.shields.io/crates/v/icu_freertos)](https://crates.io/crates/icu_freertos) + + + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). From 21eb1cfa47a9ddb37d77260cecc55c0d44e30dfc Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 18:25:00 -0700 Subject: [PATCH 06/14] Fix all-targets errors --- ffi/diplomat/Cargo.toml | 5 ++++- ffi/diplomat/src/lib.rs | 4 ++-- ffi/freertos/src/lib.rs | 42 +++++++++++++++++++++++++---------------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index 085006c24a6..6fab918811a 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -33,7 +33,7 @@ skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. # x86tiny is not relevant in normal environments, # smaller_static gets tested on the FFI job anyway -denylist = ["bench", "x86tiny", "smaller_static"] +denylist = ["bench", "x86tiny", "smaller_static", "internal_all_features_hack"] [lib] crate-type = ["rlib"] @@ -47,6 +47,9 @@ provider_static = ["icu_testdata"] smaller_static = ["provider_static"] # Enables size-optimized builds on x86_64 x86tiny = ["dlmalloc"] +# We can't exclude x86tiny from `--all-features` and it messes up the build for other crates +# Instead, we use this feature to detect when `--all-features` is occurring +internal_all_features_hack = [] [dependencies] fixed_decimal = { path = "../../utils/fixed_decimal", features = ["ryu"] } diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index da3c66f3202..e3f700d0265 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -15,7 +15,7 @@ )] #![allow(clippy::upper_case_acronyms)] #![cfg_attr( - any(feature = "x86tiny", target_os = "none"), + all(feature = "x86tiny", not(feature = "internal_all_features_hack")), feature(alloc_error_handler) )] @@ -54,5 +54,5 @@ pub mod segmenter_line; #[cfg(target_arch = "wasm32")] mod wasm_glue; -#[cfg(all(feature = "x86tiny", not(target_os = "none")))] +#[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))] mod x86tiny_glue; diff --git a/ffi/freertos/src/lib.rs b/ffi/freertos/src/lib.rs index beb21bbc3b2..6694c644a82 100644 --- a/ffi/freertos/src/lib.rs +++ b/ffi/freertos/src/lib.rs @@ -4,6 +4,7 @@ // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations #![no_std] + #![cfg_attr( not(test), deny( @@ -14,28 +15,37 @@ ) )] #![allow(clippy::upper_case_acronyms)] -#![feature(alloc_error_handler)] -extern crate alloc; + +#![cfg_attr(target_os = "none", feature(alloc_error_handler))] // Necessary to for symbols to be linked in extern crate icu_capi; -use alloc::alloc::Layout; -use core::panic::PanicInfo; -use cortex_m::asm; -use freertos_rust::FreeRtosAllocator; +// CFG it off so that it doesn't break the --all-features build due to needing unstable rust +#[cfg(target_os = "none")] +mod stuff { + extern crate alloc; -#[global_allocator] -static GLOBAL: FreeRtosAllocator = FreeRtosAllocator; -#[alloc_error_handler] -fn alloc_error(_layout: Layout) -> ! { - asm::bkpt(); - loop {} -} + use alloc::alloc::Layout; + use core::panic::PanicInfo; + use cortex_m::asm; + use freertos_rust::FreeRtosAllocator; + + #[global_allocator] + static GLOBAL: FreeRtosAllocator = FreeRtosAllocator; + + + #[alloc_error_handler] + fn alloc_error(_layout: Layout) -> ! { + asm::bkpt(); + loop {} + } -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop {} + #[cfg(target_os = "none")] + #[panic_handler] + fn panic(_info: &PanicInfo) -> ! { + loop {} + } } From e35f8ea198aa3dea5fb13f7971f7c17995a46777 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 18:26:05 -0700 Subject: [PATCH 07/14] fix cargo warning about clashing target names --- utils/yoke/derive/examples/{derive.rs => yoke_derive.rs} | 0 utils/zerofrom/derive/examples/{derive.rs => zf_derive.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename utils/yoke/derive/examples/{derive.rs => yoke_derive.rs} (100%) rename utils/zerofrom/derive/examples/{derive.rs => zf_derive.rs} (100%) diff --git a/utils/yoke/derive/examples/derive.rs b/utils/yoke/derive/examples/yoke_derive.rs similarity index 100% rename from utils/yoke/derive/examples/derive.rs rename to utils/yoke/derive/examples/yoke_derive.rs diff --git a/utils/zerofrom/derive/examples/derive.rs b/utils/zerofrom/derive/examples/zf_derive.rs similarity index 100% rename from utils/zerofrom/derive/examples/derive.rs rename to utils/zerofrom/derive/examples/zf_derive.rs From b3de0d6094de36dc190625e527c826a9b14db6fb Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:13:26 -0700 Subject: [PATCH 08/14] Move x86tiny to staticlib --- Cargo.lock | 2 +- ffi/capi_cdylib/Cargo.toml | 4 +--- ffi/capi_staticlib/Cargo.toml | 12 ++++++++++-- ffi/capi_staticlib/src/lib.rs | 12 ++++++++++++ ffi/{diplomat => capi_staticlib}/src/x86tiny_glue.rs | 0 ffi/diplomat/Cargo.toml | 12 +----------- ffi/diplomat/src/lib.rs | 8 +------- 7 files changed, 26 insertions(+), 24 deletions(-) rename ffi/{diplomat => capi_staticlib}/src/x86tiny_glue.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 36916f93c4f..7d7fcf6b3ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1072,7 +1072,6 @@ version = "0.1.0" dependencies = [ "diplomat", "diplomat-runtime", - "dlmalloc", "fixed_decimal", "icu_decimal", "icu_locale_canonicalizer", @@ -1102,6 +1101,7 @@ dependencies = [ name = "icu_capi_staticlib" version = "0.1.0" dependencies = [ + "dlmalloc", "icu_capi", ] diff --git a/ffi/capi_cdylib/Cargo.toml b/ffi/capi_cdylib/Cargo.toml index 13276887b92..cbad88f45ca 100644 --- a/ffi/capi_cdylib/Cargo.toml +++ b/ffi/capi_cdylib/Cargo.toml @@ -37,8 +37,6 @@ default = ["provider_fs", "provider_static"] provider_fs = ["icu_capi/provider_fs"] provider_static = ["icu_capi/provider_static"] smaller_static = ["icu_capi/smaller_static"] -# Enables size-optimized builds on x86_64 -x86tiny = ["icu_capi/x86tiny"] [package.metadata.cargo-all-features] # Omit most optional dependency features from permutation testing @@ -46,4 +44,4 @@ skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. # x86tiny is not relevant in normal environments, # smaller_static gets tested on the FFI job anyway -denylist = ["bench", "x86tiny", "smaller_static"] +denylist = ["bench", "smaller_static"] diff --git a/ffi/capi_staticlib/Cargo.toml b/ffi/capi_staticlib/Cargo.toml index 00731075dd3..cdcec538908 100644 --- a/ffi/capi_staticlib/Cargo.toml +++ b/ffi/capi_staticlib/Cargo.toml @@ -37,8 +37,12 @@ default = ["provider_fs", "provider_static"] provider_fs = ["icu_capi/provider_fs"] provider_static = ["icu_capi/provider_static"] smaller_static = ["icu_capi/smaller_static"] + # Enables size-optimized builds on x86_64 -x86tiny = ["icu_capi/x86tiny"] +x86tiny = ["dlmalloc"] + +# Hack to prevent nightly code from being compiled with --all-features +internal_all_features_hack = [] [package.metadata.cargo-all-features] # Omit most optional dependency features from permutation testing @@ -46,4 +50,8 @@ skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. # x86tiny is not relevant in normal environments, # smaller_static gets tested on the FFI job anyway -denylist = ["bench", "x86tiny", "smaller_static"] +denylist = ["bench", "x86tiny", "smaller_static", "internal_all_features_hack"] + +# This cfg originates in dlmalloc/lib.rs +[target.'cfg(any(target_os = "linux", target_os = "macos", target_arch = "wasm32"))'.dependencies] +dlmalloc = { version = "0.2", optional = true, features = ["global"] } diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs index c4ef0b9251d..a0178c25cd8 100644 --- a/ffi/capi_staticlib/src/lib.rs +++ b/ffi/capi_staticlib/src/lib.rs @@ -24,5 +24,17 @@ ) )] + +#![cfg_attr( + all(feature = "x86tiny", not(feature = "internal_all_features_hack")), + feature(alloc_error_handler) +)] + // Necessary to for symbols to be linked in extern crate icu_capi; + +extern crate alloc; + + +#[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))] +mod x86tiny_glue; diff --git a/ffi/diplomat/src/x86tiny_glue.rs b/ffi/capi_staticlib/src/x86tiny_glue.rs similarity index 100% rename from ffi/diplomat/src/x86tiny_glue.rs rename to ffi/capi_staticlib/src/x86tiny_glue.rs diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index 6fab918811a..be94dd4b683 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -31,9 +31,8 @@ all-features = true # Omit most optional dependency features from permutation testing skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. -# x86tiny is not relevant in normal environments, # smaller_static gets tested on the FFI job anyway -denylist = ["bench", "x86tiny", "smaller_static", "internal_all_features_hack"] +denylist = ["bench", "smaller_static"] [lib] crate-type = ["rlib"] @@ -45,11 +44,6 @@ default = ["provider_fs", "provider_static"] provider_fs = ["icu_provider_fs", "icu_provider_fs/deserialize_json"] provider_static = ["icu_testdata"] smaller_static = ["provider_static"] -# Enables size-optimized builds on x86_64 -x86tiny = ["dlmalloc"] -# We can't exclude x86tiny from `--all-features` and it messes up the build for other crates -# Instead, we use this feature to detect when `--all-features` is occurring -internal_all_features_hack = [] [dependencies] fixed_decimal = { path = "../../utils/fixed_decimal", features = ["ryu"] } @@ -71,10 +65,6 @@ diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "a46d01025 diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "a46d01025159e842982b2e4bc8ca9361d4b897dc" } icu_testdata = { version = "0.5", path = "../../provider/testdata", default-features = false, features = ["static"], optional = true } -# This cfg originates in dlmalloc/lib.rs -[target.'cfg(any(target_os = "linux", target_os = "macos", target_arch = "wasm32"))'.dependencies] -dlmalloc = { version = "0.2", optional = true, features = ["global"] } - [target.'cfg(target_arch = "wasm32")'.dependencies] log = { version = "0.4" } diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index e3f700d0265..a52bcb52fb7 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -14,10 +14,6 @@ ) )] #![allow(clippy::upper_case_acronyms)] -#![cfg_attr( - all(feature = "x86tiny", not(feature = "internal_all_features_hack")), - feature(alloc_error_handler) -)] //! This module contains the source of truth for the [Diplomat](https://github.com/rust-diplomat/diplomat)-generated //! FFI bindings. This generates the C, C++ and Wasm bindings. This module also contains the C @@ -34,7 +30,7 @@ // Needed to be able to build cdylibs/etc // // Renamed so you can't accidentally use it -#[cfg(all(not(target_os = "none"), not(feature = "x86tiny")))] +#[cfg(target_arch = "wasm32")] extern crate std as rust_std; extern crate alloc; @@ -54,5 +50,3 @@ pub mod segmenter_line; #[cfg(target_arch = "wasm32")] mod wasm_glue; -#[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))] -mod x86tiny_glue; From 550bbadfec4cd17d3e4b5666ec01082f72be1227 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:13:48 -0700 Subject: [PATCH 09/14] rm rlib --- ffi/diplomat/Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index be94dd4b683..00cc57d2a35 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -34,10 +34,6 @@ skip_optional_dependencies = true # smaller_static gets tested on the FFI job anyway denylist = ["bench", "smaller_static"] -[lib] -crate-type = ["rlib"] -path = "src/lib.rs" - # Please keep the features list in sync with the icu_capi_staticlib crate [features] default = ["provider_fs", "provider_static"] From 8b99e9c9f6d6f0df4e94558d3a070f78a01251e8 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:29:30 -0700 Subject: [PATCH 10/14] fixup ci --- ffi/capi_cdylib/Cargo.toml | 4 ++++ ffi/capi_staticlib/Cargo.toml | 4 ++++ ffi/capi_staticlib/README.md | 4 +--- ffi/capi_staticlib/src/lib.rs | 7 +------ ffi/diplomat/src/lib.rs | 1 - ffi/freertos/Cargo.toml | 4 ++++ ffi/freertos/src/lib.rs | 5 ----- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ffi/capi_cdylib/Cargo.toml b/ffi/capi_cdylib/Cargo.toml index cbad88f45ca..7473cbfed17 100644 --- a/ffi/capi_cdylib/Cargo.toml +++ b/ffi/capi_cdylib/Cargo.toml @@ -1,3 +1,7 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + [package] name = "icu_capi_cdylib" description = "C interface to ICU4X" diff --git a/ffi/capi_staticlib/Cargo.toml b/ffi/capi_staticlib/Cargo.toml index cdcec538908..6cac025b4b1 100644 --- a/ffi/capi_staticlib/Cargo.toml +++ b/ffi/capi_staticlib/Cargo.toml @@ -1,3 +1,7 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + [package] name = "icu_capi_staticlib" description = "C interface to ICU4X" diff --git a/ffi/capi_staticlib/README.md b/ffi/capi_staticlib/README.md index dfe39d48878..02b86e6ea92 100644 --- a/ffi/capi_staticlib/README.md +++ b/ffi/capi_staticlib/README.md @@ -1,9 +1,7 @@ # icu_capi_staticlib [![crates.io](https://img.shields.io/crates/v/icu_capi_staticlib)](https://crates.io/crates/icu_capi_staticlib) This exists as a separate crate to work around -cargo being unable to conditionally compile crate-types. - -https://github.com/rust-lang/cargo/issues/4881 +cargo being [unable to conditionally compile crate-types](https://github.com/rust-lang/cargo/issues/4881). This leads to problems like emscripten being unable to link because symbols like log_js are not defined even if the crate_type diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs index a0178c25cd8..cc9c73ac2d8 100644 --- a/ffi/capi_staticlib/src/lib.rs +++ b/ffi/capi_staticlib/src/lib.rs @@ -3,9 +3,7 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). //! This exists as a separate crate to work around -//! cargo being unable to conditionally compile crate-types. -//! -//! https://github.com/rust-lang/cargo/issues/4881 +//! cargo being [unable to conditionally compile crate-types](https://github.com/rust-lang/cargo/issues/4881). //! //! This leads to problems like emscripten being unable to link //! because symbols like log_js are not defined even if the crate_type @@ -23,8 +21,6 @@ clippy::panic ) )] - - #![cfg_attr( all(feature = "x86tiny", not(feature = "internal_all_features_hack")), feature(alloc_error_handler) @@ -35,6 +31,5 @@ extern crate icu_capi; extern crate alloc; - #[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))] mod x86tiny_glue; diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index a52bcb52fb7..98e4a425012 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -49,4 +49,3 @@ pub mod segmenter_line; #[cfg(target_arch = "wasm32")] mod wasm_glue; - diff --git a/ffi/freertos/Cargo.toml b/ffi/freertos/Cargo.toml index b328737ebd2..5c067eac006 100644 --- a/ffi/freertos/Cargo.toml +++ b/ffi/freertos/Cargo.toml @@ -1,3 +1,7 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + [package] name = "icu_freertos" description = "C interface to ICU4X" diff --git a/ffi/freertos/src/lib.rs b/ffi/freertos/src/lib.rs index 6694c644a82..4ccbf0698f2 100644 --- a/ffi/freertos/src/lib.rs +++ b/ffi/freertos/src/lib.rs @@ -4,7 +4,6 @@ // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations #![no_std] - #![cfg_attr( not(test), deny( @@ -15,8 +14,6 @@ ) )] #![allow(clippy::upper_case_acronyms)] - - #![cfg_attr(target_os = "none", feature(alloc_error_handler))] // Necessary to for symbols to be linked in @@ -27,7 +24,6 @@ extern crate icu_capi; mod stuff { extern crate alloc; - use alloc::alloc::Layout; use core::panic::PanicInfo; use cortex_m::asm; @@ -36,7 +32,6 @@ mod stuff { #[global_allocator] static GLOBAL: FreeRtosAllocator = FreeRtosAllocator; - #[alloc_error_handler] fn alloc_error(_layout: Layout) -> ! { asm::bkpt(); From 88a6b6caee94244c35b68b69fd750031ae6a60a9 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:34:29 -0700 Subject: [PATCH 11/14] fix std linkage --- ffi/capi_cdylib/src/lib.rs | 6 ++++++ ffi/capi_staticlib/src/lib.rs | 7 +++++++ ffi/diplomat/src/lib.rs | 2 -- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ffi/capi_cdylib/src/lib.rs b/ffi/capi_cdylib/src/lib.rs index c4ef0b9251d..14e59fd93e7 100644 --- a/ffi/capi_cdylib/src/lib.rs +++ b/ffi/capi_cdylib/src/lib.rs @@ -26,3 +26,9 @@ // Necessary to for symbols to be linked in extern crate icu_capi; + +// Needed to be able to build cdylibs/etc +// +// Renamed so you can't accidentally use it +#[cfg(not(feature = "x86tiny"))] +extern crate std as rust_std; diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs index cc9c73ac2d8..f55d1bb6f42 100644 --- a/ffi/capi_staticlib/src/lib.rs +++ b/ffi/capi_staticlib/src/lib.rs @@ -26,9 +26,16 @@ feature(alloc_error_handler) )] + // Necessary to for symbols to be linked in extern crate icu_capi; +// Needed to be able to build cdylibs/etc +// +// Renamed so you can't accidentally use it +#[cfg(not(feature = "x86tiny"))] +extern crate std as rust_std; + extern crate alloc; #[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))] diff --git a/ffi/diplomat/src/lib.rs b/ffi/diplomat/src/lib.rs index 98e4a425012..b44c604acde 100644 --- a/ffi/diplomat/src/lib.rs +++ b/ffi/diplomat/src/lib.rs @@ -27,8 +27,6 @@ //! ``` //! -// Needed to be able to build cdylibs/etc -// // Renamed so you can't accidentally use it #[cfg(target_arch = "wasm32")] extern crate std as rust_std; From 4c29e2ccd7a03ee56086df8755ea04b4d7da90db Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:41:25 -0700 Subject: [PATCH 12/14] tidy --- ffi/capi_cdylib/README.md | 4 +--- ffi/capi_cdylib/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ffi/capi_cdylib/README.md b/ffi/capi_cdylib/README.md index ddf9db1cf9a..66b4201a4bd 100644 --- a/ffi/capi_cdylib/README.md +++ b/ffi/capi_cdylib/README.md @@ -1,9 +1,7 @@ # icu_capi_cdylib [![crates.io](https://img.shields.io/crates/v/icu_capi_cdylib)](https://crates.io/crates/icu_capi_cdylib) This exists as a separate crate to work around -cargo being unable to conditionally compile crate-types. - -https://github.com/rust-lang/cargo/issues/4881 +cargo being [unable to conditionally compile crate-types](https://github.com/rust-lang/cargo/issues/4881). This leads to problems like emscripten being unable to link because symbols like log_js are not defined even if the crate_type diff --git a/ffi/capi_cdylib/src/lib.rs b/ffi/capi_cdylib/src/lib.rs index 14e59fd93e7..f82b3839a9b 100644 --- a/ffi/capi_cdylib/src/lib.rs +++ b/ffi/capi_cdylib/src/lib.rs @@ -3,9 +3,7 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). //! This exists as a separate crate to work around -//! cargo being unable to conditionally compile crate-types. -//! -//! https://github.com/rust-lang/cargo/issues/4881 +//! cargo being [unable to conditionally compile crate-types](https://github.com/rust-lang/cargo/issues/4881). //! //! This leads to problems like emscripten being unable to link //! because symbols like log_js are not defined even if the crate_type From bff509cb99191e891832880f3ac8bc49be5152ef Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:41:33 -0700 Subject: [PATCH 13/14] fmt --- ffi/capi_staticlib/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/ffi/capi_staticlib/src/lib.rs b/ffi/capi_staticlib/src/lib.rs index f55d1bb6f42..f04d669350f 100644 --- a/ffi/capi_staticlib/src/lib.rs +++ b/ffi/capi_staticlib/src/lib.rs @@ -26,7 +26,6 @@ feature(alloc_error_handler) )] - // Necessary to for symbols to be linked in extern crate icu_capi; From 6a906509811f3a939c3f37f1485e027f819cb976 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2022 19:44:04 -0700 Subject: [PATCH 14/14] licenses --- ffi/capi_cdylib/LICENSE | 331 +++++++++++++++++++++++++++++++++++++ ffi/capi_staticlib/LICENSE | 331 +++++++++++++++++++++++++++++++++++++ ffi/freertos/LICENSE | 331 +++++++++++++++++++++++++++++++++++++ 3 files changed, 993 insertions(+) create mode 100644 ffi/capi_cdylib/LICENSE create mode 100644 ffi/capi_staticlib/LICENSE create mode 100644 ffi/freertos/LICENSE diff --git a/ffi/capi_cdylib/LICENSE b/ffi/capi_cdylib/LICENSE new file mode 100644 index 00000000000..5ab1f57507b --- /dev/null +++ b/ffi/capi_cdylib/LICENSE @@ -0,0 +1,331 @@ +Except as otherwise noted below, ICU4X is licensed under the Apache +License, Version 2.0 (included below) or the MIT license (included +below), at your option. Unless importing data or code in the manner +stated below, any contribution intentionally submitted for inclusion +in ICU4X by you, as defined in the Apache-2.0 license, shall be dual +licensed in the foregoing manner, without any additional terms or +conditions. + +As exceptions to the above: +* Portions of ICU4X that have been adapted from ICU4C and/or ICU4J are +under the Unicode license (included below) and/or the ICU license +(included below) as indicated by source code comments. +* Unicode data incorporated in ICU4X is under the Unicode license +(included below). +* Your contributions may import code from ICU4C and/or ICU4J and +Unicode data under these licenses. Indicate the license and the ICU4C +or ICU4J origin in source code comments. + +- - - - + +Apache License, version 2.0 + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +- - - - + +MIT License + +Copyright The ICU4X Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +- - - - + +Unicode License + +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +- - - - + +ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +- - - - diff --git a/ffi/capi_staticlib/LICENSE b/ffi/capi_staticlib/LICENSE new file mode 100644 index 00000000000..5ab1f57507b --- /dev/null +++ b/ffi/capi_staticlib/LICENSE @@ -0,0 +1,331 @@ +Except as otherwise noted below, ICU4X is licensed under the Apache +License, Version 2.0 (included below) or the MIT license (included +below), at your option. Unless importing data or code in the manner +stated below, any contribution intentionally submitted for inclusion +in ICU4X by you, as defined in the Apache-2.0 license, shall be dual +licensed in the foregoing manner, without any additional terms or +conditions. + +As exceptions to the above: +* Portions of ICU4X that have been adapted from ICU4C and/or ICU4J are +under the Unicode license (included below) and/or the ICU license +(included below) as indicated by source code comments. +* Unicode data incorporated in ICU4X is under the Unicode license +(included below). +* Your contributions may import code from ICU4C and/or ICU4J and +Unicode data under these licenses. Indicate the license and the ICU4C +or ICU4J origin in source code comments. + +- - - - + +Apache License, version 2.0 + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +- - - - + +MIT License + +Copyright The ICU4X Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +- - - - + +Unicode License + +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +- - - - + +ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +- - - - diff --git a/ffi/freertos/LICENSE b/ffi/freertos/LICENSE new file mode 100644 index 00000000000..5ab1f57507b --- /dev/null +++ b/ffi/freertos/LICENSE @@ -0,0 +1,331 @@ +Except as otherwise noted below, ICU4X is licensed under the Apache +License, Version 2.0 (included below) or the MIT license (included +below), at your option. Unless importing data or code in the manner +stated below, any contribution intentionally submitted for inclusion +in ICU4X by you, as defined in the Apache-2.0 license, shall be dual +licensed in the foregoing manner, without any additional terms or +conditions. + +As exceptions to the above: +* Portions of ICU4X that have been adapted from ICU4C and/or ICU4J are +under the Unicode license (included below) and/or the ICU license +(included below) as indicated by source code comments. +* Unicode data incorporated in ICU4X is under the Unicode license +(included below). +* Your contributions may import code from ICU4C and/or ICU4J and +Unicode data under these licenses. Indicate the license and the ICU4C +or ICU4J origin in source code comments. + +- - - - + +Apache License, version 2.0 + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +- - - - + +MIT License + +Copyright The ICU4X Authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +- - - - + +Unicode License + +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +- - - - + +ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +- - - -