https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102342
Bug ID: 102342 Summary: gm2 testsuite failures for non-default multilib Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: unassigned at gcc dot gnu.org Reporter: ro at gcc dot gnu.org Target Milestone: --- When running the gm2 testsuite for non-default multilibs (e.g. x86_64-pc-linux-gnu for the default (-m64) and -m32, or i386-pc-solaris2.11 for the default -m32 and -m64), many tests for the non-default multilib FAIL, e.g. FAIL: gm2/calling-c/datatypes/unbounded/run/pass/m.mod compilation, -g UNRESOLVED: gm2/calling-c/datatypes/unbounded/run/pass/m.mod execution, -g (link failed) /vol/gcc/bin/gld-2.35: i386:x86-64 architecture of input file `/tmp/ccTE5Kph.a(c.o)' is incompatible with i386 output While the main testcase is correctly compiled with the necessary multilib flags (-m32 here), additional objects (c.o here) are not. The common problem is that those compilations are done manually with an explicit set output [exec ${XGCC} -B[file dirname $rootme]/gcc -g -c $srcdir/gm2/calling-c/datatypes/unbounded/run/pass/c.c -o c.o] in gm2.exp, not taking multilib flags into account. There are two ways to do this correctly. One is to do the compilation with target_compile like this: -- gm2.exp 2021-07-08 14:07:03.408049578 +0000 +++ m2.exp 2021-09-15 11:50:06.344101169 +0000 @@ -29,14 +29,9 @@ set gm2src ${srcdir}/../m2 gm2_init_pim "${srcdir}/gm2/calling-c/datatypes/unbounded/run/pass" - -set XGCC [lookfor_file $rootme xgcc]; - gm2_link_with "c.o -lm2pim -lm2iso -lpthread" - -set output [exec rm -f c.o] -set output [exec ${XGCC} -B[file dirname $rootme]/gcc -g -c $srcdir/gm2/calling-c/datatypes/unbounded/run/pass/c.c -o c.o] +set output [target_compile $srcdir/$subdir/c.c c.o object "-g"] foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] { # If we're only testing specific files and this isn't one of them, skip it. @@ -47,5 +42,3 @@ gm2_target_compile $srcdir/$subdir/m.mod m.o object "-g" gm2-torture-execute $testcase "" "pass" } - -set output [exec rm -f c.o] The other, canonical one, is to use dg-additonal-sources instead, avoiding the need for special driver files. The above patch fixed the issue on i386-pc-solaris2.11 with -m32/-m64.