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
curl using cmake on arm32 systems build error -Werror=cast-align #13035
Comments
This looks like a wrong compiler warning. |
fyi - it is |
Hmm, is this the only file where you get those errors? We use the same casting in |
I just tested with |
Does this patch silence the warnings? (against current master, might not work cleanly on 8.6.0) diff --git a/lib/http_chunks.c b/lib/http_chunks.c
index 3236c0e47..c1f5e42f5 100644
--- a/lib/http_chunks.c
+++ b/lib/http_chunks.c
@@ -389,10 +389,21 @@ CURLcode Curl_httpchunk_read(struct Curl_easy *data,
struct chunked_writer {
struct Curl_cwriter super;
struct Curl_chunker ch;
};
+#if defined(__GNUC__)
+/* Ignore cast-align warnings (on 32 bit arm):
+
+ error: cast increases required alignment of target type [-Werror=cast-align]
+ | struct chunked_writer *ctx = (struct chunked_writer *)writer;
+ ^
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
+#endif
+
static CURLcode cw_chunked_init(struct Curl_easy *data,
struct Curl_cwriter *writer)
{
struct chunked_writer *ctx = (struct chunked_writer *)writer;
@@ -411,10 +422,14 @@ static void cw_chunked_close(struct Curl_easy *data,
static CURLcode cw_chunked_write(struct Curl_easy *data,
struct Curl_cwriter *writer, int type,
const char *buf, size_t blen)
{
struct chunked_writer *ctx = (struct chunked_writer *)writer;
+#if defined(__GNUC__)
+/* Stop ignoring cast-align warnings */
+#pragma GCC diagnostic pop
+#endif
CURLcode result;
size_t consumed;
if(!(type & CLIENTWRITE_BODY))
return Curl_cwriter_write(data, writer->next, type, buf, blen); |
We could reorder the struct to move the @heitbaum could you test if it helps to reshuffle the members in |
I have run a full build on all of our targets. This addresses the issue. No warnings or errors - 👍. |
I’ll try. |
I’ve had a look, and don’t think it is the struct itself? I tried with char align[] with no success.. Might be wrong. Is it the pointer? The pointer is 4 bytes on arm32 and 8 on aarch64/x86_64. Curl_cwriter is 12 bytes on arm32 and 24 or x86_64 im a bit confused now. |
Same here. Do not really understand it. Let's go with @bagder 's proposal. |
I'll turn it into a PR in a sec |
Using pragma. Reported by Rudi Heitbaum Fixes #13035
the "sec" became 17 hours 😁 |
You are just accelerating too fast now and then, time dilation sets in. |
This isn't limited to gcc or arm32. llvm/clang 17.0.6 also complains, e.g. in this case for Windows
edit: this is different code, but the same pattern with a reader (instead of writer), and the same warning. |
Ok, it's time to rethink this way of casting. We started this in content_encoding.c ages ago, but modern compilers and arch do not seem to like that. I will make a PR to change that, given @bagder any intent to merge #13026 and #13039 soon? I'd like to do the rework on top of that to avoid rebasing. |
I'll have them merged before EOD! |
Thanks. Then I'll start that change tomorrow. |
My current explanation for this mess: https://chaos.social/@icing/112043038186968686 |
- `struct Curl_cwriter` and `struct Curl_creader` now carry a `void *ctx` member that points to the instance as allocated. - using `r->ctx` and `w->ctx` as pointer to the instance specific struct that has been allocated - intended to fix curl#13035
Could you verify that #13059 fixes the issue in your builds? Thanks! |
#13059 fixed my build case. (it wasn't x64, but x86, just noticed it now, but Windows and llvm/clang 17 it is) |
I did this
build curl using cmake on arm32 systems errors due to
http_chunks.c:399:32: error: cast increases required alignment of target type [-Werror=cast-align]
. Build on aarch64 and x86_64 build correctlyI expected the following
Successful compile
curl/libcurl version
curl 8.6.0
operating system
LibreELEC HEAD
The text was updated successfully, but these errors were encountered: