Skip to content

Commit b3e4bd5

Browse files
committed
ffibake
1 parent e3122d1 commit b3e4bd5

File tree

20 files changed

+287
-177
lines changed

20 files changed

+287
-177
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ffi/capi_cdylib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ icu_provider = { version = "1.0.0", path = "../../provider/core", default-featur
4141
default = ["icu_capi/default"]
4242
any_provider = ["icu_capi/any_provider"]
4343
buffer_provider = ["icu_capi/buffer_provider"]
44+
baked_provider = ["icu_capi/baked_provider"]
4445
provider_fs = ["icu_capi/provider_fs"] # Indirectly implies buffer_provider
4546
provider_test = ["icu_capi/provider_test"]
4647
logging = ["icu_capi/logging"]

ffi/capi_staticlib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ icu_provider = { version = "1.0.0", path = "../../provider/core", default-featur
4141
default = ["icu_capi/default"]
4242
any_provider = ["icu_capi/any_provider"]
4343
buffer_provider = ["icu_capi/buffer_provider"]
44+
baked_provider = ["icu_capi/baked_provider"]
4445
provider_fs = ["icu_capi/provider_fs"] # Indirectly implies buffer_provider
4546
provider_test = ["icu_capi/provider_test"]
4647
logging = ["icu_capi/logging"]

ffi/diplomat/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ all-features = true
3232
skip_optional_dependencies = true
3333
# Bench feature gets tested separately and is only relevant for CI.
3434
# logging enables a feature of a dependency that has no externally visible API changes
35-
# serde enables dependency features but buffer_provider affects the actual code
36-
denylist = ["bench", "logging"]
35+
# baked_provider requires datagen.
36+
denylist = ["bench", "logging", "baked_provider"]
3737

3838
# Please keep the features list in sync with the icu_capi_staticlib/icu_capi_cdylib crates
3939
[features]
@@ -61,6 +61,7 @@ provider_test = ["dep:icu_testdata"]
6161
logging = ["icu_provider/log_error_context", "dep:log"]
6262
# Use the env_logger functionality to log based on environment variables
6363
simple_logger = ["dep:simple_logger"]
64+
baked_provider = ["any_provider", "dep:zerovec"]
6465

6566
# meta feature for things we enable by default in C and C++
6667
cpp_default = ["provider_test", "logging", "simple_logger"]
@@ -94,6 +95,8 @@ serde = { version = "1.0", default-features = false, optional = true }
9495

9596
icu_testdata = { version = "1.0.0", path = "../../provider/testdata", optional = true, features = ["icu_segmenter"] }
9697

98+
zerovec = { version = "*", path = "../../utils/zerovec", optional = true}
99+
97100
# Run `cargo make diplomat-install` to get the right diplomat binary installed
98101
# The version here can either be a `version = ".."` spec or `git = "https://github.com/rust-diplomat/diplomat", rev = ".."`
99102
# Since this crate is published, Diplomat must be published preceding a new ICU4X release but may use git versions in between

ffi/diplomat/c/examples/fixeddecimal_tiny/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ optim*
55
*.elf
66
*.o
77
a.out.dSYM
8-
decimal-bn-en.postcard
9-
decimal_bn_en.h
8+
baked

ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,49 @@ GCC := gcc
1717
CLANG := clang-14
1818
LLD := lld-14
1919

20+
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
2021

21-
../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST)
22-
cargo build -p icu_capi_staticlib --no-default-features --features buffer_provider
22+
../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) baked/mod.rs
23+
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs cargo build -p icu_capi_staticlib --no-default-features --features baked_provider
2324

24-
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST)
25+
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST) baked/mod.rs
2526
cd icu_capi_staticlib_tiny && \
26-
RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu
27+
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu
2728

28-
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST)
29+
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST) baked/mod.rs
2930
cd icu_capi_staticlib_tiny && \
30-
RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size
31+
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size
3132

32-
decimal-bn-en.postcard:
33-
cargo run -p icu_datagen --features bin -- --locales en bn --keys "decimal/symbols@1" --cldr-root ../../../../../provider/testdata/data/cldr/ --format blob --out decimal-bn-en.postcard
34-
35-
decimal_bn_en.h: decimal-bn-en.postcard
36-
xxd -i -C decimal-bn-en.postcard > decimal_bn_en.h
33+
baked/mod.rs:
34+
cargo run -p icu_datagen --features bin,icu_segmenter -- --locales en bn --all-keys --cldr-tag 42.0.0 --icuexport-tag release-72-1 --format mod --out baked --use-separate-crates
3735

3836
# Naive target: no optimizations, full std
39-
optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c decimal_bn_en.h
37+
optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c
4038
$(GCC) test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o optim0.elf
4139

4240
# optim.elf: gcc with maximum link-time code stripping (gc-sections and strip-all)
43-
optim1.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c decimal_bn_en.h
41+
optim1.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c
4442
$(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
4543

4644
# optim2.elf: clang single-step with gc-sections
47-
optim2.elf: icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a $(ALL_HEADERS) test.c decimal_bn_en.h
45+
optim2.elf: icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a $(ALL_HEADERS) test.c
4846
$(CLANG) -flto -fdata-sections -ffunction-sections test.c icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a -g -o optim2.elf -Wl,--gc-sections
4947

50-
optim3.o: $(ALL_HEADERS) test.c decimal_bn_en.h
48+
optim3.o: $(ALL_HEADERS) test.c
5149
$(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim3.o
5250

5351
# optim3.elf: clang two-step with lld, debug mode
5452
optim3.elf: optim3.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a
5553
$(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim3.elf optim3.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a -Wl,--gc-sections
5654

57-
optim4.o: $(ALL_HEADERS) test.c decimal_bn_en.h
55+
optim4.o: $(ALL_HEADERS) test.c
5856
$(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim4.o
5957

6058
# optim4.elf: clang two-step with lld, release mode with debug symbols
6159
optim4.elf: optim4.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a
6260
$(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim4.elf optim4.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a -Wl,--gc-sections
6361

64-
optim5.o: $(ALL_HEADERS) test.c decimal_bn_en.h
62+
optim5.o: $(ALL_HEADERS) test.c
6563
$(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -o optim5.o
6664

6765
# optim5.elf: clang two-step with lld, release mode stripped of debug symbols

0 commit comments

Comments
 (0)