Update njs_utf8.h to fix a build failure with O3 and lto on ppc64el #738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cc -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -specs=/usr/share/dpkg/elf-package-metadata.specs -o build/njs -Isrc -Ibuild
-pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -fexcess-precision=standard -g -O3 -ffile-prefix-map=/<>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-stack-clash-protection -fdebug-prefix-map=/<>=/usr/src/libnginx-mod-js-0.8.4-1 -fPIC -Wdate-time -D_FORTIFY_SOURCE=3 -g -O3 -ffile-prefix-map=/<>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-stack-clash-protection -fdebug-prefix-map=/<>=/usr/src/libnginx-mod-js-0.8.4-1
external/njs_shell.c
build/libnjs.a
-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -specs=/usr/share/dpkg/elf-package-metadata.specs -lm -lpcre2-8 -lcrypto -ledit
In function ‘njs_utf8_decode’,
inlined from ‘njs_text_encoder_encode_into’ at src/njs_encoding.c:214:14:
src/njs_utf8.c:191:42: error: ‘ctx.codepoint’ may be used uninitialized [-Werror=maybe-uninitialized]
191 | ctx->codepoint = (ctx->codepoint << 6) | (c & 0x3F);
| ^
src/njs_encoding.c: In function ‘njs_text_encoder_encode_into’:
src/njs_encoding.c:169:27: note: ‘ctx.codepoint’ was declared here
169 | njs_unicode_decode_t ctx;
| ^
In function ‘njs_utf8_length’,
inlined from ‘njs_error_new’ at src/njs_error.c:39:14,
inlined from ‘njs_throw_error_va’ at src/njs_error.c:69:5:
src/njs_utf8.h:141:12: error: ‘buf’ may be used uninitialized [-Werror=maybe-uninitialized]
141 | return njs_utf8_stream_length(&ctx, p, len, 1, 1, NULL);
| ^
src/njs_utf8.c: In function ‘njs_throw_error_va’:
src/njs_utf8.c:354:1: note: by argument 2 of type ‘const u_char *’ to ‘njs_utf8_stream_length.constprop’ declared here
354 | njs_utf8_stream_length(njs_unicode_decode_t *ctx, const u_char *p, size_t len,
| ^
src/njs_error.c:61:14: note: ‘buf’ declared here
61 | u_char buf[NJS_MAX_ERROR_STR], *p;
| ^
lto1: all warnings being treated as errors
make[3]: *** [/tmp/ccCzf1An.mk:32: /tmp/cc3U6GC7.ltrans10.ltrans.o] Error 1
make[3]: *** Waiting for unfinished jobs....
lto1: all warnings being treated as errors
make[3]: *** [/tmp/ccCzf1An.mk:26: /tmp/cc3U6GC7.ltrans8.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Proposed changes
I found on Ubuntu ppc64el, where lto and O3 are used, gcc to fail with some missing initialization issues.
Checklist
Before creating a PR, run through this checklist and mark each as complete:
CONTRIBUTING
document