Created attachment 37902 [details] gcc6 --enable-default-pie causes hundreds of errors in test suite When building GCC6 weekly snapshot 20160306 and adding the --enable-default-pie to the configure script, hundreds of errors occur when running the test suite. Platform is X86_64 on Intel Xeon D1540 "Broadwell" Using glibc-2.23 with configure options: --prefix=/usr \ --disable-profile \ --enable-kernel=2.6.32 \ --enable-obsolete-rpc \ --enable-lock-elision=yes \ --enable-stackguard-randomization \ --enable-bind-now Using binutils-2_26-branch with configure options: --prefix=/usr \ --enable-shared \ --disable-werror \ --disable-gdb \ --with-system-zlib Using gcc-6-20160306 with configure options: --prefix=/usr \ --enable-languages=c,c++ \ --disable-multilib \ --disable-bootstrap \ --with-system-zlib \ --disable-libmpx \ --disable-libstdcxx-pch \ --enable-default-pie \ --enable-checking=release Attached is the test suite summary for gcc built with --enable-default-pie. The build without --enable-default-pie but all other configuration options being the same yielded only the 3 errors in PR ld/12365 of binutils 2.26 and these are false positives. There were also 2 libstdc++ errors that are marked "experimental" that occurred in both tests, so I am ignoring them.
When GCC is configured with --enable-default-pie, -fno-pic doesn't turn off PIC: [hjl@gnu-6 gcc]$ ./xgcc -B./ -S x.c -fno-pic x.c:2:3: error: #error foo # error foo ^~~~~ [hjl@gnu-6 gcc]$
(In reply to H.J. Lu from comment #1) > When GCC is configured with --enable-default-pie, -fno-pic doesn't > turn off PIC: > > [hjl@gnu-6 gcc]$ ./xgcc -B./ -S x.c -fno-pic > x.c:2:3: error: #error foo > # error foo > ^~~~~ > [hjl@gnu-6 gcc]$ It isn't a bug since PIC is off by default, but PIE is on by default, which also defines __PIC__, with --enable-default-pie.
But -fno-pic should turn off even the default -fpie or -fPIE (if you force it through configure option) and also make sure neither __PIC__ nor __PIE__ macros are defined.
(In reply to Jakub Jelinek from comment #3) > But -fno-pic should turn off even the default -fpie or -fPIE (if you force > it through configure option) and also make sure neither __PIC__ nor __PIE__ > macros are defined. There is a separate issue and should be tracked with a new bug report.
*** Bug 66400 has been marked as a duplicate of this bug. ***
They should be fixed on hjl/pr70150 branch in GCC git repo.
Created attachment 38007 [details] test suite summary I built hjl/pr70150 branch and while the prior test suite failures are gone, 6 new ones appeared. Full test suite summary is attached. Running target unix FAIL: g++.dg/ext/label13a.C -std=gnu++98 execution test FAIL: g++.dg/ext/label13a.C -std=gnu++98 scan-assembler _ZN1CC4Ev FAIL: g++.dg/ext/label13a.C -std=gnu++11 execution test FAIL: g++.dg/ext/label13a.C -std=gnu++11 scan-assembler _ZN1CC4Ev FAIL: g++.dg/ext/label13a.C -std=gnu++14 execution test FAIL: g++.dg/ext/label13a.C -std=gnu++14 scan-assembler _ZN1CC4Ev XPASS: g++.dg/tls/thread_local-order2.C -std=c++11 execution test XPASS: g++.dg/tls/thread_local-order2.C -std=c++14 execution test === g++ Summary === # of expected passes 103282 # of unexpected failures 6 # of unexpected successes 2 # of expected failures 285 # of unsupported tests 3674 /sources/gcc-build/gcc/testsuite/g++/../../xg++ version 6.0.0 20160317 (experim ental) (GCC)
(In reply to psturm from comment #7) > Created attachment 38007 [details] > test suite summary > > I built hjl/pr70150 branch and while the prior test suite failures are gone, > 6 new ones appeared. Full test suite summary is attached. > > Running target unix > FAIL: g++.dg/ext/label13a.C -std=gnu++98 execution test > FAIL: g++.dg/ext/label13a.C -std=gnu++98 scan-assembler _ZN1CC4Ev > FAIL: g++.dg/ext/label13a.C -std=gnu++11 execution test > FAIL: g++.dg/ext/label13a.C -std=gnu++11 scan-assembler _ZN1CC4Ev > FAIL: g++.dg/ext/label13a.C -std=gnu++14 execution test > FAIL: g++.dg/ext/label13a.C -std=gnu++14 scan-assembler _ZN1CC4Ev Do you get them without --enable-default-pie?
I didn't finish the full system build with --enable default-pie yet. I'll build it without next and let you know.
Yes, exact same errors when built without --enable-default-pie.
*** Bug 66402 has been marked as a duplicate of this bug. ***
Patches are posted at https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00929.html https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00995.html
(In reply to H.J. Lu from comment #12) > Patches are posted at > > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00929.html > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00995.html https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00929.html patch does not apply because it appears it conflicts with another change made for HPPA: In weekly snapshot 6-20160410: gcc/testsuite/gcc.dg/uninit-19.c /* { dg-warning "may be used uninitialized" "" { target { { nonpic } || { hppa*64*-*-* } } } 13 } */ /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic } || { hppa*64*-*-* } } } } 22 } */ patch is looking for: -/* { dg-warning "may be used uninitialized" "" { target nonpic } 13 } */ -/* { dg-warning "may be used uninitialized" "" { target { ! nonpic } } 22 } */
(In reply to psturm from comment #13) > (In reply to H.J. Lu from comment #12) > > Patches are posted at > > > > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00929.html > > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00995.html > > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00929.html patch does not > apply because it appears it conflicts with another change made for HPPA: Please try patches on hjl/pr70150 branch.
Tested with hjl/pr70150 branch and no unexpected errors using --enable-default-pie. However, when testing the same branch with both --enable-default-pie and --enable-default-ssp, a couple new failures did show up (in addition to the 11 expected failures): FAIL: gcc.target/i386/cleanup-1.c execution test FAIL: gcc.target/i386/cleanup-2.c execution test I am not sure whether this is relevant or not?
(In reply to psturm from comment #15) > Tested with hjl/pr70150 branch and no unexpected errors using > --enable-default-pie. > > However, when testing the same branch with both --enable-default-pie and > --enable-default-ssp, a couple new failures did show up (in addition to the > 11 expected failures): > > FAIL: gcc.target/i386/cleanup-1.c execution test > FAIL: gcc.target/i386/cleanup-2.c execution test > > I am not sure whether this is relevant or not? Do they fail with only --enable-default-ssp?
Yes, they do appear when only using --enable-default-ssp, so I don't think they are relevant.
(In reply to psturm from comment #17) > Yes, they do appear when only using --enable-default-ssp, so I don't think > they are relevant. I suggest you open a new bug report if you haven't done so.
H.J, Done. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70230 On a separate topic, do you know an Intel colleague named Kirill Shutemov? I am having a problem with a kernel warning about a pmd_set_huge failure and an ACPI warning on my Xeon D-1540 development system when I load the ixgbe driver. The driver guys told me to post on linux-mm and I did, but no reply just yet. It seems Kirill Shumetov is active in the kernel memory management and this is an issue manifesting on an Intel system (both CPU and 10g ethernet). If not him, do you know anyone else I can contact about this? Thanks, Paul ----- Original Message ----- From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: "psturm" <psturm@computervoice.com> Sent: Sunday, April 17, 2016 6:02:45 PM Subject: [Bug testsuite/70150] Additonal test failures with --enable-default-pie https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70150 --- Comment #18 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to psturm from comment #17) > Yes, they do appear when only using --enable-default-ssp, so I don't think > they are relevant. I suggest you open a new bug report if you haven't done so.
GCC 6.1 has been released.
GCC 6.3 is being released, adjusting target milestone.
GCC 6.4 is being released, adjusting target milestone.
Author: hjl Date: Tue Sep 25 12:25:44 2018 New Revision: 264565 URL: https://gcc.gnu.org/viewcvs?rev=264565&root=gcc&view=rev Log: Check pie_enabled target in PIC tests We need to check pie_enabled target in PIC tests to support GCC where PIE is enabled by default when configured with --enable-default-pie. PR testsuite/70150 * gcc.dg/20020312-2.c (dg-additional-options): Set to "-no-pie" for pie_enabled target. * gcc.dg/uninit-19.c: Check pie_enabled for PIC. * gcc.target/i386/pr34256.c: Likewise. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/20020312-2.c trunk/gcc/testsuite/gcc.dg/uninit-19.c trunk/gcc/testsuite/gcc.target/i386/pr34256.c
H.J. : Can you please update Known to work?
Created attachment 52287 [details] Fix testsuite issues with --enable-default-pie The following failure are seen in gcc-11.2 when building with --enable-default-pie: FAIL: gcc.target/i386/cet-sjlj-6a.c scan-assembler-times movq\\t.*buf\\\\+8 1 FAIL: gcc.target/i386/cet-sjlj-6a.c scan-assembler-times subq\\tbuf\\\\+8 1 FAIL: gcc.target/i386/cet-sjlj-6b.c scan-assembler-times movq\\t.*buf\\\\+16 1 FAIL: gcc.target/i386/cet-sjlj-6b.c scan-assembler-times subq\\tbuf\\\\+16 1 FAIL: gcc.target/i386/fentryname3.c scan-assembler 0x0f, 0x1f, 0x44, 0x00, 0x00 FAIL: gcc.target/i386/pr24414.c (test for excess errors) FAIL: gcc.target/i386/pr93492-3.c scan-assembler \\t.cfi_startproc\\n\\tendbr(32|64)\\n.*.LPFE1:\\n\\tnop\\n1:\\tcall\\t__fentry__\\n\\tret\\n FAIL: gcc.target/i386/pr93492-5.c scan-assembler \\t.cfi_startproc\\n.*.LPFE1:\\n\\tnop\\n1:\\tcall\\t__fentry__\\n\\tret\\n FAIL: gcc.target/i386/pr98482-1.c scan-assembler movabsq\\t\\\\\$__fentry__, %r10\\n\\tcall\\t\\\\*%r10 Adding -no-pie to dg-options only fixed pr24414.c. For the rest I added a "{ target { ! pie_enabled } }" to the failing tests, which may or may not be the proper solution...
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:f30f04b1fbd4b4e13a7535fad8e698c7b24db9b8 commit r13-6516-gf30f04b1fbd4b4e13a7535fad8e698c7b24db9b8 Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 13:57:19 2022 +0800 aarch64: testsuite: disable PIE for aapcs64 tests [PR70150] If GCC is built with --enable-default-pie, a lot of aapcs64 tests fail because relocation unsupported in PIE is used. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/aarch64/aapcs64/aapcs64.exp (additional_flags): Add -fno-pie -no-pie.
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:a1ccb4583dfaa267648110aa7da7275acc3000f8 commit r13-6517-ga1ccb4583dfaa267648110aa7da7275acc3000f8 Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 14:28:44 2022 +0800 aarch64: testsuite: disable PIE for tests with large code model [PR70150] These tests set large code model with -mcmodel=large or target pragma for AArch64. But if GCC is configured with --enable-default-pie, it triggers "sorry: unimplemented: code model large with -fpic". Disable PIE to make avoid the issue. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.dg/tls/pr78796.c (dg-additional-options): Add -fno-pie -no-pie for aarch64-*-*. * gcc.target/aarch64/pr63304_1.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr70120-2.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr78733.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr79041-2.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr94530.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr94577.c (dg-options): Add -fno-pie. * gcc.target/aarch64/reload-valid-spoff.c (dg-options): Add -fno-pie.
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:7e8a3dbbb26f66ce8ea60be48962022b5fb2ef55 commit r13-6518-g7e8a3dbbb26f66ce8ea60be48962022b5fb2ef55 Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 14:45:17 2022 +0800 aarch64: testsuite: disable PIE for fuse_adrp_add_1.c [PR70150] In PIE, symbol "fixed_regs" is addressed via GOT. It will break the scan-assembler pattern and cause test failure with --enable-default-pie. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/aarch64/fuse_adrp_add_1.c (dg-options): Add -fno-pie.
(In reply to Allan McRae from comment #25) > Created attachment 52287 [details] > Fix testsuite issues with --enable-default-pie > > The following failure are seen in gcc-11.2 when building with > --enable-default-pie: > > FAIL: gcc.target/i386/cet-sjlj-6a.c scan-assembler-times movq\\t.*buf\\\\+8 1 > FAIL: gcc.target/i386/cet-sjlj-6a.c scan-assembler-times subq\\tbuf\\\\+8 1 > FAIL: gcc.target/i386/cet-sjlj-6b.c scan-assembler-times movq\\t.*buf\\\\+16 > 1 > FAIL: gcc.target/i386/cet-sjlj-6b.c scan-assembler-times subq\\tbuf\\\\+16 1 > FAIL: gcc.target/i386/fentryname3.c scan-assembler 0x0f, 0x1f, 0x44, 0x00, > 0x00 > FAIL: gcc.target/i386/pr24414.c (test for excess errors) > FAIL: gcc.target/i386/pr93492-3.c scan-assembler > \\t.cfi_startproc\\n\\tendbr(32|64)\\n.*.LPFE1:\\n\\tnop\\n1: > \\tcall\\t__fentry__\\n\\tret\\n > FAIL: gcc.target/i386/pr93492-5.c scan-assembler > \\t.cfi_startproc\\n.*.LPFE1:\\n\\tnop\\n1:\\tcall\\t__fentry__\\n\\tret\\n > FAIL: gcc.target/i386/pr98482-1.c scan-assembler movabsq\\t\\\\\$__fentry__, > %r10\\n\\tcall\\t\\\\*%r10 > > Adding -no-pie to dg-options only fixed pr24414.c. For the rest I added a > "{ target { ! pie_enabled } }" to the failing tests, which may or may not be > the proper solution... You may want -fno-PIE. -fno-PIE (with "f") affects code generation, but "-no-pie" simply tells the linker not to link the executable as a PIE.
Hello Xi Ruoyao, Your 3 patches are also fixing the regressions in the gcc-12 branch. Do you plan on back-porting them on this release branch?
(In reply to Marc Poulhiès from comment #30) > Hello Xi Ruoyao, > > Your 3 patches are also fixing the regressions in the gcc-12 branch. Do you > plan on back-porting them on this release branch? Richard: is it allowed to backport them (or the entire https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613093.html series) for gcc-12?
(In reply to Xi Ruoyao from comment #31) > Richard: is it allowed to backport them (or the entire > https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613093.html series) for > gcc-12? Yeah, backporting is OK with me, thanks.
The releases/gcc-12 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:e8ee5a0b00dc7a7c25dd3264e9007f440457a791 commit r12-9699-ge8ee5a0b00dc7a7c25dd3264e9007f440457a791 Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 13:57:19 2022 +0800 aarch64: testsuite: disable PIE for aapcs64 tests [PR70150] If GCC is built with --enable-default-pie, a lot of aapcs64 tests fail because relocation unsupported in PIE is used. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/aarch64/aapcs64/aapcs64.exp (additional_flags): Add -fno-pie -no-pie. (cherry picked from commit f30f04b1fbd4b4e13a7535fad8e698c7b24db9b8)
The releases/gcc-12 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:b2d29f2622c215201cb415565ab4f18b738ca35c commit r12-9700-gb2d29f2622c215201cb415565ab4f18b738ca35c Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 14:28:44 2022 +0800 aarch64: testsuite: disable PIE for tests with large code model [PR70150] These tests set large code model with -mcmodel=large or target pragma for AArch64. But if GCC is configured with --enable-default-pie, it triggers "sorry: unimplemented: code model large with -fpic". Disable PIE to make avoid the issue. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.dg/tls/pr78796.c (dg-additional-options): Add -fno-pie -no-pie for aarch64-*-*. * gcc.target/aarch64/pr63304_1.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr70120-2.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr78733.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr79041-2.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr94530.c (dg-options): Add -fno-pie. * gcc.target/aarch64/pr94577.c (dg-options): Add -fno-pie. * gcc.target/aarch64/reload-valid-spoff.c (dg-options): Add -fno-pie. (cherry picked from commit a1ccb4583dfaa267648110aa7da7275acc3000f8)
The releases/gcc-12 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:5a21f78294624dd7166e1a25a57c805a759dc0d2 commit r12-9701-g5a21f78294624dd7166e1a25a57c805a759dc0d2 Author: Xi Ruoyao <xry111@xry111.site> Date: Sat Sep 24 14:45:17 2022 +0800 aarch64: testsuite: disable PIE for fuse_adrp_add_1.c [PR70150] In PIE, symbol "fixed_regs" is addressed via GOT. It will break the scan-assembler pattern and cause test failure with --enable-default-pie. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/aarch64/fuse_adrp_add_1.c (dg-options): Add -fno-pie. (cherry picked from commit 7e8a3dbbb26f66ce8ea60be48962022b5fb2ef55)
Two more fixes are pending review at https://inbox.sourceware.org/gcc-patches/20240506044542.102727-2-xry111@xry111.site/.
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:331f7d8a393af99afccdb2729d4ab45797fd7a86 commit r15-2869-g331f7d8a393af99afccdb2729d4ab45797fd7a86 Author: Xi Ruoyao <xry111@xry111.site> Date: Mon May 6 11:33:43 2024 +0800 i386: testsuite: Add -no-pie for pr113689-1.c [PR70150] For a --enable-default-pie build, using -fno-pic (for compiler) but not -no-pie (for linker) triggers some linker warnings counted as excess errors: /usr/bin/ld: /tmp/cc8MgxiR.o: warning: relocation in read-only section `.text.startup' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/i386/pr113689-1.c (dg-options): Add -no-pie.
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:8035619b7313d9503852e1c7c8c06cfddca4d648 commit r15-2870-g8035619b7313d9503852e1c7c8c06cfddca4d648 Author: Xi Ruoyao <xry111@xry111.site> Date: Mon May 6 11:39:14 2024 +0800 i386: testsuite: Adapt fentryname3.c for r14-811 change [PR70150] After r14-811 "call *nop@GOTPCREL(%rip)" is only generated with -mno-direct-extern-access even if --enable-default-pie. So the r13-1614 change to this file is not valid anymore. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/i386/fentryname3.c (dg-final): Revert r13-1614 change.
The releases/gcc-14 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:377c3e9a8b73b47a1211d43fee162179ee1f87e7 commit r14-10616-g377c3e9a8b73b47a1211d43fee162179ee1f87e7 Author: Xi Ruoyao <xry111@xry111.site> Date: Mon May 6 11:33:43 2024 +0800 i386: testsuite: Add -no-pie for pr113689-1.c [PR70150] For a --enable-default-pie build, using -fno-pic (for compiler) but not -no-pie (for linker) triggers some linker warnings counted as excess errors: /usr/bin/ld: /tmp/cc8MgxiR.o: warning: relocation in read-only section `.text.startup' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/i386/pr113689-1.c (dg-options): Add -no-pie. (cherry picked from commit 331f7d8a393af99afccdb2729d4ab45797fd7a86)
The releases/gcc-14 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:f5b3dae221e6e41ebd806f504d83012173737dab commit r14-10617-gf5b3dae221e6e41ebd806f504d83012173737dab Author: Xi Ruoyao <xry111@xry111.site> Date: Mon May 6 11:39:14 2024 +0800 i386: testsuite: Adapt fentryname3.c for r14-811 change [PR70150] After r14-811 "call *nop@GOTPCREL(%rip)" is only generated with -mno-direct-extern-access even if --enable-default-pie. So the r13-1614 change to this file is not valid anymore. gcc/testsuite/ChangeLog: PR testsuite/70150 * gcc.target/i386/fentryname3.c (dg-final): Revert r13-1614 change. (cherry picked from commit 8035619b7313d9503852e1c7c8c06cfddca4d648)