-
Notifications
You must be signed in to change notification settings - Fork 456
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
map system from "darwin" to "macos" when parsing triple #3296
base: main
Are you sure you want to change the base?
map system from "darwin" to "macos" when parsing triple #3296
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Curious though, why not make the change to update the triple
function to map darwin
to macos
?
rules_rust/rust/platform/triple.bzl
Lines 48 to 63 in 14f3829
cpu_arch = component_parts[0] | |
vendor = component_parts[1] | |
system = component_parts[2] | |
abi = None | |
if cpu_arch.startswith(("thumbv8m", "thumbv7m", "thumbv7e", "thumbv6m")): | |
abi = system | |
system = vendor | |
vendor = None | |
if system == "androideabi": | |
system = "android" | |
abi = "eabi" | |
if len(component_parts) == 4: | |
abi = component_parts[3] |
It seems like rustc also expects the name to be "macos" which I determine from the json dump from the command below where you can see "os": "macos",
rustc +nightly --print target-spec-json -Z unstable-options
rustc +nightly --print target-spec-json -Z unstable-options
{
"abi-return-struct-as-int": true,
"arch": "aarch64",
"archive-format": "darwin",
"cpu": "apple-m1",
"crt-objects-fallback": "false",
"data-layout": "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32",
"debuginfo-kind": "dwarf-dsym",
"dll-suffix": ".dylib",
"dynamic-linking": true,
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"frame-pointer": "non-leaf",
"function-sections": false,
"has-rpath": true,
"has-thread-local": true,
"is-like-osx": true,
"link-env": [
"ZERO_AR_DATE=1"
],
"link-env-remove": [
"IPHONEOS_DEPLOYMENT_TARGET",
"TVOS_DEPLOYMENT_TARGET",
"XROS_DEPLOYMENT_TARGET"
],
"linker-flavor": "darwin-cc",
"linker-is-gnu": false,
"lld-flavor": "darwin",
"llvm-floatabi": "hard",
"llvm-target": "arm64-apple-macosx",
"max-atomic-width": 128,
"metadata": {
"description": "ARM64 Apple macOS (11.0+, Big Sur+)",
"host_tools": true,
"std": true,
"tier": 1
},
"os": "macos",
"split-debuginfo": "packed",
"stack-probes": {
"kind": "inline"
},
"supported-sanitizers": [
"address",
"thread",
"cfi"
],
"supported-split-debuginfo": [
"packed",
"unpacked",
"off"
],
"target-family": [
"unix"
],
"target-mcount": "\u0001mcount",
"target-pointer-width": "64",
"vendor": "apple"
}
But there definitely isn't a triple with "macos"
rustc +nightly --print target-list -Z unstable-options | grep macos
prints nothing
rustc +nightly --print target-list -Z unstable-options | grep darwin
aarch64-apple-darwin
arm64e-apple-darwin
i686-apple-darwin
x86_64-apple-darwin
x86_64h-apple-darwin
d13a045
to
fc2de05
Compare
@christianscott be advised, there may be places in code that only account for "darwin" you might wanna look at all uses of |
Will do! |
Fixing the CI failure (no bzlmod on macos aarch64). I can repro locally. Error message
|
I think this is complaining about these not being updated rules_rust/rust/repositories.bzl Lines 42 to 51 in 14f3829
|
The build has passed 🎉 I've updated the description as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christianscott responded to all the comments!
3e591e7
to
eecccda
Compare
@@ -46,17 +46,17 @@ def declare_config_settings(): | |||
constraint_values = system_to_constraints(system), | |||
) | |||
|
|||
# Add alias for OSX to "darwin" to match what users will be expecting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be best to add an additional alias.
Co-authored-by: UebelAndre <github@uebelandre.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sick! Thank you!
@christianscott looks like you gotta run buildifier! |
Oops 🙈 pushed a fix |
Map
darwin
tomacos
when parsing target triples to align with Rust’s internal naming conventionRust’s target triple format and internal OS naming conventions use different terms for macOS:
• The target triple follows LLVM conventions and uses
-darwin
, e.g.,aarch64-apple-darwin
.• Rust itself uses
macos
for OS-based conditionals, e.g.,#[cfg(target_os = "macos")]
.This mismatch originates from upstream toolchains— LLVM and GCC have historically used darwin in triples to denote macOS. Meanwhile, Rust internally adopted macos before 1.0, as discussed in this early thread: Rust Internals Discussion.
Fixes: bazelbuild/rules_rust#3291