-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fixed build on Linux with GCC #44
Conversation
|
b646958
to
626a6e5
Compare
Never mind. Got it fixed: https://github.com/stemann/mlx-c/actions/runs/11916338116 |
626a6e5
to
846407a
Compare
I have removed the GitHub Actions |
mlx/c/array.h
Outdated
@@ -5,6 +5,7 @@ | |||
|
|||
#include "mlx/c/string.h" | |||
|
|||
#include <cstdint> |
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 did not need this one on my side, curious which GCC compiler/system are you using, and where the error is located?
- this is a C header, so includes should be C, not C++; is the error popping up in
array.cpp
or inarray.h
?
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.
GCC 11.4: https://github.com/stemann/mlx-c/actions/runs/11910841319/job/33191101517#step:4:293
In file included from /home/runner/work/mlx-c/mlx-c/mlx/c/array.cpp:5:
/home/runner/work/mlx-c/mlx-c/mlx/c/array.h:176:26: error: ‘uint8_t’ was not declared in this scope
176 | int mlx_array_item_uint8(uint8_t* res, const mlx_array arr);
| ^~~~~~~
Though, I'm using GCC 10 in JuliaPackaging/Yggdrasil#9809
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 might have messed up wrt. C vs C++ headers.
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.
Uh ok. Definitively need a stdint.h
there, thanks
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.
To be more specific, I was using:
- Locally, in a container
mcr.microsoft.com/devcontainers/cpp:1-debian-11
: GCC 10.2 (on Debian 11). - GitHub Actions, on
"ubuntu-latest"
runner: GCC 11.4 - BinaryBuilder env. (Julia): GCC 10.2 (cross-compile env. running on an Alpine Linux (musl) - cross-compiling to various targets)
mlx/c/closure.cpp
Outdated
@@ -183,7 +183,7 @@ extern "C" mlx_closure_value_and_grad mlx_closure_value_and_grad_new_func( | |||
"mlx_closure_value_and_grad returned a non-zero value"); | |||
} | |||
auto cpp_res = | |||
std::tie(mlx_vector_array_get_(res_0), mlx_vector_array_get_(res_1)); | |||
std::make_pair(mlx_vector_array_get_(res_0), mlx_vector_array_get_(res_1)); |
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.
Sorry this is not really documented, but this file is auto-generated, so one should not modify it manually. Instead, modify mlxtypes.py
cpp_make_tuple = "std::make_pair" if n == 2 else "std::make_tuple"
types.append(
{
"cpp": cpp_tuple + "<" + ", ".join(cpp_types) + ">",
"alt": [cpp_tuple + "<" + ", ".join(alt_types) + ">"] + alts,
"c_to_cpp": lambda s: cpp_make_tuple + "("
The file can then be generated via
python ../../python/closure_generator.py --implementation > closure.cpp
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.
(a clang-format -i closure.cpp
would need to follow)
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.
Ah OK.
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 added the change to the mlxtypes.py
code generator, but if I run it there are a lot more changes than I would expect (I would have expected zero - keeping my manual change).
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.
Ah - got you message on clang-format
now. Now executed.
mlx/c/compile.h
Outdated
@@ -8,6 +8,8 @@ | |||
|
|||
#include <stdio.h> | |||
|
|||
#include <cstdint> |
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.
same comments as above
- this is a C header
- where is the error coming up? (I do not have it on my end)
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.
It was for uintptr_t
, it seems: https://github.com/stemann/mlx-c/actions/runs/11911185130/job/33192141400#step:5:334
mlx/c/fast.cpp
Outdated
@@ -3,6 +3,8 @@ | |||
/* This file is auto-generated. Do not edit manually. */ | |||
/* */ | |||
|
|||
#include <cstdarg> |
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.
This is an auto-generated file. I do not get the error there as well, so curious to know where it occurs. For this one, and the one in metal.cpp
, I would suggest to put additional includes in mlx/c/private/mlx.h
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.
cstdarg
was for the va_x
functions, like va_list
, va_arg
etc.
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.
Noted, i.e. moving it to mlx/c/private/mlx.h
.
mlx/c/metal.cpp
Outdated
@@ -3,6 +3,8 @@ | |||
/* This file is auto-generated. Do not edit manually. */ | |||
/* */ | |||
|
|||
#include <cstring> |
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.
see comment above
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.
Noted, i.e. moving it to mlx/c/private/mlx.h
.
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 tried replacing it with <string.h>
, but it failed - again complaining that there is no strncpy
: https://github.com/stemann/mlx-c/actions/runs/11923235104
Using (now in mlx/c/private/mlx.h
) fixes it: https://github.com/stemann/mlx-c/actions/runs/11923278948
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.
Thanks! Asking for few changes, let me know if that works for you, as I would prefer to have these added before I tag the next MLX C version
It would be great to get these changes merged in, and a new version tagged. Your requested changes should now be implemented - except I have not run the |
* Added missing includes of cstdint, cstring etc. * Replaced pair construction with std::tie with std::make_pair.
-- as it is needed for the (generated) compile.h file
6455e76
to
9fe2944
Compare
Also, Fixed CMakeLists wrt. setting
MLX_BUILD_BENCHMARKS=OFF
.Follow-up after #38
Needed for JuliaPackaging/Yggdrasil#9809