Skip to content

Compilation errors when building rust with GCC 6.1 #33246

Closed
@rjammala

Description

@rjammala

Here is what I get when I clone rust from github and try to build it with GCC 6.1:

rjammalamadaka/rust/src/rt/miniz.c: In function ‘tinfl_decompress’:
rjammalamadaka/rust/src/rt/miniz.c:578:9: error: this ‘for’ clause does not guard... [-Werror=misleading-indentation]
         for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
         ^~~
rjammalamadaka/rust/src/rt/miniz.c:578:47: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
         for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
                                               ^~~
rjammalamadaka/rust/src/rt/miniz.c: In function ‘tdefl_find_match’:
rjammalamadaka/rust/src/rt/miniz.c:1396:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
     if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break;
     ^~
rjammalamadaka/rust/src/rt/miniz.c:1396:23: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
     if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break;

Activity

nagisa

nagisa commented on Apr 27, 2016

@nagisa
Member

NOTE: I edited you message to format the report.

durka

durka commented on Apr 28, 2016

@durka
Contributor

Should we fix the code, or just turn off the warning? It looks like miniz.c was imported wholesale from somewhere else...

frewsxcv

frewsxcv commented on Apr 29, 2016

@frewsxcv
Member
adelarsq

adelarsq commented on Apr 30, 2016

@adelarsq

@alexcrichton Just to know. Any reason to avoid a update for the miniz.c file?

alexcrichton

alexcrichton commented on Apr 30, 2016

@alexcrichton
Member

Nah should be fine to update!

alexcrichton

alexcrichton commented on Apr 30, 2016

@alexcrichton
Member

@bors: retry

On Fri, Apr 29, 2016 at 5:35 PM, Adelar da Silva Queiróz <
notifications@github.com> wrote:

@alexcrichton https://github.com/alexcrichton Just to know. Any reason
to avoid a update for the miniz.c file?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#33246 (comment)

dns2utf8

dns2utf8 commented on May 10, 2016

@dns2utf8
Contributor

I updated the miniz.c locally, but it did not compile with gcc 6.1.1.
I am compiling with clang 3.7.1 now with the updated file, works so far.

MagaTailor

MagaTailor commented on May 10, 2016

@MagaTailor

No problem on ARM using gcc 6.1.0, go figure. And I didn't pass -Wno-error anywhere.

Edit:
No wait, gcc was bootstrapped with --disable-werror

dns2utf8

dns2utf8 commented on May 10, 2016

@dns2utf8
Contributor

I was able to build the compiler and the docs with clang and I opened a issue on richgel999/miniz#51.

MagaTailor

MagaTailor commented on May 10, 2016

@MagaTailor

Likewise with gcc, just add -Wno-error to your CFLAGS for now.

SimonSapin

SimonSapin commented on May 20, 2016

@SimonSapin
Contributor

This fixes the build for me with GCC 6.1.1.

diff --git a/src/rt/miniz.c b/src/rt/miniz.c
index 2b803b0..b3a453d 100644
--- a/src/rt/miniz.c
+++ b/src/rt/miniz.c
@@ -575,7 +575,10 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
       {
         mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
         r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
-        for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
+        for ( i = 0; i <= 143; ++i) *p++ = 8;
+        for ( ; i <= 255; ++i) *p++ = 9;
+        for ( ; i <= 279; ++i) *p++ = 7;
+        for ( ; i <= 287; ++i) *p++ = 8;
       }
       else
       {
@@ -1393,7 +1396,10 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
         if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break;
       TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
     }
-    if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break;
+    if (!dist) break;
+    p = s;
+    q = d->m_dict + probe_pos;
+    for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break;
     if (probe_len > match_len)
     {
       *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return;
dns2utf8

dns2utf8 commented on May 27, 2016

@dns2utf8
Contributor

There is a PR addressing this: #33798

dns2utf8

dns2utf8 commented on May 27, 2016

@dns2utf8
Contributor

And I made a PR to upstream: richgel999/miniz#52
Maybe upgrade miniz after it is merged.

Regards

tbu-

tbu- commented on May 30, 2016

@tbu-
Contributor

Fixed by #33798.

Keruspe

Keruspe commented on May 30, 2016

@Keruspe
Contributor

There's still another compilation failure with gcc 6 here

/var/tmp/paludis/build/dev-lang-rust-1.9.0-r1/work/rustc-1.9.0/src/rt/hoedown/src/document.c: In function 'char_link':
/var/tmp/paludis/build/dev-lang-rust-1.9.0-r1/work/rustc-1.9.0/src/rt/hoedown/src/document.c:1161:5: error: this 'else' clause does not guard... [-Werror=misleading-indentation]
     else nb_p--; i++;
     ^~~~
/var/tmp/paludis/build/dev-lang-rust-1.9.0-r1/work/rustc-1.9.0/src/rt/hoedown/src/document.c:1161:18: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'
     else nb_p--; i++;
                  ^
        ^ 
steveklabnik

steveklabnik commented on Oct 31, 2018

@steveklabnik
Member

We have since removed hoedown as well. Is anyone still seeing this issue? I believe it can be closed.

added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
and removed
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
on Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@durka@alexcrichton@Keruspe@SimonSapin

        Issue actions

          Compilation errors when building rust with GCC 6.1 · Issue #33246 · rust-lang/rust