#intrinsics #built-in #snapshot #compiler

nightly compiler-builtins-snapshot

编译器内置库的快照

3 个不稳定版本

使用旧的 Rust 2015

0.1.20170127+764557f0b669…2017年1月26日
0.1.20170126+764557f0b669… 2017年1月26日
0.0.20161008+c56faf22abb3…2016年10月8日
0.0.20161004+954e3b70959b…2016年10月3日
0.0.20161003+954e3b70959b… 2016年10月3日

#478编程语言

36 每月下载次数

MIT/Apache

3MB
65K SLoC

C++ 38K SLoC // 0.1% comments Bitbake 11K SLoC // 0.1% comments C 8K SLoC // 0.3% comments GNU Style Assembly 3K SLoC // 0.4% comments Python 2.5K SLoC // 0.4% comments Rust 2K SLoC // 0.1% comments Shell 457 SLoC // 0.1% comments Forge Config 14 SLoC // 0.4% comments Batch 2 SLoC

compiler-builtins

Build status Build Status

[WIP] 将 compiler-rt 内置函数移植到 Rust

请参阅 rust-lang/rust#35437.

何时以及如何使用此库?

如果你正在使用 rustup 无法通过二进制形式安装 std 的目标(这通常意味着你正在自己构建核心库)并且需要 compiler-rt 内置函数(即,当你构建可执行文件时可能遇到链接器错误:undefined reference to __aeabi_memcpy),你可以使用此库来获取这些内置函数并解决链接器错误。为此,将此库添加到正在构建的库的依赖图中

# Cargo.toml
[dependencies]
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" }
extern crate compiler_builtins;

// ...

如果在更改之后仍然遇到 "undefined reference to $INTRINSIC" 错误,这意味着我们还没有将 $INTRINSIC 移植到 Rust!请就内置函数的名称和目标使用的 LLVM 三元组(例如 thumbv7m-none-eabi)打开 一个问题。这样我们就可以优先移植那个特定的内置函数。

如果你为目标提供了 C 编译器,那么在我们实现此内置函数的同时,你可以暂时启用回退到实际的 compiler-rt 实现以及未实现的内置函数

[dependencies.compiler_builtins]
git = "https://github.com/rust-lang-nursery/compiler-builtins"
features = ["c"]

