Target WIP: hexagon-unknown-linux-musl

We already have Hexagon DSP codegen support in rustc. But I'd like to extend it to support a linux target.

I have a PR that's queued up that will get the ball rolling. But I'm having trouble navigating the cyclical dependency among libstd and libc.

Here's what I've done to try and get the new target build working locally.

  1. I did the rustup toolchain link clever trick to get my initial rustc target into the basis toolchain.
  2. patched my local libc crate with the necessary hexagon-unknown-linux-musl changes.
  3. bumped the libc version in my local liblibc/Cargo.toml to 0.2.61
  4. patched the workspace Cargo.toml with libc = { path = 'src/liblibc' }
  5. patched the src/libstd/Cargo.toml libc dependency to reference version 0.2.61

It looks to me like these steps so far have been effective at getting further in the libstd build progress. But from what I can tell I'm getting failures when building some of libstd's depencies for hexagon-unknown-linux-musl. In particular I think one of its dependencies depends on libc 0.2.54 and I've tried a couple of things to convince the build process to use my local libc with hexagon-linux support but not had luck with that yet.

If I knew which crate depended on that libc version I suppose I could add a local patch of that crate to my workspace and require it to use my 0.2.61 libc.

Originally I added the rustc PR referenced above with the hopes that it would magically break this cycle but I suppose it's just moving the problem to the build/staging environment.

I'll keep trying other ideas but if there's a recommended process for this part I am eager to hear it.

Relevant build log: https://gist.github.com/androm3da/03dccedef5d09088274386105c1a51f7#file-build_stage_1-log

FWIW this dependency isn't cyclic. If you have a target-specification file (as json) or in librustc_target you can build libc without a libstd dependency - it only requires libcore.

Once libc builds for your target, you can try to use it to build libstd, and iterate until it is as complete as libstd requires.

Once that is done, you can just push your changes to libc upstream. If you don't have a librustc_target yet, you can also push your .json target specification there to make sure that your target builds on CI.

When pushing the libstd required changes for your target to rust-lang/rust, you should just be able to use a released version of libc.

Once libc builds for your target, you can try to use it to build libstd, and iterate until it is as complete as libstd requires.

This is the bit I seem to struggle with -- driving this operation with solely x.py seems to not be the way. I will try to build libc for my target without x.py I guess.

Once that is done, you can just push your changes to libc upstream.

Thanks, I will give it a try. The PR I referenced for adding my target to librustc_target is now merged. I suspect there might be some more settings/operational details to make sure that new target is present/enabled for nightlies, though?

Ah yeah, so that is always a pain. What you are doing with #[patch] at the workspace level should work. If there is some other dependency that has a hardcoded libc version that doesn't bump to yours, please report that dependency.

I think you can also use:

#[replace]
"libc:0.2.54" = { path = '/src/your/libc' }

to try to work around that.

