Anyone else working on #5446 or #5486?
I don't think anyone is
Want me to assign them to you?
yes :)
Oh, wait I need a comment again :smiley:
What is the internal form of the toXChecked functions?
internal form?
Yeah, so what is the actual data that should be returned.
Also, why are their both X_op functions in the llvm/lowlevel.rs as well as run_low_level
why are their both X_op functions in the llvm/lowlevel.rs as well as run_low_level
I'm a little confused, run_low_level is inside llvm/lowlevel.rs
Sorry, these questions were a complete mess. So, there are functions like toI32Checked
, which returns Result I32 [OutOfBounds]
, so what does the [OutOfBounds]
correspond to, is it a tag?
Second question, the run_low_level
function is indeed in llvm/lowlevel.rs
. However there is also build_int_unary_op
, build_int_binary_op
, among others. Why is this? What should be put into run_low_level
and what should be made into an op
?
Hopefully this clears up the questions about the questions.
so what does the
[OutOfBounds]
correspond to, is it a tag?
Yes, OutOfBounds
is a tag
i see, and when should one use the _op
functions as opposed to the run_low_level
is it just a way to seperate the code out
Yes, I believe so
ok got it
Hey anyone know why running
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
import pf.Stdout
main =
numF64 = 1701411834604692531795.748
numDec = Num.toDecChecked numF64
Stdout.line! (Inspect.toStr numDec)
Gives this error
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Invalid decimal for float literal = 1701411834604692531795.748. This should be a type error!
Location: crates/compiler/mono/src/ir/literal.rs:115:25
(Yes I'm implementing the decimal function, but even removing it still gives this error)
but even removing it still gives this error
This breaks the same for me on main
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
import pf.Stdout
main =
numF64 = 1701411834604692531795.748
Stdout.line! (Inspect.toStr numF64)
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Invalid decimal for float literal = 1701411834604692531795.748. This should be a type error!
Location: crates/compiler/mono/src/ir/literal.rs:115:25
yeah thats what I'm saying
Changing it to 1701411834604692531795.748f64
works fine
The default number type is Dec
so I imagine that is relevant here
Do you get this or is this a bug in my addition?
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Undefined Symbol in relocation, (+6360, Relocation { kind: PltRelative, encoding: Generic, size: +20, target: Symbol(SymbolIndex(+a6)), addend: +fffffffffffffffc, implicit_addend: false }): Ok(Symbol { name: "__fixdfti", address: +0, size: +0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: +10, st_other: +0 } })
Location: crates/linker/src/elf.rs:1452:25
This is where it's failing
LayoutRepr::Builtin(Builtin::Decimal) => {
let dec = match RocDec::from_str(num_str) {
Some(d) => d,
None => internal_error!(
"Invalid decimal for float literal = {}. This should be a type error!",
num_str
),
};
NumLiteral::Decimal(dec.to_ne_bytes())
}
Do you get this or is this a bug in my addition?
I haven't seen that
My guess is that may be unrelated though... that looks like a linker bug
ok so that's my bug
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
import pf.Stdout
main =
numF64 = 1701411834604692531795.748f64
Stdout.line! (Inspect.toStr numF64)
numDec = Num.toDec numF64
Stdout.line! (Inspect.toStr numDec)
With this
Can you represent that number as a F64?
» 1701411834604692531795.748f64
1701411834604692400000 : F64
wdym
When I put it in the repl it's getting cut off at the 4
, rounding and losing precision
It's definitly in the range, it's probably just not high percision that far from 0
Ok yeah i don't think it's related
but ima check anyway
Ok yeah it's a bug in another part of the code
We should return a constant out of range error if the constant is too large to be converted into a Dec
So there is a missing error that needs to be wired up
So that error is correct, it just isn't pretty
No, it is a valid F64, Roc is just saying it isn't
It isn't an f64
It's a Dec.
And it isn't a valid Dec
At what point?
Oh, am I mixed up, I thought it was too large to be a valid Dec and that is the failuer
oh there was a mistake, but it's still invalid even if I switch toDec
to toDecChecked
If it fits in a Dec then it is a Dec parsing bug
Even if its marked as a float?
Wizard ish said:
Do you get this or is this a bug in my addition?
An internal compiler expectation was broken. This is definitely a compiler bug. Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose> Undefined Symbol in relocation, (+6360, Relocation { kind: PltRelative, encoding: Generic, size: +20, target: Symbol(SymbolIndex(+a6)), addend: +fffffffffffffffc, implicit_addend: false }): Ok(Symbol { name: "__fixdfti", address: +0, size: +0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: +10, st_other: +0 } }) Location: crates/linker/src/elf.rs:1452:25
You probably need to explicit tell llvm not to Dead code eliminate that function. It's probably part of compiler rt.
which func
toDec?
__fixdfti
Wizard ish said:
Even if its marked as a float?
I don't follow. Based on Luke's comments above, it works with the f64
suffix. So it works when marked as a float.
no it doesn't
here
Here's the work on Dec functions and both of these fail:
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
import pf.Stdout
main =
numF64 = 1701411795f64
numDec = Num.toDecChecked numF64
Stdout.line! (Inspect.toStr numDec)
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
import pf.Stdout
main =
numF64 = 17014117913243243243234223141241.43243f64
numDec = Num.toDecChecked numF64
Stdout.line! (Inspect.toStr numDec)
With
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Undefined Symbol in relocation, (+7fb0, Relocation { kind: PltRelative, encoding: Generic, size: +20, target: Symbol(SymbolIndex(+a9)), addend: +fffffffffffffffc, implicit_addend: false }): Ok(Symbol { name: "__fixdfti", address: +0, size: +0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: +10, st_other: +0 } })
Location: crates/linker/src/elf.rs:1452:25
Oh sure. That is a separate issue from Invalid decimal for float literal = 1701411834604692531795.748. This should be a type error!
.
Let me try and find where you need to stop dead code elimination
I think Brendan is talking about adding that function here https://github.com/roc-lang/roc/blob/49ab969ff3eedad0d5feaa56dc63e7cb4be3b471/crates/compiler/gen_llvm/src/llvm/build.rs#L1056
Yes, exactly. Thanks for finding it!
hmmm and do i add the llvm operation name or the name given in the code
__fixdfti
from the linker error
ah ok
Yo that fixed it!
ok and the implementations of the funcs are done
just gonna add some tests and then open the pr
Why are there three backends, and what even is the dev
backend?
The gen-llvm
backend is used to produce optimised code which means the code that is produces will run fast.
The gen-dev
backends are designed to compile and produce code very fast (a few milliseconds) so they are nicer for a development workflow where you don't care (yet) about runtime performance but instead want to iterate fast.
The gen-wasm
backend produces native wasm32 bytecode and is the dev
backend equivalent for wasm.
LLVM is really great, but it is very slow to compile like on the order of 700 milliseconds for a hello word type app.
does gen-dev
use LLVM?
Nope. It generates assembly directly
Hey, should PRs be seperate from the diffrent backends (so, for instance, should / can I make a PR just implementing toDec for LLVM)?
Totally fine either way.
Very often llvm backend has features long before the other backends
Frankly, we really need to iron out the last few features for the dev backend so that it could be enabled by default (though that may reveal that we also need a proper register allocator and a bigger overhaul)
Hmm that’s done in mono right?
Register allocation? No, it's backend specific.
I mean gen dev
Yep
Ok
Its register allocation is exceptionally naive right now. Runs super fast, but spills all the time. The dev backend currently goes straight from mono to assembly. This is fast, but really the wrong abstraction for generating assembly. So it has some complications and limitations.
Currently the dev backend is used for the repl and can be opted into. I think the only major missing feature is generating the platform interface correctly. Once that is done, it could be the default backend.
Wasm backend is farther along. It is used for the web repl, but also can be used for real apps (still requires explicit opt in)
I’m not familiar with it. Does it just always load stuff into memory even if the next op uses it?
out of curosity why is mono used?
It keeps a working list of stuff in registers, but doesn't track lifetimes in order to be smarter. So it just pushes the oldest thing in a register to stack if it runs out of registers.
It uses mono cause that is the bottom of the compiler stack before backends. It is faster to just use mono than to build and convert to another ir.
ah i see, anything y'all in particular need help with?
The plan is actually now to add an extra level of ir:
https://github.com/roc-lang/roc/issues/6498
Bigger project, but very useful.
while you go into it a little, exactly how high level should it be?
should it be like assembly, where, for instance, types are completly irrelevant and for instance Add<i32>
is a completly seperate op from Add<u64>
(ie AddSigned4
and AddUnsigned8
) or rather should it have types tagged (so have registers also store types) so one writes Add
and it will then when translated in binary become either Add<i32>
or Add<u64>
?
I assumed roughly one enum entry per function here: https://github.com/roc-lang/roc/blob/fc6b519b5948023981ac5751d2f6ee48bcef2316/crates/compiler/gen_dev/src/generic64/mod.rs#L153-L742
That is our current assembly abstraction
Hello, I was advised (here)[https://github.com/roc-lang/roc/pull/7261#issuecomment-2556535016], to sign my old commits, however I couldn’t find any source that said how to sign pushed commits in a PR. How would I do this?
Hi @Wizard ish,
It is explained here but I don't recommend doing that procedure in the case of this PR, because its complicated if you got merges in there. We'll force the merge, I'm just going to check out the failure of the panic check.
Ok, also that should be linked with signing in the contribution guide
It is linked: https://github.com/roc-lang/roc/blob/main/CONTRIBUTING.md#commit-signing
But I welcome suggestions on how we can make that more visible
Oh I was looking under the dropdown
Yeah my original here link was wrong, the dropdown (Forgot to sign commits?) actually seems to contain the best answer to your question "to sign my old commits".
Hi Wizard ish,
It is explained here but I don't recommend doing that procedure in the case of this PR, because its complicated if you got merges in there. We'll force the merge, I'm just going to check out the failure of the panic check.
Do you agree?
Yeah, though both are quite useful
I'll link to the guide again under the dropdown
What do you think?
Screenshot from 2024-12-20 21-00-01.png
it's good, but imo it should really be a alert
I didn't know about alerts, those are nice!
I did find out that they do not work inside dropdowns so I went with an exclamation emoji instead
Yeah, github has a lot of fun formatting things, you can find much on them here. My personal favorite has got to be diagramming
Last updated: Jul 06 2025 at 12:14 UTC