-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Roc standard library in C++ #6230
base: main
Are you sure you want to change the base?
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.
Just a few high level comments. Didn't really dig into the impl much. At some point I'll probably want to push a PR with some suggested changes, but that is for another time.
crates/glue/cpp/src/internal.h
Outdated
/** | ||
* Base class for all Roc value types | ||
* Implements common logic like reference counting. | ||
* We don't use virtual functions because we want to avoid the vtable. | ||
*/ |
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.
Unless I am mixing something up, this will still use a vtable, the base class just has an implementation. To avoid a vtable, you would have to use some sort of template.
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.
Anyway, given there will be little shared logic, I would just drop this and not have a generic Value
type.
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.
OK I misunderstood vtables then. I deleted the comment.
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.
I'm not going to get rid of Value
as part of this PR because the idea is to take what I have and bring it into the repo. The understanding is that we can make improvements later and this can be one of them.
crates/glue/cpp/src/dict.h
Outdated
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.
Probably should remove this file? Our dictionaries haven't been an associative list in quite a long time. On top of that, the impl may change more. I don't think it would be better to force the roc platform to expose dictionary functions to the platform than for the platform to attempt to implement this.
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.
Our dictionaries haven't been an associative list in quite a long time.
OK then we also need to update or delete crates/roc_std/src/roc_dict.rs which is what I based this on, and what our RustGlue.roc uses.
I'll set up some CI tests |
crates/glue/cpp/src/internal.h
Outdated
void *roc_alloc(size_t size, uint32_t alignment); | ||
void *roc_realloc(void *ptr, size_t new_size, size_t old_size, size_t alignment); | ||
void roc_dealloc(void *ptr, uint32_t alignment); | ||
void roc_panic(const char *message, uint32_t _tag_id); |
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.
Just FYI this should take a Str in the first parameter
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.
Oh yes of course. We must have this bug in so many places. I copied this code from somewhere else in the repo.
Unfortunately, fixing this creates a cyclic dependency. I need to make internal.h
depend on str.h
but str.h
already depends on internal.h
for the allocation functions.
I might be able to break it by reorganising the files or pre-declaring something.
|
That's weird, I developed this on an M1 Mac! |
Managed to reproduce using the exact same commands as CI |
My local installation of Clang
Roc nix version of Clang
Clang 11 is throwing in the Result tests somewhere. ./run-tests --group Result # fails
./run-tests --group Result --name Ok # succeeds
./run-tests --group Result --name Err # succeeds
./run-tests --group Result --name OkSameType # succeeds
./run-tests --group Result --name ErrSameType # succeeds |
@Anton-4 do you know if there's a good reason we're on Clang 11.1? From the LLVM releases page it seems to date back to Feb 2021. |
The |
After a long and difficult bisect journey I was able to find the nix commit that caused the issue. Follow up discussion will happen in #6303. |
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Needed for RUSTFLAGS Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Hmm, I'm seeing issues with clang++ 16 and 15 as well @brian-carroll
clang++ 15 (outside nix):
|
Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked |
Copying over from https://github.com/brian-carroll/roc-std-cpp/releases/tag/copy-to-main-repo
This will not be useful until we also have a
CppGlue.roc
, which will probably import the.h
files as strings.I'm not sure what we want to do from a CI point of view.
The tests depend on GNU Make and clang or gcc.
You can run the tests with
make check
If you want to use gcc instead of clang, it's
make check CC=gcc
Oh and I also vendored a test framework! Hopefully the license is OK?