Is cross-compiling with Rust even possible on OpenBSD? I don't see
rustup available, and ran into the below issues when trying a couple of
different triples, with an attempted no_std "hello world".

Thank you.


On 2025-01-21 17:13:11-0700, Luke A. Call <luke...@onemodel.org> wrote:
> I'm attempting to follow these instructions
>    https://zenn.dev/zulinx86/articles/rust-nostd-101
> ...to create a no_std "hello world" in Rust, just to 
> see it work, and its size and speed. 
> 
> I get these two errors:
> 
> 
> $cargo build --target x86_64-unknown-openbsd
>    Compiling baremetal_rust v0.1.0 (/home/lacall/proj/learnrust/no_std)
> error: linking with `cc` failed: exit status: 1
>   |
>   = note: LC_ALL="C" PATH="/usr/local/lib/rustlib/
> x86_64-unknown-openbsd/bin:/usr/local/lib/rustlib/
> x86_64-unknown-openbsd/bin:/usr/local/lib/rustlib/x86_64-unknown-openbsd
> /bin:[...] " VSLANG="1033" "cc" "-m64" "/tmp/rustcxWUaqp/symbols.o" 
> "/home/lacall/proj/learnrust/no_std/target/x86_64-unknown-openbsd/
> debug/deps/baremetal_rust-a29cf966f63a7968.27oi4sy4zl19d02xz9nha6rkv.
> rcgu.o" "-Wl,--as-needed" "-L" "/home/lacall/proj/learnrust/no_std/
> target/x86_64-unknown-openbsd/debug/deps" "-L" "/home/lacall/proj/
> learnrust/no_std/target/debug/deps" "-L" "/usr/local/lib/rustlib/
> x86_64-unknown-openbsd/lib" "-Wl,-Bstatic" "/usr/local/lib/rustlib/
> x86_64-unknown-openbsd/lib/librustc_std_workspace_core-02e247769dc17413.
> rlib" "/usr/local/lib/rustlib/x86_64-unknown-openbsd/lib/libcore-02e24
> 7769dc17405.rlib" "/usr/local/lib/rustlib/x86_64-unknown-openbsd/lib/
> libcompiler_builtins-02e247769dc17404.rlib" "-Wl,-Bdynamic" 
> "-lcompiler_rt" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/
> local/lib/rustlib/x86_64-unknown-openbsd/lib" "-o" "/home/lacall/proj/
> learnrust/no_std/target/x86_64-unknown-openbsd/debug/deps/
> baremetal_rust-a29cf966f63a7968" "-Wl,--gc-sections" "-pie" "-Wl,-z,
> relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs"
>   = note: ld: error: duplicate symbol: _start
>           >>> defined at /usr/lib/crt0.o:(.text+0x0)
>           >>> defined at 27oi4sy4zl19d02xz9nha6rkv
>           >>>            /home/lacall/proj/learnrust/no_std/target/
>         x86_64-unknown-openbsd/debug/deps/baremetal_rust-
>         a29cf966f63a7968.27oi4sy4zl19d02xz9nha6rkv.rcgu.o:(
>         .text._start+0x0)
> 
>           cc: error: linker command failed with exit code 1 (use -v 
>         to see invocation)
> error: could not compile `baremetal_rust` (bin "baremetal_rust") due to 1 
> previous error 
> 
> 
> ...or...
> 
> 
> $cargo build --target x86_64-unknown-none                                     
>                                                           Compiling 
> baremetal_rust v0.1.0 (/home/lacall/proj/learnrust/no_std)
> error[E0463]: can't find crate for `core`
>   |
>   = note: the `x86_64-unknown-none` target may not be installed
>   = help: consider downloading the target with `rustup target add 
> x86_64-unknown-none`
> For more information about this error, try `rustc --explain E0463`.
> error: could not compile `baremetal_rust` (bin "baremetal_rust") due to 1 
> previous error
> 
> 
> But I'm also interested in cross-compiling later, to other platforms,
> which I will have to learn, and this makes me wonder if that will be 
> possible, since rustup does not seem to be available.
> 
> Any suggestions or corrections? Thanks very much.
> 
> Luke Call

Reply via email to