贡献

  1. 从 [待办列表][#progress] 中选择一个或多个内置函数。
  2. 在此存储库上进行分支
  3. 将内置函数及其对应的 单元测试 从其 C 实现中 移植到 Rust。
  4. 发送拉取请求 (PR)
  5. 一旦 PR 通过我们广泛的 测试基础设施,我们就会合并它!
  6. 庆祝 🎉

移植注意事项

  1. Rust相比,C的运算符优先级略有不同。C在位运算(& | ^)之前评估比较运算(== !=),而Rust则相反。
  2. C假设所有操作都是封包操作。在调试模式下,Rust在溢出时会产生恐慌。考虑使用Wrapping类型或显式的wrapping_*函数。
  3. 注意C隐式转换,特别是整数提升。Rust在类型转换方面更为明确,因此请确保任何影响输出的转换都被移植到Rust实现中。
  4. Rust标准库中有许多用于整数或浮点数操作的函数考虑使用这些函数之一,而不是移植新的函数。

进度

  • adddf3.c
  • addsf3.c
  • arm/adddf3vfp.S
  • arm/addsf3vfp.S
  • arm/aeabi_dcmp.S
  • arm/aeabi_fcmp.S
  • arm/aeabi_idivmod.S
  • arm/aeabi_ldivmod.S
  • arm/aeabi_memcpy.S
  • arm/aeabi_memmove.S
  • arm/aeabi_memset.S
  • arm/aeabi_uidivmod.S
  • arm/aeabi_uldivmod.S
  • arm/divdf3vfp.S
  • arm/divmodsi4.S (通用版本已完成)
  • arm/divsf3vfp.S
  • arm/divsi3.S (通用版本已完成)
  • arm/eqdf2vfp.S
  • arm/eqsf2vfp.S
  • arm/extendsfdf2vfp.S
  • arm/fixdfsivfp.S
  • arm/fixsfsivfp.S
  • arm/fixunsdfsivfp.S
  • arm/fixunssfsivfp.S
  • arm/floatsidfvfp.S
  • arm/floatsisfvfp.S
  • arm/floatunssidfvfp.S
  • arm/floatunssisfvfp.S
  • arm/gedf2vfp.S
  • arm/gesf2vfp.S
  • arm/gtdf2vfp.S
  • arm/gtsf2vfp.S
  • arm/ledf2vfp.S
  • arm/lesf2vfp.S
  • arm/ltdf2vfp.S
  • arm/ltsf2vfp.S
  • arm/modsi3.S (通用版本已完成)
  • arm/muldf3vfp.S
  • arm/mulsf3vfp.S
  • arm/nedf2vfp.S
  • arm/negdf2vfp.S
  • arm/negsf2vfp.S
  • arm/nesf2vfp.S
  • arm/softfloat-alias.list
  • arm/subdf3vfp.S
  • arm/subsf3vfp.S
  • arm/truncdfsf2vfp.S
  • arm/udivmodsi4.S (通用版本已完成)
  • arm/udivsi3.S (通用版本已完成)
  • arm/umodsi3.S (通用版本已完成)
  • arm/unorddf2vfp.S
  • arm/unordsf2vfp.S
  • ashldi3.c
  • ashrdi3.c
  • divdf3.c
  • divdi3.c
  • divmoddi4.c
  • divmodsi4.c
  • divsf3.c
  • divsi3.c
  • extendhfsf2.c
  • extendsfdf2.c
  • fixdfdi.c
  • fixdfsi.c
  • fixsfdi.c
  • fixsfsi.c
  • fixunsdfdi.c
  • fixunsdfsi.c
  • fixunssfdi.c
  • fixunssfsi.c
  • floatdidf.c
  • floatdisf.c
  • floatsidf.c
  • floatsisf.c
  • floatundidf.c
  • floatundisf.c
  • floatunsidf.c
  • floatunsisf.c
  • i386/ashldi3.S
  • i386/ashrdi3.S
  • i386/chkstk.S
  • i386/chkstk2.S
  • i386/divdi3.S
  • i386/lshrdi3.S
  • i386/moddi3.S
  • i386/muldi3.S
  • i386/udivdi3.S
  • i386/umoddi3.S
  • lshrdi3.c
  • moddi3.c
  • modsi3.c
  • muldf3.c
  • muldi3.c
  • mulodi4.c
  • mulosi4.c
  • mulsf3.c
  • powidf2.c
  • powisf2.c
  • subdf3.c
  • subsf3.c
  • truncdfhf2.c
  • truncdfsf2.c
  • truncsfhf2.c
  • udivdi3.c
  • udivmoddi4.c
  • udivmodsi4.c
  • udivsi3.c
  • umoddi3.c
  • umodsi3.c
  • x86_64/chkstk.S
  • x86_64/chkstk2.S

这些内置函数用于支持正在Rust中添加的128位整数。

  • ashlti3.c
  • ashrti3.c
  • divti3.c
  • fixdfti.c
  • fixsfti.c
  • fixunsdfti.c
  • fixunssfti.c
  • floattidf.c
  • floattisf.c
  • floatuntidf.c
  • floatuntisf.c
  • lshrti3.c
  • modti3.c
  • muloti4.c
  • multi3.c
  • udivmodti4.c
  • udivti3.c
  • umodti3.c

未实现的功能

这些内置函数涉及浮点类型("f128", "f80" 和复数)这些类型在 Rust 中不受支持。

  • addtf3.c
  • comparetf2.c
  • divdc3.c
  • divsc3.c
  • divtc3.c
  • divtf3.c
  • divxc3.c
  • extenddftf2.c
  • extendsftf2.c
  • fixtfdi.c
  • fixtfsi.c
  • fixtfti.c
  • fixunstfdi.c
  • fixunstfsi.c
  • fixunstfti.c
  • fixunsxfdi.c
  • fixunsxfsi.c
  • fixunsxfti.c
  • fixxfdi.c
  • fixxfti.c
  • floatditf.c
  • floatdixf.c
  • floatsitf.c
  • floattixf.c
  • floatunditf.c
  • floatundixf.c
  • floatunsitf.c
  • floatuntixf.c
  • i386/floatdixf.S
  • i386/floatundixf.S
  • muldc3.c
  • mulsc3.c
  • multc3.c
  • multf3.c
  • mulxc3.c
  • powitf2.c
  • powixf2.c
  • ppc/divtc3.c
  • ppc/fixtfdi.c
  • ppc/fixunstfdi.c
  • ppc/floatditf.c
  • ppc/floatunditf.c
  • ppc/gcc_qadd.c
  • ppc/gcc_qdiv.c
  • ppc/gcc_qmul.c
  • ppc/gcc_qsub.c
  • ppc/multc3.c
  • subtf3.c
  • trunctfdf2.c
  • trunctfsf2.c
  • x86_64/floatdixf.c
  • x86_64/floatundixf.S

这些内置函数从未被 LLVM 调用。

  • absvdi2.c
  • absvsi2.c
  • absvti2.c
  • addvdi3.c
  • addvsi3.c
  • addvti3.c
  • arm/aeabi_cdcmp.S
  • arm/aeabi_cdcmpeq_check_nan.c
  • arm/aeabi_cfcmp.S
  • arm/aeabi_cfcmpeq_check_nan.c
  • arm/aeabi_div0.c
  • arm/aeabi_drsub.c
  • arm/aeabi_frsub.c
  • arm/aeabi_memcmp.S
  • arm/bswapdi2.S
  • arm/bswapsi2.S
  • arm/clzdi2.S
  • arm/clzsi2.S
  • arm/comparesf2.S
  • arm/restore_vfp_d8_d15_regs.S
  • arm/save_vfp_d8_d15_regs.S
  • arm/switch16.S
  • arm/switch32.S
  • arm/switch8.S
  • arm/switchu8.S
  • clzdi2.c
  • clzsi2.c
  • clzti2.c
  • cmpdi2.c
  • cmpti2.c
  • comparedf2.c
  • comparesf2.c
  • ctzdi2.c
  • ctzsi2.c
  • ctzti2.c
  • ffsdi2.c
  • ffsti2.c
  • mulvdi3.c
  • mulvsi3.c
  • mulvti3.c
  • negdf2.c
  • negdi2.c
  • negsf2.c
  • negti2.c
  • negvdi2.c
  • negvsi2.c
  • negvti2.c
  • paritydi2.c
  • paritysi2.c
  • parityti2.c
  • popcountdi2.c
  • popcountsi2.c
  • popcountti2.c
  • ppc/restFP.S
  • ppc/saveFP.S
  • subvdi3.c
  • subvsi3.c
  • subvti3.c
  • ucmpdi2.c
  • ucmpti2.c
  • udivmodti4.c

Rust 只在支持它们的平台上公开原子类型,因此不需要回退到软件实现。

  • arm/sync_fetch_and_add_4.S
  • arm/sync_fetch_and_add_8.S
  • arm/sync_fetch_and_and_4.S
  • arm/sync_fetch_and_and_8.S
  • arm/sync_fetch_and_max_4.S
  • arm/sync_fetch_and_max_8.S
  • arm/sync_fetch_and_min_4.S
  • arm/sync_fetch_and_min_8.S
  • arm/sync_fetch_and_nand_4.S
  • arm/sync_fetch_and_nand_8.S
  • arm/sync_fetch_and_or_4.S
  • arm/sync_fetch_and_or_8.S
  • arm/sync_fetch_and_sub_4.S
  • arm/sync_fetch_and_sub_8.S
  • arm/sync_fetch_and_umax_4.S
  • arm/sync_fetch_and_umax_8.S
  • arm/sync_fetch_and_umin_4.S
  • arm/sync_fetch_and_umin_8.S
  • arm/sync_fetch_and_xor_4.S
  • arm/sync_fetch_and_xor_8.S
  • arm/sync_synchronize.S
  • atomic.c
  • atomic_flag_clear.c
  • atomic_flag_clear_explicit.c
  • atomic_flag_test_and_set.c
  • atomic_flag_test_and_set_explicit.c
  • atomic_signal_fence.c
  • atomic_thread_fence.c

未使用 Rust 的杂项功能。

  • apple_versioning.c
  • clear_cache.c
  • emutls.c
  • enable_execute_stack.c
  • eprintf.c
  • gcc_personality_v0.c
  • trampoline_setup.c

仅从软浮点代码调用的内置函数的浮点实现。在这种情况下,最好简单地使用通用的软浮点版本。

  • i386/floatdidf.S
  • i386/floatdisf.S
  • i386/floatundidf.S
  • i386/floatundisf.S
  • x86_64/floatundidf.S
  • x86_64/floatundisf.S
  • x86_64/floatdidf.c
  • x86_64/floatdisf.c

许可证

编译器内置功能crate同时受伊利诺伊大学“类似BSD”许可证和MIT许可证的双重许可。作为本代码的用户,您可以选择在任一许可证下使用它。作为贡献者,您同意允许您的代码在任一许可证下使用。

相关许可证的全文在LICENSE.TXT中。

无运行时依赖。