lto: Add a test for PR ld/32083
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
Add a test for PR ld/32083 and xfail the test if GCC doesn't have the fix
for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361
PR ld/32083
* testsuite/ld-plugin/common-2a.c: New file.
* testsuite/ld-plugin/common-2b.c: Likewise.
* testsuite/ld-plugin/lto.exp: Run PR ld/32083 test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
ld/testsuite/ld-plugin/common-2a.c | 11 +++++++++++
ld/testsuite/ld-plugin/common-2b.c | 6 ++++++
ld/testsuite/ld-plugin/lto.exp | 31 ++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/common-2a.c
create mode 100644 ld/testsuite/ld-plugin/common-2b.c
Comments
On Fri, Aug 16, 2024 at 3:48 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Add a test for PR ld/32083 and xfail the test if GCC doesn't have the fix
> for
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361
>
> PR ld/32083
> * testsuite/ld-plugin/common-2a.c: New file.
> * testsuite/ld-plugin/common-2b.c: Likewise.
> * testsuite/ld-plugin/lto.exp: Run PR ld/32083 test.
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
> ld/testsuite/ld-plugin/common-2a.c | 11 +++++++++++
> ld/testsuite/ld-plugin/common-2b.c | 6 ++++++
> ld/testsuite/ld-plugin/lto.exp | 31 ++++++++++++++++++++++++++++++
> 3 files changed, 48 insertions(+)
> create mode 100644 ld/testsuite/ld-plugin/common-2a.c
> create mode 100644 ld/testsuite/ld-plugin/common-2b.c
>
> diff --git a/ld/testsuite/ld-plugin/common-2a.c b/ld/testsuite/ld-plugin/common-2a.c
> new file mode 100644
> index 00000000000..fccfca72868
> --- /dev/null
> +++ b/ld/testsuite/ld-plugin/common-2a.c
> @@ -0,0 +1,11 @@
> +#include <stdio.h>
> +
> +int foo;
> +
> +int main()
> +{
> + if (foo == 0)
> + printf ("PASS\n");
> +
> + return 0;
> +}
> diff --git a/ld/testsuite/ld-plugin/common-2b.c b/ld/testsuite/ld-plugin/common-2b.c
> new file mode 100644
> index 00000000000..c014c673f74
> --- /dev/null
> +++ b/ld/testsuite/ld-plugin/common-2b.c
> @@ -0,0 +1,6 @@
> +int foo;
> +
> +void
> +func (void)
> +{
> +}
> diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
> index bbd68407edc..7781c56fae5 100644
> --- a/ld/testsuite/ld-plugin/lto.exp
> +++ b/ld/testsuite/ld-plugin/lto.exp
> @@ -238,6 +238,23 @@ set lto_link_tests [list \
> {} \
> "libdefinition-1.a" \
> ] \
> + [list \
> + "Build common-2a.o" \
> + "" \
> + "-O2 -fcommon -flto $lto_no_fat" \
> + {common-2a.c} \
> + {} \
> + "" \
> + "c" \
> + ] \
> + [list \
> + "Build libcommon-2.a" \
> + "$plug_opt" \
> + "-O2 -fcommon -flto $lto_no_fat" \
> + {common-2b.c} \
> + {} \
> + "libcommon-2.a" \
> + ] \
> ]
>
> if { [at_least_gcc_version 10 0] && [check_lto_shared_available] } {
> @@ -880,6 +897,20 @@ run_cc_link_tests $lto_link_tests
> # by some elf tests besides shared libs tests. So, always compile them.
> run_cc_link_tests $lto_compile_elf_tests
>
> +# GCC may not have the fix for:
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361
> +set exec_output [run_host_cmd "$CC_FOR_TARGET" \
> + "-O2 -fcommon -flto -o tmpdir/common-2 \
> + tmpdir/common-2a.o tmpdir/libcommon-2.a \
> + tmpdir/libcommon-2.a"]
> +if [string match "" $exec_output] then {
> + pass "PR ld/32083"
> +} elseif { [ regexp "lto1: fatal error: multiple prevailing defs for 'func'" $exec_output ] } {
> + xfail "PR ld/32083"
> +} else {
> + fail "PR ld/32083"
> +}
> +
> # Restrict these to ELF targets that support shared libs and PIC.
> if { [is_elf_format] && [check_lto_shared_available] } {
> run_cc_link_tests $lto_link_elf_tests
> --
> 2.46.0
>
GCC 15 has been fixed by
https://gcc.gnu.org/git?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998
I am checking in this test.
--
H.J.
new file mode 100644
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int foo;
+
+int main()
+{
+ if (foo == 0)
+ printf ("PASS\n");
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,6 @@
+int foo;
+
+void
+func (void)
+{
+}
@@ -238,6 +238,23 @@ set lto_link_tests [list \
{} \
"libdefinition-1.a" \
] \
+ [list \
+ "Build common-2a.o" \
+ "" \
+ "-O2 -fcommon -flto $lto_no_fat" \
+ {common-2a.c} \
+ {} \
+ "" \
+ "c" \
+ ] \
+ [list \
+ "Build libcommon-2.a" \
+ "$plug_opt" \
+ "-O2 -fcommon -flto $lto_no_fat" \
+ {common-2b.c} \
+ {} \
+ "libcommon-2.a" \
+ ] \
]
if { [at_least_gcc_version 10 0] && [check_lto_shared_available] } {
@@ -880,6 +897,20 @@ run_cc_link_tests $lto_link_tests
# by some elf tests besides shared libs tests. So, always compile them.
run_cc_link_tests $lto_compile_elf_tests
+# GCC may not have the fix for:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361
+set exec_output [run_host_cmd "$CC_FOR_TARGET" \
+ "-O2 -fcommon -flto -o tmpdir/common-2 \
+ tmpdir/common-2a.o tmpdir/libcommon-2.a \
+ tmpdir/libcommon-2.a"]
+if [string match "" $exec_output] then {
+ pass "PR ld/32083"
+} elseif { [ regexp "lto1: fatal error: multiple prevailing defs for 'func'" $exec_output ] } {
+ xfail "PR ld/32083"
+} else {
+ fail "PR ld/32083"
+}
+
# Restrict these to ELF targets that support shared libs and PIC.
if { [is_elf_format] && [check_lto_shared_available] } {
run_cc_link_tests $lto_link_elf_tests