Comments (1)
This won't work on msvc because there is no libgcc_s.so there. Instead we can link to msvcrt.lib, which contains the intrinsics we want to test against. However, the intrinsics in msvcrt.lib are named differently from the ones in gcc_s/compiler-rt. This is good because we can statically link against that library without worrying about name collisions but it's also annoying because we must now translate from msvcrt naming to compiler-rt naming.
@retep998 has provided us with a list of the intrinsics available in msvcrt.lib. But we still need to translate the names from msvcrt to compiler-rt. That can be done by looking into llvm source code. For example there are code sections like:
// lib/Target/X86/X86ISelLowering.cpp
if (Subtarget.isTargetKnownWindowsMSVC()) {
// Setup Windows compiler runtime calls.
setLibcallName(RTLIB::SDIV_I64, "_alldiv");
setLibcallName(RTLIB::UDIV_I64, "_aulldiv");
setLibcallName(RTLIB::SREM_I64, "_allrem");
setLibcallName(RTLIB::UREM_I64, "_aullrem");
setLibcallName(RTLIB::MUL_I64, "_allmul");
setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::X86_StdCall);
}
that contain the msvcrt names. And other sections like this one:
// lib/Target/ARM/ARMISelLowering.cpp
} LibraryCalls[] = {
// ...
// Integer division functions
// RTABI chapter 4.3.1
{ RTLIB::SDIV_I8, "__aeabi_idiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::SDIV_I16, "__aeabi_idiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::SDIV_I32, "__aeabi_idiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::SDIV_I64, "__aeabi_ldivmod", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::UDIV_I8, "__aeabi_uidiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::UDIV_I16, "__aeabi_uidiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::UDIV_I32, "__aeabi_uidiv", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
{ RTLIB::UDIV_I64, "__aeabi_uldivmod", CallingConv::ARM_AAPCS, ISD::SETCC_INVALID },
};
that contain the compiler-rt names. Using that information you can conclude that RTLIB::UDIV_I64
=== __aeabi_uldivmod
=== _allmul
.
With that background information, here are the next steps:
- Create a
msvcrt
crate that links to msvcrt.lib and binds to the msvcrt intrinsics. That crate must expose the same API as thegcc_s
crate. Basically, it must provide functions like__muldi3: fn() -> Option<extern unsafe fn(u64, u64) -> u64>
. The crate must handle the differences in naming and signature of intrinsics between msvcrt and compiler-rt. - Then, probably, we only need to add a
#[cfg(target_env = "msvc")] extern crate msvcrt as gcc_s
to the root of the rustc-builtins crate (for tests only).
from compiler-builtins.
Related Issues (20)
- `__extenddftf2` is found to be missing at runtime when using the WASI SDK to build Rust crates' C code HOT 2
- Getting C-defined intrinsics into a project that uses the stable compiler doesn't work because of all the `#![feature]` checks HOT 2
- Unable to find long double symbols on `aarch64-apple-darwin` HOT 4
- Adding feature to port `libm` for any target HOT 3
- Unable to use static macOS libraries in Unreal Engine projects HOT 2
- Regression: build failure on i686-pc-windows-gnu due to multiple definition of `_alloca` HOT 15
- Undefined reference to __chkstk, __alloca when building target i686-unknown-uefi
- aarch64 windows build failure HOT 1
- `aarch64-linux` `multf3` symbol has incorrect rounding HOT 1
- Unable to `-Zbuild-std` because std depends on `compiler-builtins` without the `no-f16-f128` features HOT 5
- Rounding error in `__mulsf3` HOT 6
- Inconsistent truncation of -0.0 HOT 6
- powerpc64le truncation failure HOT 1
- Errors building latest version on arm-android HOT 7
- Infinite recursion in sqrt HOT 4
- "was built for iOS 16.4" warning HOT 4
- Infinite recursion in `__extendhfsf2` and `__truncsfhf2` on "no-f16-f128" platforms HOT 6
- Various symbols on win/apple are no longer weak after #598 HOT 13
- Presence of `f16` in signatures causes missing symbols on PPC HOT 2
- Optimizing Compiler builtins causes build failure on VxWorks HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler-builtins.