Also note that currently rustc does not build with libc 0.2.60 and that there is a PR open (https://github.com/rust-lang/rust/pull/61393) that fixes that, so you might want to start from that PR if you plan to target libc >= 0.2.60.

I did have to apply a local patch because of a warning or error regarding ::libc::uint32_t but it was trivial. I'll look at the PR in case there's more to it than that.

Thanks for the heads up.

I didn't know about #[replace] thanks I will try it!

Okay it feels like I'm making progress @gnzlbg

I'm trying to build libcore and it fails for lack of some language items. The data_layout for hexagon-unknown-linux-musl doesn't mention any i128 and I wonder if that's part of the problem. There's no native 128-bit registers so I think either I need to find a better way to disable this feature for rust or punt to a software implementation of 128-bit logic.

There's some mips targets (among others probably) that don't have i128 in their data_layout but I suppose since Hexagon has a coprocessor that supports larger-than-128 bit registers, that might be a factor here.

Failure while building libcore:

./x.py build --stage 1 -vvvv --config ../hexagon-linux-83.toml src/libcore
running: /local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /local/mnt/workspace/rust/rust/src/bootstrap/Cargo.toml --verbose --verbose --verbose
       Fresh unicode-xid v0.1.0
...
rustc command: "LD_LIBRARY_PATH"="/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib:/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps:/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib" "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "--crate-name" "compiler_builtins" "/usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/lib.rs" "--color" "never" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=2" "--cfg" "feature=\"c\"" "--cfg" "feature=\"cc\"" "--cfg" "feature=\"compiler-builtins\"" "--cfg" "feature=\"core\"" "--cfg" "feature=\"default\"" "--cfg" "feature=\"rustc-dep-of-std\"" "-C" "metadata=bd952819c66fd8ff-rustc" "-C" "extra-filename=-bd952819c66fd8ff" "--out-dir" "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps" "--target" "x86_64-unknown-linux-gnu" "-L" "dependency=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps" "--extern" "core=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_std_workspace_core-325a092e1d4cc28f.rlib" "--cap-lints" "warn" "-L" "native=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/build/compiler_builtins-4552e39eff386d49/out" "--cfg" "__absvdi2=\"optimized-c\"" "--cfg" "__absvsi2=\"optimized-c\"" "--cfg" "__absvti2=\"optimized-c\"" "--cfg" "__addvdi3=\"optimized-c\"" "--cfg" "__addvsi3=\"optimized-c\"" "--cfg" "__addvti3=\"optimized-c\"" "--cfg" "__clzdi2=\"optimized-c\"" "--cfg" "__clzsi2=\"optimized-c\"" "--cfg" "__clzti2=\"optimized-c\"" "--cfg" "__cmpdi2=\"optimized-c\"" "--cfg" "__cmpti2=\"optimized-c\"" "--cfg" "__ctzdi2=\"optimized-c\"" "--cfg" "__ctzsi2=\"optimized-c\"" "--cfg" "__ctzti2=\"optimized-c\"" "--cfg" "__divdc3=\"optimized-c\"" "--cfg" "__divsc3=\"optimized-c\"" "--cfg" "__divxc3=\"optimized-c\"" "--cfg" "__extendhfsf2=\"optimized-c\"" "--cfg" "__ffsti2=\"optimized-c\"" "--cfg" "__floatdisf=\"optimized-c\"" "--cfg" "__floatdixf=\"optimized-c\"" "--cfg" "__floatundidf=\"optimized-c\"" "--cfg" "__floatundisf=\"optimized-c\"" "--cfg" "__floatundixf=\"optimized-c\"" "--cfg" "__int_util=\"optimized-c\"" "--cfg" "__muldc3=\"optimized-c\"" "--cfg" "__mulsc3=\"optimized-c\"" "--cfg" "__mulvdi3=\"optimized-c\"" "--cfg" "__mulvsi3=\"optimized-c\"" "--cfg" "__mulvti3=\"optimized-c\"" "--cfg" "__mulxc3=\"optimized-c\"" "--cfg" "__negdf2=\"optimized-c\"" "--cfg" "__negdi2=\"optimized-c\"" "--cfg" "__negsf2=\"optimized-c\"" "--cfg" "__negti2=\"optimized-c\"" "--cfg" "__negvdi2=\"optimized-c\"" "--cfg" "__negvsi2=\"optimized-c\"" "--cfg" "__negvti2=\"optimized-c\"" "--cfg" "__paritydi2=\"optimized-c\"" "--cfg" "__paritysi2=\"optimized-c\"" "--cfg" "__parityti2=\"optimized-c\"" "--cfg" "__popcountdi2=\"optimized-c\"" "--cfg" "__popcountsi2=\"optimized-c\"" "--cfg" "__popcountti2=\"optimized-c\"" "--cfg" "__powixf2=\"optimized-c\"" "--cfg" "__subvdi3=\"optimized-c\"" "--cfg" "__subvsi3=\"optimized-c\"" "--cfg" "__subvti3=\"optimized-c\"" "--cfg" "__truncdfhf2=\"optimized-c\"" "--cfg" "__truncdfsf2=\"optimized-c\"" "--cfg" "__truncsfhf2=\"optimized-c\"" "--cfg" "__ucmpdi2=\"optimized-c\"" "--cfg" "__ucmpti2=\"optimized-c\"" "--cfg" "apple_versioning=\"optimized-c\"" "-l" "static=compiler-rt" "-Cdebuginfo=0" "-Dwarnings" "-Drust_2018_idioms" "--sysroot" "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1" "-Zexternal-macro-backtrace" "-Cprefer-dynamic" "-Clinker=clang++" "-C" "panic=abort" "-C" "debug-assertions=no" "-C" "codegen-units=8" "-Zsave-analysis" "-C" "link-args=-Wl,-rpath,$ORIGIN/../lib" "-Z" "force-unstable-if-unmarked"
sysroot: "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1"
libdir: "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib"
error[E0522]: definition of an unknown language item: `i128_add`
  --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
   |
94 | |     (
   | |_______________________^ definition of unknown language item `i128_add`
...
291|           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
   |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_addo`
  --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
   |
98 | |             $($body:tt)*
   | |________________________^ definition of unknown language item `i128_addo`
...
291|           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
   |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_add`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
104 | |         intrinsics! {
    | |_______________________^ definition of unknown language item `u128_add`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_addo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
108 | |             }
    | |________________________^ definition of unknown language item `u128_addo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_sub`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
115 | |                 $($body)*
    | |_______________________^ definition of unknown language item `i128_sub`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_subo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
119 | |         intrinsics!($($rest)*);
    | |________________________^ definition of unknown language item `i128_subo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_sub`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
125 | |         #[unadjusted_on_win64]
    | |_______________________^ definition of unknown language item `u128_sub`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_subo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
129 | |         }
    | |________________________^ definition of unknown language item `u128_subo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_mul`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
113 | |             $(#[$($attr)*])*
    | |_______________________^ definition of unknown language item `i128_mul`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_mulo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
117 | |         }
    | |________________________^ definition of unknown language item `i128_mulo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_mul`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
123 | |     // win64 for some methods.
    | |_______________________^ definition of unknown language item `u128_mul`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_mulo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
127 | |         pub extern $abi:tt fn $name:ident( $($argname:ident:  $ty:ty),* ) -> $ret:ty {
    | |________________________^ definition of unknown language item `u128_mulo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_div`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
104 | |         intrinsics! {
    | |_______________________^ definition of unknown language item `i128_div`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_rem`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
108 | |             }
    | |_______________________^ definition of unknown language item `i128_rem`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_shl`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
109 | |         }
    | |_______________________^ definition of unknown language item `i128_shl`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_shlo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
113 | |             $(#[$($attr)*])*
    | |________________________^ definition of unknown language item `i128_shlo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_shl`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
117 | |         }
    | |_______________________^ definition of unknown language item `u128_shl`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_shlo`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
121 | |
    | |________________________^ definition of unknown language item `u128_shlo`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_shr`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
126 | |         $(#[$($attr:tt)*])*
    | |_______________________^ definition of unknown language item `i128_shr`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `i128_shro`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
130 | |
    | |________________________^ definition of unknown language item `i128_shro`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_shr`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
134 | |         intrinsics! {
    | |_______________________^ definition of unknown language item `u128_shr`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_shro`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
138 | |             }
    | |________________________^ definition of unknown language item `u128_shro`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_div`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
273 | |         }
    | |_______________________^ definition of unknown language item `u128_div`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error[E0522]: definition of an unknown language item: `u128_rem`
   --> /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/macros.rs:291:65
    |
277 | |         fn from(i: u128) -> U64x2 {
    | |_______________________^ definition of unknown language item `u128_rem`
...
291 |           #[cfg_attr(not(any(stage0, feature = "no-lang-items")), lang = $lang)]
    |  _________________________________________________________________^

error: aborting due to 24 previous errors

For more information about this error, try `rustc --explain E0522`.
error: Could not compile `compiler_builtins`.

Caused by:
  process didn't exit successfully: `CARGO_PKG_VERSION=0.1.17 CARGO=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo CARGO_PKG_HOMEPAGE='https://github.com/rust-lang-nursery/compiler-builtins' CARGO_PKG_AUTHORS='Jorge Aparicio <japaricious@gmail.com>' CARGO_MANIFEST_DIR=/usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17 CARGO_PKG_VERSION_PATCH=17 CARGO_PKG_VERSION_MAJOR=0 LD_LIBRARY_PATH='/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps:/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage0/lib' CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PRE= CARGO_PKG_NAME=compiler_builtins CARGO_PKG_DESCRIPTION='Compiler intrinsics used by the Rust compiler. Also available for other targets
if necessary'\!'
' CARGO_PKG_REPOSITORY='https://github.com/rust-lang-nursery/compiler-builtins' OUT_DIR=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/build/compiler_builtins-4552e39eff386d49/out /local/mnt/workspace/rust/rust/build/bootstrap/debug/rustc --crate-name compiler_builtins /usr2/bcain/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.17/src/lib.rs --color never --error-format json --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 --cfg 'feature="c"' --cfg 'feature="cc"' --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=bd952819c66fd8ff -C extra-filename=-bd952819c66fd8ff --out-dir /local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern core=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_std_workspace_core-325a092e1d4cc28f.rlib --cap-lints warn -L native=/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/build/compiler_builtins-4552e39eff386d49/out --cfg '__absvdi2="optimized-c"' --cfg '__absvsi2="optimized-c"' --cfg '__absvti2="optimized-c"' --cfg '__addvdi3="optimized-c"' --cfg '__addvsi3="optimized-c"' --cfg '__addvti3="optimized-c"' --cfg '__clzdi2="optimized-c"' --cfg '__clzsi2="optimized-c"' --cfg '__clzti2="optimized-c"' --cfg '__cmpdi2="optimized-c"' --cfg '__cmpti2="optimized-c"' --cfg '__ctzdi2="optimized-c"' --cfg '__ctzsi2="optimized-c"' --cfg '__ctzti2="optimized-c"' --cfg '__divdc3="optimized-c"' --cfg '__divsc3="optimized-c"' --cfg '__divxc3="optimized-c"' --cfg '__extendhfsf2="optimized-c"' --cfg '__ffsti2="optimized-c"' --cfg '__floatdisf="optimized-c"' --cfg '__floatdixf="optimized-c"' --cfg '__floatundidf="optimized-c"' --cfg '__floatundisf="optimized-c"' --cfg '__floatundixf="optimized-c"' --cfg '__int_util="optimized-c"' --cfg '__muldc3="optimized-c"' --cfg '__mulsc3="optimized-c"' --cfg '__mulvdi3="optimized-c"' --cfg '__mulvsi3="optimized-c"' --cfg '__mulvti3="optimized-c"' --cfg '__mulxc3="optimized-c"' --cfg '__negdf2="optimized-c"' --cfg '__negdi2="optimized-c"' --cfg '__negsf2="optimized-c"' --cfg '__negti2="optimized-c"' --cfg '__negvdi2="optimized-c"' --cfg '__negvsi2="optimized-c"' --cfg '__negvti2="optimized-c"' --cfg '__paritydi2="optimized-c"' --cfg '__paritysi2="optimized-c"' --cfg '__parityti2="optimized-c"' --cfg '__popcountdi2="optimized-c"' --cfg '__popcountsi2="optimized-c"' --cfg '__popcountti2="optimized-c"' --cfg '__powixf2="optimized-c"' --cfg '__subvdi3="optimized-c"' --cfg '__subvsi3="optimized-c"' --cfg '__subvti3="optimized-c"' --cfg '__truncdfhf2="optimized-c"' --cfg '__truncdfsf2="optimized-c"' --cfg '__truncsfhf2="optimized-c"' --cfg '__ucmpdi2="optimized-c"' --cfg '__ucmpti2="optimized-c"' --cfg 'apple_versioning="optimized-c"' -l static=compiler-rt` (exit code: 1)
command did not execute successfully: "/local/mnt/workspace/rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "8" "-v" "-v" "-v" "--release" "--features" "panic-unwind llvm-libunwind backtrace compiler-builtins-c" "--manifest-path" "/local/mnt/workspace/rust/rust/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
Traceback (most recent call last):
  File "./x.py", line 11, in <module>
    bootstrap.main()
  File "/local/mnt/workspace/rust/rust/src/bootstrap/bootstrap.py", line 866, in main
    bootstrap(help_triggered)
  File "/local/mnt/workspace/rust/rust/src/bootstrap/bootstrap.py", line 852, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/local/mnt/workspace/rust/rust/src/bootstrap/bootstrap.py", line 141, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /local/mnt/workspace/rust/rust/build/bootstrap/debug/bootstrap build --stage 1 -vvvv --config ../hexagon-linux-83.toml src/libcore

I'm not sure how they do it, but many targets do not support 128-bit integers and yet they are able to build libcore (e.g. the nvptx targets). Maybe try to search for some of those in tree and see if a workaround is being added somewhere ? (maybe in compiler-builtins ?)

Yes

1 Like

So @bcain as @bjorn3 mentions to get libcore going you are going to have to patch the compiler-builtins crate for your target as well.

Nit: Few, if any targets have native 128-bit integer registers that support 128-bit integer operations (not counting 128-bit SIMD registers where the only available arithmetic ops interpret them as packed vectors of smaller types).

Yeah good point so I guess the rust i/u128 are nearly always implemented in software? Seems like there would be a target-independent implementation I could use. I suppose I could implement it as arch-specific instructions to make it faster but for now I just want to get a working platform.

Yes, compiler-builtins has one, that is why I mentioned it.

Oh dang :man_facepalming: -- I guess I just saw arm annotations there and assumed that it was arch-specific. Thanks for taking the time to point it out, I'll find a way to enable it.

Those arm annotations are because arm calls some intrinsics different from other architectures. If hexagon uses standard names, then there should be no need to change compiler_builtins.