snmalloc
snmalloc copied to clipboard
feat: add rust bindings
Use existing bazel tools to generate rust bindings for bazel users
I'm seeing issues with using bindings for src/snmalloc/override/rust.cc
INFO: Analyzed target //src/snmalloc_rs:test (0 packages loaded, 0 targets configured).
ERROR: /Users/jaya.kasa/dev/snmalloc/src/snmalloc_rs/BUILD.bazel:50:10: Compiling Rust bin test (1 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target //src/snmalloc_rs:test) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_rust+/util/process_wrapper/process_wrapper --arg-file ... (remaining 43 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: linking with `external/toolchains_llvm++llvm+llvm_toolchain/bin/cc_wrapper.sh` failed: exit status: 1
|
= note: "external/toolchains_llvm++llvm+llvm_toolchain/bin/cc_wrapper.sh" "/var/folders/ry/hs24hcmd6gl5r74pslgpfpmw0000gp/T/rustcgW8usE/symbols.o" "<2 object files omitted>" "/private/var/tmp/_bazel_jaya.kasa/43505f64a2a161116557018c890c6d00/external/rules_rust++rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/lib/rustlib/aarch64-apple-darwin/lib/{libtest-f8a21e2032cfe53d.rlib,libgetopts-46d833e8dc44400b.rlib,libunicode_width-7b0508d2e7802a56.rlib,librustc_std_workspace_std-9977f585145720ab.rlib}.rlib" "/private/var/tmp/_bazel_jaya.kasa/43505f64a2a161116557018c890c6d00/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/src/snmalloc_rs/{libsnmalloc_sys-1030967836.rlib}.rlib" "/private/var/tmp/_bazel_jaya.kasa/43505f64a2a161116557018c890c6d00/external/rules_rust++rust+rust_macos_aarch64__aarch64-apple-darwin__stable_tools/lib/rustlib/aarch64-apple-darwin/lib/{libstd-b14eaf39f161baba.rlib,libpanic_unwind-e9afca0624de13f2.rlib,libobject-f4f25c763c07e1da.rlib,libmemchr-f5821a4757eb4967.rlib,libaddr2line-e2075fd42f8fdfe6.rlib,libgimli-08932eb7054dd262.rlib,librustc_demangle-ed8c67e97825d1a5.rlib,libstd_detect-1047965a55c74dd5.rlib,libhashbrown-a128e33792b49d56.rlib,librustc_std_workspace_alloc-9d142a7fc6a557ed.rlib,libminiz_oxide-b5c8cae15aefe652.rlib,libadler2-458be00c7580c8fb.rlib,libunwind-ebf825f8faf836bb.rlib,libcfg_if-c920e7cfad4eac40.rlib,liblibc-b046c3bdd2263ebf.rlib,liballoc-4320d4958ec5f4d4.rlib,librustc_std_workspace_core-8e246dbdcfd33251.rlib,libcore-c8c2fe5a80a1416e.rlib,libcompiler_builtins-78f29445e315e03f.rlib}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-L" "<sysroot>/lib/rustlib/aarch64-apple-darwin/lib" "-L" "/private/var/tmp/_bazel_jaya.kasa/43505f64a2a161116557018c890c6d00/sandbox/darwin-sandbox/374/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/snmalloc-rust-support/lib" "-o" "bazel-out/darwin_arm64-fastbuild/bin/src/snmalloc_rs/test-1577428010/test" "-Wl,-dead_strip" "-nodefaultlibs" "-mmacosx-version-min=10.15" "-no-canonical-prefixes" "-fobjc-link-runtime" "--target=aarch64-apple-macosx" "-no-canonical-prefixes" "-lm" "-headerpad_max_install_names" "-fobjc-link-runtime" "-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/lib" "-lc++" "-lc++abi" "-Bdynamic" "-Lexternal/toolchains_llvm++llvm+llvm_toolchain_llvm/lib" "-Bstatic" "-lunwind" "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: ld: warning: ignoring duplicate libraries: '-lm'
Undefined symbols for architecture arm64:
"_sn_rust_alloc", referenced from:
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_allocated_memory::h1933c082abf06472 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_reallocated_memory::h9495df8ff213e04a in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_reallocated_memory::h9495df8ff213e04a in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
...
"_sn_rust_alloc_zeroed", referenced from:
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_zero_allocated_memory::hfdb968388a086853 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
"_sn_rust_dealloc", referenced from:
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_allocated_memory::h1933c082abf06472 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_zero_allocated_memory::hfdb968388a086853 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
...
"_sn_rust_realloc", referenced from:
snmalloc_rs::tests::allocation_lifecycle::h08be184ba6ccf236 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
snmalloc_rs::tests::it_frees_reallocated_memory::h9495df8ff213e04a in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
"_sn_rust_statistics", referenced from:
snmalloc_rs::SnMallocInfo::statistics::h41fd9476994452f6 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
"_sn_rust_usable_size", referenced from:
snmalloc_rs::tests::test_usable_size::h759325fea3f7a8a9 in snmalloc_rs.snmalloc_rs.8d38e725a4586c18-cgu.0.rcgu.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hi @jayakasadev,
I am not sure how to help unblock this PR, as I don't understand Bazel tooling. It looks like you are building the same component multiple times, and the linker is complaining.
FYI, I refactored the Bazel CI to be its own actions. (#776, #779) This makes it easier to see where the issue is coming from.