wabt icon indicating copy to clipboard operation
wabt copied to clipboard

silence gcc-12 warnings

Open rathann opened this issue 3 years ago • 3 comments

This fixes the following test failures (#1885): test/wasm2c/spec/call.txt test/wasm2c/spec/names.txt test/wasm2c/spec/skip-stack-guard-page.txt

- test/wasm2c/spec/call.txt
  expected error code 0, got 1.
  STDERR MISMATCH:
  --- expected
  +++ actual
  @@ -0,0 +1,21 @@
  +out/test/wasm2c/spec/call/call.0.c: In function ‘w2c_runaway’:
  +out/test/wasm2c/spec/call/call.0.c:945:13: error: infinite recursion detected [-Werror=infinite-recursion]
  +  945 | static void w2c_runaway(void) {
  +      |             ^~~~~~~~~~~
  +out/test/wasm2c/spec/call/call.0.c:947:3: note: recursive call
  +  947 |   w2c_runaway();
  +      |   ^~~~~~~~~~~~~
  +At top level:
  +cc1: note: unrecognized command-line option ‘-Wno-tautological-constant-out-of-range-compare’ may have been intended to silence earlier diagnostics
  +cc1: all warnings being treated as errors
  +Traceback (most recent call last):
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 497, in <module>
  +    sys.exit(main(sys.argv[1:]))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 471, in main
  +    o_filenames.append(Compile(cc, c_filename, out_dir, includes, defines))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 357, in Compile
  +    cc.RunWithArgsForStdout(*args)
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/utils.py", line 88, in RunWithArgsForStdout
  +    raise error
  +utils.Error: Error running "cc -I/builddir/build/BUILD/wabt-1.0.28/wasm2c -DWASM_RT_MODULE_PREFIX=Z_call_0 -c out/test/wasm2c/spec/call/call.0.c -o out/test/wasm2c/spec/call/call.0.o -Wall -Werror -Wno-unused -Wno-tautological-constant-out-of-range-compare -std=c99 -D_DEFAULT_SOURCE" (1):
  +None
  STDOUT MISMATCH:
  --- expected
  +++ actual
  @@ -1 +0,0 @@
  -72/72 tests passed.

- test/wasm2c/spec/names.txt
  expected error code 0, got 1.
  STDERR MISMATCH:
  --- expected
  +++ actual
  @@ -0,0 +1,139 @@
  +In file included from out/test/wasm2c/spec/names/names.2.c:5:
  +out/test/wasm2c/spec/names/names.2.h:119:38: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  +  119 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZEFZBFZAFZE2Z80Z8BZC2ZA0ZC2ZADZE2Z81ZA0ZE1Z9AZ80ZE2Z80ZAEZE2Z80ZADZ_iv))(void);
  +      |                             ~~~~~~   ^
  +      |                             |  |     |
  +      |                             |  |     end of bidirectional context
  +      |                             |  U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |                             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.h:121:55: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  +  121 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80Z8EZE2Z80Z8FZE2Z80Z91ZE2Z80ZA8ZE2Z80ZA9ZE2Z80ZAAZE2Z80ZABZE2Z80ZACZE2Z80ZAFZE2Z81ZA6ZE2Z81ZA7ZE2Z81ZA8ZE2Z81ZA9Z_iv))(void);
  +      |                            ~~~         ~~~~~~         ^
  +      |                            |           |  |           |
  +      |                            |           |  |           end of bidirectional context
  +      |                            |           |  U+2067 (RIGHT-TO-LEFT ISOLATE)
  +      |                            |           U+2066 (LEFT-TO-RIGHT ISOLATE)
  +      |                            U+202A (LEFT-TO-RIGHT EMBEDDING)
  +out/test/wasm2c/spec/names/names.2.h:332:22: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  +  332 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZAEcbaZ_iv))(void);
  +      |             ~~~      ^
  +      |             |        |
  +      |             |        end of bidirectional context
  +      |             U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.h:334:22: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  +  334 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZADabcZE2Z80ZAEZ_iv))(void);
  +      |             ~~~      ^
  +      |             |        |
  +      |             |        end of bidirectional context
  +      |             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.h:336:25: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  +  336 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZAEcbaZE2Z80ZADZ_iv))(void);
  +      |             ~~~   ~~~   ^
  +      |             |     |     |
  +      |             |     |     end of bidirectional context
  +      |             |     U+202E (RIGHT-TO-LEFT OVERRIDE)
  +      |             U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.h:338:25: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  +  338 | extern u32 (*WASM_RT_ADD_PREFIX(Z_ZF0Z9DZ91ZA8Z_iv))(void);
  +      |             ~~~   ~~~   ^
  +      |             |     |     |
  +      |             |     |     end of bidirectional context
  +      |             |     U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:4700:38: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 4700 | u32 (*WASM_RT_ADD_PREFIX(Z_ZEFZBFZAFZE2Z80Z8BZC2ZA0ZC2ZADZE2Z81ZA0ZE1Z9AZ80ZE2Z80ZAEZE2Z80ZADZ_iv))(void);
  +      |                             ~~~~~~   ^
  +      |                             |  |     |
  +      |                             |  |     end of bidirectional context
  +      |                             |  U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |                             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:4702:55: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 4702 | u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80Z8EZE2Z80Z8FZE2Z80Z91ZE2Z80ZA8ZE2Z80ZA9ZE2Z80ZAAZE2Z80ZABZE2Z80ZACZE2Z80ZAFZE2Z81ZA6ZE2Z81ZA7ZE2Z81ZA8ZE2Z81ZA9Z_iv))(void);
  +      |                            ~~~         ~~~~~~         ^
  +      |                            |           |  |           |
  +      |                            |           |  |           end of bidirectional context
  +      |                            |           |  U+2067 (RIGHT-TO-LEFT ISOLATE)
  +      |                            |           U+2066 (LEFT-TO-RIGHT ISOLATE)
  +      |                            U+202A (LEFT-TO-RIGHT EMBEDDING)
  +out/test/wasm2c/spec/names/names.2.c:4913:22: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  + 4913 | u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZAEcbaZ_iv))(void);
  +      |             ~~~      ^
  +      |             |        |
  +      |             |        end of bidirectional context
  +      |             U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:4915:22: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  + 4915 | u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZADabcZE2Z80ZAEZ_iv))(void);
  +      |             ~~~      ^
  +      |             |        |
  +      |             |        end of bidirectional context
  +      |             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:4917:25: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 4917 | u32 (*WASM_RT_ADD_PREFIX(Z_ZE2Z80ZAEcbaZE2Z80ZADZ_iv))(void);
  +      |             ~~~   ~~~   ^
  +      |             |     |     |
  +      |             |     |     end of bidirectional context
  +      |             |     U+202E (RIGHT-TO-LEFT OVERRIDE)
  +      |             U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:4919:25: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 4919 | u32 (*WASM_RT_ADD_PREFIX(Z_ZF0Z9DZ91ZA8Z_iv))(void);
  +      |             ~~~   ~~~   ^
  +      |             |     |     |
  +      |             |     |     end of bidirectional context
  +      |             |     U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |             U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c: In function ‘init_exports’:
  +out/test/wasm2c/spec/names/names.2.c:5667:22: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 5667 |   /* export: '<U+206A><U+206B><U+206C><U+206D><U+206E><U+206F>' */
  +      |                                                           ~~~~~~~~   ^
  +      |                                                           |    |     |
  +      |                                                           |    |     end of bidirectional context
  +      |                                                           |    U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |                                                           U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:5669:45: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 5669 |   /* export: '<U+2061><U+2062><U+2063><U+2064>' */
  +      |                                                  ~                          ^
  +      |                                                  |           |  |           |
  +      |                                                  |           |  |           end of bidirectional context
  +      |                                                  |           |  U+2067 (RIGHT-TO-LEFT ISOLATE)
  +      |                                                  |           U+2066 (LEFT-TO-RIGHT ISOLATE)
  +      |                                                  U+202A (LEFT-TO-RIGHT EMBEDDING)
  +out/test/wasm2c/spec/names/names.2.c:5880:18: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  + 5880 |   /* export: '<U+202E>cba<U+202D>' */
  +      |               ~~~~~~~~           ^
  +      |               |                  |
  +      |               |                  end of bidirectional context
  +      |               U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:5882:21: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
  + 5882 |   /* export: '<U+1D468>' */
  +      |               ~~~~~~~~~~~~  ^
  +      |               |             |
  +      |               |             end of bidirectional context
  +      |               U+202E (RIGHT-TO-LEFT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:5884:24: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 5884 |   /* export: '<U+1D434>' */
  +      |               ~~~~~~~~~~~~~    ^
  +      |               |          |     |
  +      |               |          |     end of bidirectional context
  +      |               |          U+202E (RIGHT-TO-LEFT OVERRIDE)
  +      |               U+202D (LEFT-TO-RIGHT OVERRIDE)
  +out/test/wasm2c/spec/names/names.2.c:5886:24: error: unpaired UTF-8 bidirectional control characters detected [-Werror=bidi-chars=]
  + 5886 |   /* export: '<U+1D608>' */
  +      |               ~~~~~~~~~~~~~    ^
  +      |               |          |     |
  +      |               |          |     end of bidirectional context
  +      |               |          U+202D (LEFT-TO-RIGHT OVERRIDE)
  +      |               U+202E (RIGHT-TO-LEFT OVERRIDE)
  +At top level:
  +cc1: note: unrecognized command-line option ‘-Wno-tautological-constant-out-of-range-compare’ may have been intended to silence earlier diagnostics
  +cc1: all warnings being treated as errors
  +Traceback (most recent call last):
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 497, in <module>
  +    sys.exit(main(sys.argv[1:]))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 471, in main
  +    o_filenames.append(Compile(cc, c_filename, out_dir, includes, defines))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 357, in Compile
  +    cc.RunWithArgsForStdout(*args)
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/utils.py", line 88, in RunWithArgsForStdout
  +    raise error
  +utils.Error: Error running "cc -I/builddir/build/BUILD/wabt-1.0.28/wasm2c -DWASM_RT_MODULE_PREFIX=Z_names_2 -c out/test/wasm2c/spec/names/names.2.c -o out/test/wasm2c/spec/names/names.2.o -Wall -Werror -Wno-unused -Wno-tautological-constant-out-of-range-compare -std=c99 -D_DEFAULT_SOURCE" (1):
  +None
  STDOUT MISMATCH:
  --- expected
  +++ actual
  @@ -1,3 +0,0 @@
  -spectest.print_i32(42)
  -spectest.print_i32(123)
  -482/482 tests passed.

- test/wasm2c/spec/skip-stack-guard-page.txt
  expected error code 0, got 1.
  STDERR MISMATCH:
  --- expected
  +++ actual
  @@ -0,0 +1,21 @@
  +out/test/wasm2c/spec/skip-stack-guard-page/skip-stack-guard-page.0.c: In function ‘w2c_f1’:
  +out/test/wasm2c/spec/skip-stack-guard-page/skip-stack-guard-page.0.c:322:13: error: infinite recursion detected [-Werror=infinite-recursion]
  +  322 | static void w2c_f1(void) {
  +      |             ^~~~~~
  +out/test/wasm2c/spec/skip-stack-guard-page/skip-stack-guard-page.0.c:458:3: note: recursive call
  +  458 |   w2c_f1();
  +      |   ^~~~~~~~
  +At top level:
  +cc1: note: unrecognized command-line option ‘-Wno-tautological-constant-out-of-range-compare’ may have been intended to silence earlier diagnostics
  +cc1: all warnings being treated as errors
  +Traceback (most recent call last):
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 497, in <module>
  +    sys.exit(main(sys.argv[1:]))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 471, in main
  +    o_filenames.append(Compile(cc, c_filename, out_dir, includes, defines))
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/run-spec-wasm2c.py", line 357, in Compile
  +    cc.RunWithArgsForStdout(*args)
  +  File "/builddir/build/BUILD/wabt-1.0.28/test/utils.py", line 88, in RunWithArgsForStdout
  +    raise error
  +utils.Error: Error running "cc -I/builddir/build/BUILD/wabt-1.0.28/wasm2c -DWASM_RT_MODULE_PREFIX=Z_skip_stack_guard_page_0 -c out/test/wasm2c/spec/skip-stack-guard-page/skip-stack-guard-page.0.c -o out/test/wasm2c/spec/skip-stack-guard-page/skip-stack-guard-page.0.o -Wall -Werror -Wno-unused -Wno-tautological-constant-out-of-range-compare -std=c99 -D_DEFAULT_SOURCE" (1):
  +None
  STDOUT MISMATCH:
  --- expected
  +++ actual
  @@ -1 +0,0 @@
  -10/10 tests passed.

rathann avatar Apr 04 '22 08:04 rathann

This looks like a helpful fix, but I think it will need to work on the platforms that wasm2c is tested on. Unfortunately it doesn't seem like clang 13 or gcc 11 will tolerate -Wbidi-chars=none -Werror without bombing out. :-(

Some options seem to be:

  • make run-spec-wasm2c.py smarter so it only adds -Wbidi-chars=none to the command-line if the compiler is gcc 12
  • make wasm2c smarter so it doesn't emit these bidi control chars
  • maybe some easier strategy?

What do you think?

keithw avatar Apr 09 '22 10:04 keithw

FWIW, I've just tested with the gcc-8.5.0 shipped with RHEL8 and it seems it accepts -Wbidi-chars=none but errors out on -Wno-tautological-constant-out-of-range-compare and -Wno-infinite-recursion. I think the best strategy would be to test if the current compiler supports each individual flag and using them only if it does.

rathann avatar May 25 '22 11:05 rathann

That strategy makes sense to me...

keithw avatar May 25 '22 19:05 keithw

Fixed in #2147

keithw avatar Feb 25 '23 10:02 keithw