Skip to content
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

oreboot won't build for riscv64: __atomic_{load,store}_16 are not defined #66240

Open
rminnich opened this issue Nov 9, 2019 · 6 comments
Open

oreboot won't build for riscv64: __atomic_{load,store}_16 are not defined #66240

rminnich opened this issue Nov 9, 2019 · 6 comments

Comments

@rminnich
Copy link

@rminnich rminnich commented Nov 9, 2019

We have been building github.com/oreboot/oreboot with rust since last spring. Within the last month, we've hit the problem seen in https://dev.azure.com/azure0427/Oreboot%20Pipeline/_build/results?buildId=338, as well as oreboot/oreboot#183

__atomic_store_16 is undefined, as is __atomic_load_16.

oreboot has been working on riscv hardware (riscv64, sifive hifive board) for several months, so we're not quite sure where to start. I've been looking around for similar problems but nothing quite fits.

Thanks.

@mati865

This comment has been minimized.

Copy link
Contributor

@mati865 mati865 commented Nov 9, 2019

Already reported to upstream crate: rust-lang/compiler-builtins#322

@rminnich

This comment has been minimized.

Copy link
Author

@rminnich rminnich commented Nov 10, 2019

here is the "fix" for oreboot

`+.globl __atomic_store_16
+__atomic_store_16:

  •   ret
    

+.globl __atomic_load_16
+__atomic_load_16:

  •   ret
    

`

i.e. fake up no op atomic load and store for 16 bits, b/c the architecture does not support them.

You're asking the architecture to do something it can't do ... :-p

@rminnich

This comment has been minimized.

Copy link
Author

@rminnich rminnich commented Nov 10, 2019

sorry about the format, that's what github claims is a code copy/paste?
`
+.globl __atomic_store_16
+__atomic_store_16:

  •   ret
    

+.globl __atomic_load_16
+__atomic_load_16:

  •   ret
    

.globl _stack_ptr
.section .rodata
_stack_ptr: .word 0x08010000
`

@asb

This comment has been minimized.

Copy link

@asb asb commented Nov 12, 2019

Copying comment from oreboot/oreboot#183 (comment)
CC @lenary
IIRC In the GCC world this symbol is provided by libatomic rather than libgcc directly. In the LLVM world, compiler-rt provides the symbol. Rust should either use a RISC-V compiler-rt or if using libgcc it should link libatomic as well.

@lenary

This comment has been minimized.

Copy link
Contributor

@lenary lenary commented Nov 12, 2019

Yeah. This issue comes up every so often, especially more recently.

The RISC-V "A" extension only introduces instructions for 32- and 64-bit atomic operations. If you need up-to-32-bit atomic operations (ie, 8-bit or 16-bit atomic operations), then you have to link with -latomic if using gcc's compiler builtins (because libgcc and libatomic are separate libraries).

LLVM's compiler-rt is a slightly different, and contains both the compiler builtins and the atomic libcalls in the same library, so this issue should arise less once LLVM can switch to compiler-rt for RISC-V. That could happen soon given https://reviews.llvm.org/D68393 has landed.

@mati865

This comment has been minimized.

Copy link
Contributor

@mati865 mati865 commented Nov 13, 2019

I was fixed in compiler-builtins crate via rust-lang/compiler-builtins#324.
Can you make xargo pull newer version? Otherwise it may require updating this dependency in Rust repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.