Skip to content

Commit 0f1e796

Browse files
committed
ffibake
1 parent 15d8e3a commit 0f1e796

File tree

29 files changed

+525
-347
lines changed

29 files changed

+525
-347
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ provider/testdata/data/icuexport/** linguist-generated=true
66
ffi/diplomat/c/include/** linguist-generated=true
77
ffi/diplomat/cpp/include/** linguist-generated=true
88
ffi/diplomat/cpp/docs/** linguist-generated=true
9-
ffi/diplomat/js/include//** linguist-generated=true
9+
ffi/diplomat/js/include/** linguist-generated=true
1010
ffi/diplomat/js/docs/** linguist-generated=true
1111
*.rs.data linguist-language=Rust
1212
*/**/README.md linguist-generated=true

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/diplomat/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ 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
3635
denylist = ["bench", "logging"]
3736

3837
# Please keep the features list in sync with the icu_capi_staticlib/icu_capi_cdylib crates
3938
[features]
40-
default = ["any_provider"]
39+
default = []
4140
any_provider = []
4241
buffer_provider = [
4342
"dep:icu_provider_blob",
@@ -63,7 +62,7 @@ logging = ["icu_provider/log_error_context", "dep:log"]
6362
simple_logger = ["dep:simple_logger"]
6463

6564
# meta feature for things we enable by default in C and C++
66-
cpp_default = ["provider_test", "logging", "simple_logger"]
65+
cpp_default = ["provider_test", "any_provider", "logging", "simple_logger"]
6766

6867
# meta feature for things we enable by default in wasm
6968
wasm_default = ["buffer_provider", "logging"]
@@ -94,6 +93,9 @@ serde = { version = "1.0", default-features = false, optional = true }
9493

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

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

ffi/diplomat/build.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4+
5+
fn main() {
6+
if std::env::var("ICU4X_FFI_BAKED_ROOT").is_err() {
7+
// Empty data generated with
8+
// cargo run -p icu_datagen --features bin,icu_segmenter -- --format mod --use-separate-crates --keys none --out empty_bake
9+
println!(
10+
"cargo:rustc-env=ICU4X_FFI_BAKED_ROOT={}/empty_bake",
11+
std::env::var("CARGO_MANIFEST_DIR").unwrap()
12+
);
13+
}
14+
}

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+
export ICU4X_FFI_BAKED_ROOT = $(dir $(realpath $(lastword $(MAKEFILE_LIST))))baked
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) $(ICU4X_FFI_BAKED_ROOT)
23+
cargo build -p icu_capi_staticlib --no-default-features
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) $(ICU4X_FFI_BAKED_ROOT)
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+
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) $(ICU4X_FFI_BAKED_ROOT)
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+
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+
$(ICU4X_FFI_BAKED_ROOT):
34+
cargo run -p icu_datagen --features bin,icu_segmenter -- --locales en bn --keys "decimal/symbols@1" --cldr-root ../../../../../provider/testdata/data/cldr/ --format mod --use-separate-crates --out ${ICU4X_FFI_BAKED_ROOT}
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)