https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119751
Bug ID: 119751 Summary: There's a need to tidy up m2 subdirectories' contents Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: zbigniew2011 at gmail dot com Target Milestone: --- Consider following programming example: (* https://www.vajhoej.dk/arne/articles/m2.html *) MODULE CoEx; FROM STextIO IMPORT WriteString, WriteLn; FROM SYSTEM IMPORT ADDRESS, ADR; FROM COROUTINES IMPORT COROUTINE, NEWCOROUTINE, TRANSFER; VAR retctx : ADDRESS; PROCEDURE Run(); VAR dummy : ADDRESS; BEGIN WriteString('B'); WriteLn; TRANSFER(dummy, retctx); WriteString('D'); WriteLn; TRANSFER(dummy, retctx); END Run; CONST wrksiz = 102400; VAR runctx : COROUTINE; wrk : ARRAY [1..wrksiz] OF CHAR; BEGIN NEWCOROUTINE(Run, ADR(wrk), wrksiz, runctx); WriteString('A'); WriteLn; TRANSFER(retctx, runctx); WriteString('C'); WriteLn; TRANSFER(retctx, runctx); WriteString('E'); WriteLn; END CoEx. Compilation attempt with 'gm2 -g coex.mod -o coex' will return error messages: coex.mod:8:24: error: In program module 'CoEx': unknown symbol 'COROUTINE' 8 | FROM COROUTINES IMPORT COROUTINE, NEWCOROUTINE, TRANSFER; | ^~~~~~~~~ coex.mod:8:35: error: unknown symbol 'NEWCOROUTINE' 8 | FROM COROUTINES IMPORT COROUTINE, NEWCOROUTINE, TRANSFER; | ^~~~~~~~~~~~ coex.mod:8:49: error: unknown symbol 'TRANSFER' 8 | FROM COROUTINES IMPORT COROUTINE, NEWCOROUTINE, TRANSFER; | ^~~~~~~~ coex.mod:44:9: error: the following unknown symbols in module 'CoEx' were locally used: NEWCOROUTINE, COROUTINE and TRANSFER 44 | END CoEx. | ^ /usr/lib64/gcc/x86_64-slackware-linux/14.2.0/m2/m2pim/def:36:15: error: In definition module 'COROUTINES': the symbols are unknown at the end of module 'CoEx' when requested by another modules import (symbols have not been exported by the appropriate definition module) 36 | END COROUTINES. | ^ Why? Because the mentioned /usr/lib64/gcc/x86_64-slackware-linux/14.2.0/m2/m2pim/COROUTINES.def seems to be out of place. It doesn't even have accompanying COROUTINES.mod anymore. Only after I renamed it with 'mv COROUTINES.def COROUTINES.def.old' the compilation went fine, because there's valid COROUTINES module in the sibling directory /usr/lib64/gcc/x86_64-slackware-linux/14.2.0/m2/m2iso. So there is a conflict. The one in 'm2pim' looks like some 'leftover'. On GCC 12.2.0 (tested on other machine, ARM32-based) there's even worse situation with that, because that conflicting COROUTINES.def in 'm2pim' has its companion COROUTINES.mod there (with partial contents) and it's compiled into library, which seems to be conflicting. So after renaming both files to *.old to get them 'out of the sight', although compilation attempt doesn't return these errors anymore, but unfortunately it also reports: coex.mod:46:1: error: the file containing the definition module ‘COROUTINES’ cannot be found (although it is present in /usr/lib/gcc/arm-linux-gnueabihf/12/m2/m2iso) There's a need to browse Modula 2 related directories more closely, is it just single such occurrence of "duplicate module", or there's more requiring clean-up. Of course COROUTINES.* should be removed from 'm2pim' completely, when already having proper copy in 'm2iso'.