From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1B61C3854816; Wed, 5 May 2021 11:24:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B61C3854816 From: "joey.dumont at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/100431] New: Fixes to enable compiling with -Werror=format-security Date: Wed, 05 May 2021 11:24:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joey.dumont at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 11:24:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100431 Bug ID: 100431 Summary: Fixes to enable compiling with -Werror=3Dformat-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=3D50757&action=3Dedit Patch to fix -Werror=3Dformat-security errors As mentioned in bug 100207, Arch Linux recently starting compiling its pack= ages with the -Werror=3Dformat-security option. In this bug report, I attach two patches that enable compiling gcc with that flag.=20 The first patch expliclity adds "%s" format strings to functions that pass = its arguments to printf.=20 However, during my testing, I found that libgcc uses -Wno-format in its CFL= AGS, 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 li= ke this:=20 /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-incl= ude=20 -fno-checking -g -march=3Dx86-64 -mtune=3Dgeneric -O2 -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3D2,-D_GLIBCXX_ASSERTIONS -Wformat -Werror=3Dformat-s= ecurity -fstack-clash-protection -fcf-protection -m32 -O2 -g -march=3Dx86-64 -mtune=3Dgeneric -O2 -fno-plt -fexceptions=20=20=20=20=20=20=20=20 -Wp,-D_FORTIFY_SOURCE=3D2,-D_GLIBCXX_ASSERTIONS -Wformat -Werror=3Dformat-security -fstack-clash-protection -fcf-protection -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=3Dformat-diag -Wno-format -Wstrict-prototypes -Wmissing-prototyp= es -Wno-error=3Dformat-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_SY= MVER -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=3Dhidden -DHIDE_EXPORTS cc1: error: =E2=80=98-Wformat-security=E2=80=99 ignored without =E2=80=98-W= format=E2=80=99 [-Werror=3Dformat-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, a= nd I can't see where.=