-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constraints for ABI #38
Comments
Some old but related doc on the topic of more constraint settings: docs.google.com/document/d/1CgU-GKocMAfsUSI3bbGZ0YRkOWczitIoKs29x3zR914/edit#heading=h.3fbh1otqm5sz |
ARM ABIs are really complicated... I'm not sure how to fit all of this into constraints. I'm sure representing all of this complexity is a bad idea, but I don't have much input into where to draw the line. I've been pretty happy defining my own constraint_setting that just enumerates my hardware platforms. The only place I find standard constraints helpful is using other people's BUILD files, which only needs granularity to the extent those BUILD files do different things. Most of this information is only needed by the toolchain itself, but I have seen different assembly files to choose between which do need more of this to work for any platform. Some platforms I've targeted with Bazel which I think are common:
Some less common platforms I've targeted with Bazel:
Some notes on aarch32 (ARMv6/ARMv7, or ARMv8 in 32-bit mode) variants I've dealt with:
|
In hopes of moving the conversation along I've opened #39 to provide a concrete example of what I'm hoping for. |
IMO, there is no winning in trying to precisely define ARM platforms in this repository. Virtually every device is its own platform, since there can be so much customization of what is on the die. |
For what it's worth, the only 3 values I'm really hoping to represent are |
I would rather go small first, with very precise definitions of what each constant means. How is musl as an API different from gnu? Aren't we getting at features of the library, rather than the binary interface? Unless we are talking about different musls. Also, by being strict about calling conventions, I am excluding anything like linker format, and features of the standard library. Those should be an orthogonal space. It's not clear from the issue description if the need is to cover all of those topics or just the ABI. @UebelAndre, it would help to see examples of what the rust teams are actually trying to do. Can you point to any of the platform definitions they are building? Or, maybe some definitive docs on rust/c++ interoperability. |
I agree with these goals. I would like to add "no names that are prone to assuming an incorrect meaning" and "obvious nesting or mutual exclusion between all categories". For example the current decision between I've got tons of specific things to bring up in the interest of avoiding something which confuses people thinking about just one of them. Also it'd be good to avoid precluding clean solutions to the rest of it in the future, but that might be hard.
Actually, coming from managing many C/C++ toolchains, The itanium C++ ABI defines how C++ is implemented on top of common ELF ABIs. The name is because it was first defined for Itanium, but it's since become the de facto standard on all the common platforms (aarch32, aarch64, x86, amd64 are the ones I work with). But C++ ABI compatibility is also affected by (and this is just on Linux with libstdc++/libc++, Microsoft basically just breaks compatibility periodically instead):
Separate from the mess of C++, there's also things like:
They do fit under "separately compiled modules need to handle them in compatible ways", but I don't think it's manageable in a centralized list like this... I think managing any of this with bazel platforms is a low priority.
Things like the interface to the dynamic linker and the implementation of
I believe the goal is to enable a platform to select a unique target from all the ones Rust supports at https://doc.rust-lang.org/nightly/rustc/platform-support.html, so that rules_rust can generate toolchains for all of them and get the correct one picked based on the platform. |
@aiuto I've created bazelbuild/rules_rust#1270 |
@aiuto I've opened bazelbuild/rules_docker#2062 to also show how other rules may benefit from a common set of definitions. A change like that would allow the Does this and #38 (comment) provide more helpful context? |
@aiuto @gregestren friendly ping 😅 |
Ping noted. Will try to respond soon (maybe next chance @aiuto and I get to talk). |
I've schedule this with my next chat with @aiuto - we at least owe a proper response / next step for this issue. We're both OOO the next two weeks but we'll sync mid-July. |
Any update on this? I don't want to push too much but thought I would ask given the "mid-July" estimate. |
Fair comment. Apologies for delays. Scheduling again for next week, and I'll make sure we discuss. |
My summary of the above:
I don't want to say more yet since the relationship between ABI and OS and platform is subtle as clearly expressed above. Still on agenda for wider discussion this week. |
Another tricky scenario to consider, courtesy of a @coffinmatician:
(I suspect that in practice rustc can use All 3 of these toolchains can be fully ABI-compatible. Some processors can run code from any of them, other processors can only run code from 1 and 3. I don't think Bazel's current constraint system allows a good solution: if you build for a platform that requires soft-ABI-hard-instructions then there's no compatible Rust toolchain, but if you use soft-ABI-soft-instructions then you end up with a non-optimal C++ toolchain. @coffinmatician thinks constraints should have a full SAT constraint optimizer to address this. |
I did some more thinking, and I have a proposal: put the list of Rust triples in a For example, a project that creates Clang toolchains would have its own constraint_setting, and another project that does GCC toolchains would have its own, and a third project for bare-metal GCC and Clang toolchains would a separate one. I don't think any other solution is going to solve the problem cleanly. Even if Also building C++ code with Clang sometimes uses subtly different triples, and GCC often uses different triples. Debian (and derivatives) also use different triples for multiarch ( I think |
I'm running bazel on alpine linux (so on musl), meaning basically any pre-built 0: https://git.sr.ht/~graywolf/x_platforms/tree/master/item/abi/BUILD |
I don't think I understand why this would be acceptable. I think |
We discussed this week. @aiuto has more input. |
We're setting up C/C++ toolchains within our company and hitting the same issue. We hermetically download a compiler, binutils and sysroot. That combination needs to be described via constraints so toolchain selection can occur correctly. Rather than ABI (which can be affected by many things), we were just thinking more around the
It's important to know the version because they are often forwards but not backwards compatible. It likely makes sense to have the non-versioned contraints also and that a The other thing to know is the version of the system headers because deploying the binary can mean the So something like:
|
@mattyclarkson do the constraints need to be in the I don't think having a separate constraint for each Linux version is a great idea because it would (in principle) make Bazel version incompatible with any Linux version released after it, but if you control your own platform and constraint definitions, you know which exact versions of Linux / libc / etc. you care about. |
Would it be possible to introduce
@platforms//abi
which contains constraints for common ABI definitions of platform triples?In
rules_rust
we currently have issues with users wanting to target platforms with shared CPU and system and unique ABI but are unable to do so as there's no constraints uniquely identifying them. Users are forced to define custom constraints and redefine toolchains to get around errors caused by this ambiguity. I think it would be very beneficial to introduce ABI constraints here so thatrules_rust
and other rules can share constraints, enabling rule maintainers to appropriately constrain toolchains so users only have to setup platform definitions.The text was updated successfully, but these errors were encountered: