[Bug bootstrap/100431] Fixes to enable compiling with -Werror=format-security
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431 --- Comment #5 from Joey Dumont --- I just started looking at these other cases (for some reason I didn't see them in my initial compilation), but I am not sure what format specifiers should be used. Are the format specifiers used by __gcc_tdiag__ documented somewhere? I tried grepping through the source, but couldn't find anything.
[Bug bootstrap/100431] Fixes to enable compiling with -Werror=format-security
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431 --- Comment #3 from Joey Dumont --- I had tested with a simple printf: #include #ifndef N_ # define N_(msgid) msgid #endif int main(int argc, char* argv[]) { printf(N_("use of C++23 % integer constant")); printf(N_("use of C++23 %%> integer constant")); return 0; } which prints the same thing with or without the "%s" format string. I've been trying to trace where pfile->cb.diagnostic is set to see how the output is actually processed, but I haven't found it yet. Thanks for the feedback!
[Bug bootstrap/100431] Fixes to enable compiling with -Werror=format-security
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431 --- Comment #1 from Joey Dumont --- Created attachment 50758 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50758&action=edit Workaround for -Wno-format flag injected during build process.
[Bug bootstrap/100431] New: Fixes to enable compiling with -Werror=format-security
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100431 Bug ID: 100431 Summary: Fixes to enable compiling with -Werror=format-security Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: joey.dumont at gmail dot com Target Milestone: --- Created attachment 50757 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50757&action=edit Patch to fix -Werror=format-security errors As mentioned in bug 100207, Arch Linux recently starting compiling its packages with the -Werror=format-security option. In this bug report, I attach two patches that enable compiling gcc with that flag. The first patch expliclity adds "%s" format strings to functions that pass its arguments to printf. However, during my testing, I found that libgcc uses -Wno-format in its CFLAGS, making the flags inconsistent. It seemed that adding the --enable-build-format-warnings should remove the -Wno-format option from the compile flags, but it didn't seem to work as expected, leading to errors like this: /build/gcc/src/gcc-build/./gcc/xgcc -B/build/gcc/src/gcc-build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include -fno-checking -g -march=x86-64 -mtune=generic -O2 -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -m32 -O2 -g -march=x86-64 -mtune=generic -O2 -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. -I../../.././gcc -I/build/gcc/src/gcc/libgcc -I/build/gcc/src/gcc/libgcc/. -I/build/gcc/src/gcc/libgcc/../gcc -I/build/gcc/src/gcc/libgcc/../include -I/build/gcc/src/gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /build/gcc/src/gcc/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS cc1: error: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Werror=format-security] I am not sure how these flags are set. In any case, the second patch works around the issue by changing the --enable-build-format-warnings to add -Wno-format-security to the flags, making the flags consistent again. I think the first patch is a genuine fix, but I'm not sure about the second. I would have expected --enable-build-format-warnings to entirely remove the -Wno-format option, but it seems to stick somewhere in the build process, and I can't see where.
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 --- Comment #11 from Joey Dumont --- I can confirm that this revision fixes the issue. I'll try to lookout for the gcc-9 version where this will be released. Thank you!
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 Joey Dumont changed: What|Removed |Added Version|9.1.0 |9.2.0 --- Comment #7 from Joey Dumont --- I realized I made a silly mistake after I posted this. I was meant to try this version for the target compiler, not the host compiler. I successfully built the target compiler (mips64-elf) with r273174. I changed the affected version to 9.2.0, as 9.1.0 was my host compiler, not the target compiler. I can test with 9.2.1 and other versions, if necessary.
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 --- Comment #8 from Joey Dumont --- I realized I made a silly mistake after I posted this. I was meant to try this version for the target compiler, not the host compiler. I successfully built the target compiler (mips64-elf) with r273174. I changed the affected version to 9.2.0, as 9.1.0 was my host compiler, not the target compiler. I can test with 9.2.1 and other versions, if necessary.
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 --- Comment #6 from Joey Dumont --- Sorry for the delay, had trouble setting up the test toolchain. >From what I can see, this does not solve the issue. In fact, the generated paralle_settings.ii is identical to the one generated before. To test this, I compiled the d57faea9337 commit of gcc-git, which corresponds to r273174 according to this commit message. I configured it with --prefix=~/software-test/ and removed options with references to system directories in the options listed above. Otherwise I kept the rest the same. To compile the cross-compiler, I exported PATH and LD_LIBRARY_PATH, like so export PATH="/home/valandil/software-test/bin:${PATH}" export LD_LIBRARY_PATH="/home/valandil/software-test/lib:${PATH}" and did the rest as usual.
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 --- Comment #4 from Joey Dumont --- Created attachment 46831 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46831&action=edit Preprocessed parallel_settings.cc
[Bug target/91474] Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 --- Comment #2 from Joey Dumont --- How do I pass -save-temps to make? Is there a environment variable that changes the gcc command options?
[Bug c++/91474] New: Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91474 Bug ID: 91474 Summary: Internal compiler error when building mabi=32 mips64-elf cross-compiler: segfault in parallel_settings.cc Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: joey.dumont at gmail dot com CC: joey.dumont at gmail dot com Target Milestone: --- Host: x86_64-pc-linux-gnu Target: mips64-elf Build: x86_64-pc-linux-gnu Created attachment 46722 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46722&action=edit Patch to enable the 32-bit ABI Let me preface this by saying that this is my first bug report, and I could not find information on what to submit for issues with cross-compilers. Let me know what information you need and I'll gladly provide it. When trying to build a gcc-9.2.0 mips64-elf cross-compiler with gcc-9.1.0, I get an internal compiler error when trying to compile `libstdc++-v3/src/c++98/parallel_settings.cc`: ``` libtool: compile: /home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/./gcc/xgcc -shared-libgcc -B/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/./gcc -nostdinc++ -L/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/src -L/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/src/.libs -L/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/libsupc++/.libs -B/usr/mips64-elf/bin/ -B/usr/mips64-elf/lib/ -isystem /usr/mips64-elf/include -isystem /usr/mips64-elf/sys-include -mabi=32 -I/home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/../libgcc -I/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/include/mips64-elf -I/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/include -I/home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/libsupc++ -std=gnu++98 -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=parallel_settings.lo -g -O2 -mabi=32 -D_GLIBCXX_PARALLEL -c /home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/src/c++98/parallel_settings.cc -o parallel_settings.o during RTL pass: split2 /home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/src/c++98/parallel_settings.cc: In function '(static initializers for /home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/src/c++98/parallel_settings.cc)': /home/valandil/software/n64-dev/mips64-elf-gcc/src/gcc-9.2.0/libstdc++-v3/src/c++98/parallel_settings.cc:42:1: internal compiler error: Segmentation fault 42 | } | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. make[9]: *** [Makefile:912: parallel_settings.lo] Error 1 make[9]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/src/c++98' make[8]: *** [Makefile:730: all-recursive] Error 1 make[8]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3/src' make[7]: *** [Makefile:562: all-recursive] Error 1 make[7]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3' make[6]: *** [Makefile:487: all] Error 2 make[6]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/32/libstdc++-v3' make[5]: *** [Makefile:855: multi-do] Error 1 make[5]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/libstdc++-v3' make[4]: *** [Makefile:823: all-multi] Error 2 make[4]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/libstdc++-v3' make[3]: *** [Makefile:562: all-recursive] Error 1 make[3]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/libstdc++-v3' make[2]: *** [Makefile:487: all] Error 2 make[2]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc/mips64-elf/libstdc++-v3' make[1]: *** [Makefile:11232: all-target-libstdc++-v3] Error 2 make[1]: Leaving directory '/home/valandil/software/n64-dev/mips64-elf-gcc/src/build-gcc' make: *** [Makefile:951: all] Error 2 ``` Here's the output of `gcc -v`: ``` $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/g