modula3 / cm3

Critical Mass Modula-3
http://modula3.github.io/cm3/
Other
134 stars 25 forks source link

How to use the "native" backend? #1182

Open mikanystrom opened 4 months ago

mikanystrom commented 4 months ago

Does anyone out there know how we are supposed to use the "native" backend?

I am finding that my old code was not working with the C-based backend, because something goes wrong when I pass data from M3 to C.

I bootstrapped using an old CM3 and do-cm3-all.py

This seems to build everything using the C backend.

Then I built m3cc using the C-based backend.

This had the problem that when I try to build code using the native backend, it "sometimes" has issues linking against the CM3 libs generated by the C backend.

So it seems that the CM3 libs have to be rebuilt using the native backend if one wants to build one's own programs with the native backend.

Is this expected behavior?

To accomplish this, I had to change pylib.py:

diff --git i/scripts/python/pylib.py w/scripts/python/pylib.py index e6e45000d..faa11b3a3 100755 --- i/scripts/python/pylib.py +++ w/scripts/python/pylib.py @@ -612,8 +612,8 @@ Target = Target or getenv("CM3_TARGET") or Host # _CBackend = "c" in LowercaseArgv or "+c" in LowercaseArgv or TargetOnlyHasCBackend(Target)

-if _CBackend:

(Maybe there is a better way?)

And then I can rebuild all the CM3 libs using the native backend.

Now things actually work pretty well...!

Any comments from the mailing list?

I can try to make a small example of a lib built with the C backend that fails miserably when linking against native code.

I am seeing this ...

/scc406110> /nfs/site/home/mnystroe/char8/m3utils-3/mscheme/sstubgen/program/AMD64_LINUX/sstubgen sstubgen: ../src/time/POSIX/DatePosixC.c:62: DatePosix__FromTime: Assertion `zone == Local || zone == UTC' failed. Abort (core dumped)

Using host libthread_db library "/lib64/libthread_db.so.1". sstubgen: ../src/time/POSIX/DatePosixC.c:62: DatePosix__FromTime: Assertion `zone == Local || zone == UTC' failed.

Program received signal SIGABRT, Aborted. 0x00002aaaab73a0c7 in raise () from /lib64/libc.so.6 Missing separate debuginfos, use: zypper install glibc-debuginfo-2.22-114.22.1.x86_64 (gdb) where

0 0x00002aaaab73a0c7 in raise () from /lib64/libc.so.6

1 0x00002aaaab73b49a in abort () from /lib64/libc.so.6

2 0x00002aaaab733016 in __assert_fail_base () from /lib64/libc.so.6

3 0x00002aaaab7330c2 in __assert_fail () from /lib64/libc.so.6

4 0x000000000070e3c3 in DatePosix__FromTime (t=1717465520.698544, zone=140737488341680, date=0x7fffffffc9d0) at ../src/time/POSIX/DatePosixC.c:62

5 0x000000000070dbf6 in Date__FromTime (_result_L_50=0x0, t_L_51=1717465520.698544, z_L_52=0x7fffffffca80 "\260\312\377\377\377\177") at ../src/time/POSIX/DatePosix.m3:29

6 0x00000000004843a2 in FinDate__FromTime (M3_CtKayy_t=<error reading variable: inner value printing not implemented for language "Auto">,

M3_Ab1PrR_zone=<error reading variable: inner value printing not implemented for language "Auto">, M3_BGtbSH__result=<error reading variable: inner value printing not implemented for language "Auto">)
at ../src/FinDate.m3:190

7 0x00000000004843f6 in FinDate__Today (M3_Ab1PrR_zone=<error reading variable: inner value printing not implemented for language "Auto">,

M3_BGtbSH__result=<error reading variable: inner value printing not implemented for language "Auto">) at ../src/FinDate.m3:186

8 0x0000000000484d70 in FinDate_M3 (M3_AcxOUs_mode=<error reading variable: inner value printing not implemented for language "Auto">) at ../src/FinDate.m3:137

9 0x00000000006e8620 in RTLinker__RunMainBody (m_L_92=0xa58680 ) at ../src/runtime/common/RTLinker.m3:409

10 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa58a80 ) at ../src/runtime/common/RTLinker.m3:389

11 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa58460 ) at ../src/runtime/common/RTLinker.m3:389

12 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa57fc0 ) at ../src/runtime/common/RTLinker.m3:389

13 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa536c0 ) at ../src/runtime/common/RTLinker.m3:389

14 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa53580 ) at ../src/runtime/common/RTLinker.m3:389

15 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cd80 ) at ../src/runtime/common/RTLinker.m3:389

16 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cc00 ) at ../src/runtime/common/RTLinker.m3:389

17 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cac0 ) at ../src/runtime/common/RTLinker.m3:389

18 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4c960 ) at ../src/runtime/common/RTLinker.m3:389

19 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4c7a0 ) at ../src/runtime/common/RTLinker.m3:389

20 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4ba40 ) at ../src/runtime/common/RTLinker.m3:389

21 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4b7c0 ) at ../src/runtime/common/RTLinker.m3:389

22 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa50d60 ) at ../src/runtime/common/RTLinker.m3:389

23 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa50ca0 ) at ../src/runtime/common/RTLinker.m3:389

24 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa3e9c0 ) at ../src/runtime/common/RTLinker.m3:389

25 0x00000000006e7316 in RTLinker__AddUnitI (m_L_95=0xa3e9c0 ) at ../src/runtime/common/RTLinker.m3:116

26 0x00000000006e7433 in RTLinker__AddUnit (b_L_83=0x418f93 ) at ../src/runtime/common/RTLinker.m3:125

27 0x00000000004183f8 in main (argc=1, argv=0x7fffffffd698, envp=0x7fffffffd6a8) at _m3main.cpp:53

(gdb)

VictorMiasnikov commented 4 months ago

( possible duplicate)

Do You see Rodney branch?

And I sent some details by e-mail. Message received?

mikanystrom commented 4 months ago

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated into the master?

VictorMiasnikov commented 4 months ago

I think that best ask Rodney04.06.2024, 19:11, "Mika Nyström" @.***>: Yes I saw your emails. No I haven't tried Rodney's branch. If there are good fixes on the Rodney branch, why aren't they integrated into the master?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

RodneyBates commented 4 months ago

I have long thought I had merged all my changes (first committed on branch rodney-new) long ago.  After Victor asked for them, I did a further check and it looked to me like they were there in the head.

I have struggled greatly over merging with git in past.  One realization that has come to be more recently is that git's so-called "remotes" aren't remote, they are local.  But rather local copies of something that is remote, whose identity is stored with the local copy, and there is some git command (I've forgotten its name) in the local repo that will bring them\ "remotes" up-to-date with any changes made since to the original.  This realization has cleared up some amount of confusion on my part, but it looks like I may be still confused about git.

I could well have made mistakes twice on this.  Apparently Victor believes so.

As I remember, the process I had finally chosen was to do a rebase that brought github head changes into my rodney-new branch on my computer. Then push rodney-new to github, which triggers testing in rodney-new on github.  Then if that's clean, do something or other to move that into the head, quickly before more changes came into the head on github.

Is "master" the right branch on github to try to get updated?

I would welcome any advice on what if anything is needed to get this resolved.

On 6/4/24 11:11, Mika Nyström wrote:

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated into the master?

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2147915550, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNFUIFBT4MZEYRZIU4LZFXRMNAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHEYTKNJVGA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

mikanystrom commented 4 months ago

I have to admit git can confuse me, too, at times.

Here is what we see right now:

[image: RodneyAhead.png]

On Tue, Jun 4, 2024 at 1:31 PM Rodney M. Bates @.***> wrote:

I have long thought I had merged all my changes (first committed on branch rodney-new) long ago. After Victor asked for them, I did a further check and it looked to me like they were there in the head.

I have struggled greatly over merging with git in past. One realization that has come to be more recently is that git's so-called "remotes" aren't remote, they are local. But rather local copies of something that is remote, whose identity is stored with the local copy, and there is some git command (I've forgotten its name) in the local repo that will bring them\ "remotes" up-to-date with any changes made since to the original. This realization has cleared up some amount of confusion on my part, but it looks like I may be still confused about git.

I could well have made mistakes twice on this. Apparently Victor believes so.

As I remember, the process I had finally chosen was to do a rebase that brought github head changes into my rodney-new branch on my computer. Then push rodney-new to github, which triggers testing in rodney-new on github. Then if that's clean, do something or other to move that into the head, quickly before more changes came into the head on github.

Is "master" the right branch on github to try to get updated?

I would welcome any advice on what if anything is needed to get this resolved.

On 6/4/24 11:11, Mika Nyström wrote:

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated into the master?

— Reply to this email directly, view it on GitHub < https://github.com/modula3/cm3/issues/1182#issuecomment-2147915550>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABSVZNFUIFBT4MZEYRZIU4LZFXRMNAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHEYTKNJVGA>.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2148366510, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKYNJLMABYX76WYZPY6KJTZFYPYXAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM3DMNJRGA . You are receiving this because you authored the thread.Message ID: @.***>

mikanystrom commented 4 months ago

Ah images not supported. Drat.

For branch "rodney-new", github says

This branch is 23 commits ahead of, 37 commits behind master.

see

https://github.com/modula3/cm3/tree/rodney-new

VictorMiasnikov commented 4 months ago

( I answer by e-mail. I will fix formatting tomorrow)((} Is "master" the right branch on github to try to get updated?))Yes, master is right branch 04.06.2024, 23:31, "Rodney M. Bates" @.***>: I have long thought I had merged all my changes (first committed on branch rodney-new)

long ago.  After Victor asked for them, I did a further check and it looked to me

like they were there in the head.

I have struggled greatly over merging with git in past.  One realization

that has come to be more recently is that git's so-called "remotes" aren't remote,

they are local.  But rather local copies of something that is remote, whose identity

is stored with the local copy, and there is some git command (I've forgotten its name) in

the local repo that will bring them\ "remotes" up-to-date with any changes made since to the

original.  This realization has cleared up some amount of confusion on my part, but

it looks like I may be still confused about git.

I could well have made mistakes twice on this.  Apparently Victor believes so.

As I remember, the process I had finally chosen was to do a rebase that brought

github head changes into my rodney-new branch on my computer. Then push rodney-new to

github, which triggers testing in rodney-new on github.  Then if that's clean,

do something or other to move that into the head, quickly before more changes

came into the head on github.

Is "master" the right branch on github to try to get updated?

I would welcome any advice on what if anything is needed to get this resolved.

On 6/4/24 11:11, Mika Nyström wrote:

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated into the master?

Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2147915550, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNFUIFBT4MZEYRZIU4LZFXRMNAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHEYTKNJVGA.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

VictorMiasnikov commented 4 months ago

I have add images by Web interface of GitHub some time ago ( as small remark)04.06.2024, 23:37, "Mika Nyström" @.***>: Ah images not supported. Drat. For branch "rodney-new", github says This branch is 23 commits ahead of, 37 commits behind master. see https://github.com/modula3/cm3/tree/rodney-new

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

VictorMiasnikov commented 4 months ago

As small remark: yes, yes we should synchronize all useful branches as quick as possible.04.06.2024, 23:36, "Mika Nyström" @.***>: I have to admit git can confuse me, too, at times.

Here is what we see right now:

[image: RodneyAhead.png]

On Tue, Jun 4, 2024 at 1:31 PM Rodney M. Bates @.***>

wrote:

I have long thought I had merged all my changes (first committed on branch

rodney-new)

long ago. After Victor asked for them, I did a further check and it

looked to me

like they were there in the head.

I have struggled greatly over merging with git in past. One realization

that has come to be more recently is that git's so-called "remotes" aren't

remote,

they are local. But rather local copies of something that is remote,

whose identity

is stored with the local copy, and there is some git command (I've

forgotten its name) in

the local repo that will bring them\ "remotes" up-to-date with any changes

made since to the

original. This realization has cleared up some amount of confusion on my

part, but

it looks like I may be still confused about git.

I could well have made mistakes twice on this. Apparently Victor believes

so.

As I remember, the process I had finally chosen was to do a rebase that

brought

github head changes into my rodney-new branch on my computer. Then push

rodney-new to

github, which triggers testing in rodney-new on github. Then if that's

clean,

do something or other to move that into the head, quickly before more

changes

came into the head on github.

Is "master" the right branch on github to try to get updated?

I would welcome any advice on what if anything is needed to get this

resolved.

On 6/4/24 11:11, Mika Nyström wrote:

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated

into the master?

Reply to this email directly, view it on GitHub <

https://github.com/modula3/cm3/issues/1182#issuecomment-2147915550>, or

unsubscribe <

https://github.com/notifications/unsubscribe-auth/ABSVZNFUIFBT4MZEYRZIU4LZFXRMNAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHEYTKNJVGA>.

You are receiving this because you are subscribed to this thread.Message

ID: @.***>

Reply to this email directly, view it on GitHub

https://github.com/modula3/cm3/issues/1182#issuecomment-2148366510, or

unsubscribe

https://github.com/notifications/unsubscribe-auth/ABKYNJLMABYX76WYZPY6KJTZFYPYXAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM3DMNJRGA

.

You are receiving this because you authored the thread.Message ID:

@.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

RodneyBates commented 4 months ago

On 6/4/24 15:37, Mika Nyström wrote:

Ah images not supported. Drat.

For branch "rodney-new", github says

This branch is 23 commits ahead of https://github.com/modula3/cm3/compare/master...rodney-new, 37 commits behind https://github.com/modula3/cm3/compare/rodney-new...master master.

Ah, this -------^ at least shows me what is missing from master. None of it sounds from the titles likely to affect the build process.

see

https://github.com/modula3/cm3/tree/rodney-new

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2148375919, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNBC3ZJ4FF3GIWMUHUTZFYQRZAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM3TKOJRHE. You are receiving this because you commented.Message ID: @.***>

VictorMiasnikov commented 4 months ago

We don't have "broken process" / {{ doing something step by step }} We have broken results i.e. compiled binaries 04.06.2024, 23:54, "Rodney M. Bates" @.***>:

On 6/4/24 15:37, Mika Nyström wrote:

Ah images not supported. Drat.

For branch "rodney-new", github says

This branch is 23 commits ahead of https://github.com/modula3/cm3/compare/master...rodney-new, 37 commits behind https://github.com/modula3/cm3/compare/rodney-new...master master.

Ah, this -------^ at least shows me what is missing from master.

None of it sounds from the titles likely to affect the build process.

see

https://github.com/modula3/cm3/tree/rodney-new

Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2148375919, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNBC3ZJ4FF3GIWMUHUTZFYQRZAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM3TKOJRHE.

You are receiving this because you commented.Message ID: @.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

olaf-wagner commented 4 months ago

Hi Rodney,

just a few notes on Git concepts as I think that may be helpful. If you already know this, just skip it.

Git uses a distributed version control architecture in which you have local copies of branches on remote sites. This is necessary to keep the naming of branches unique. When you clone a repository to work on it, by default you get a local remote called origin.

Local branches can be set to track remote branches, which means changes will automatically be related in your local repository. This can either be done implicitly by using git checkout <branch> or explicitly by using git branch —set-upstream-to ….

If you commit a change it will be committed to a local branch and your upstream copies. However, it will not be replicated to the original remote repository.

To move changes between your local and remote repositories use git fetch/pull/push. fetch will update one, several or all copies of remote branches to the current remote state. push will copy your remote branch to its upstream counterpart. pull is actuallly a combination of fetch and checkout, merge or rebase. It updates both your local counterparts of a remote branch and your actual local branch (without a remote prefix). fetch and push only work on the version store (in the .git subdirectory), while pull also updates your current workspace.

It’s a very flexible but also sometimes confusing design I admit.

So to get changes to the remote master or main branch, you have to do something like

git checkout master
git merge <my branch>
git commit -a -m ‘…’
git push

I hope this helps,

Olaf

On 4 Jun 2024, at 22:31, Rodney M. Bates wrote:

I have long thought I had merged all my changes (first committed on branch rodney-new) long ago.  After Victor asked for them, I did a further check and it looked to me like they were there in the head.

I have struggled greatly over merging with git in past.  One realization that has come to be more recently is that git's so-called "remotes" aren't remote, they are local.  But rather local copies of something that is remote, whose identity is stored with the local copy, and there is some git command (I've forgotten its name) in the local repo that will bring them\ "remotes" up-to-date with any changes made since to the original.  This realization has cleared up some amount of confusion on my part, but it looks like I may be still confused about git.

I could well have made mistakes twice on this.  Apparently Victor believes so.

As I remember, the process I had finally chosen was to do a rebase that brought github head changes into my rodney-new branch on my computer. Then push rodney-new to github, which triggers testing in rodney-new on github.  Then if that's clean, do something or other to move that into the head, quickly before more changes came into the head on github.

Is "master" the right branch on github to try to get updated?

I would welcome any advice on what if anything is needed to get this resolved.

On 6/4/24 11:11, Mika Nyström wrote:

Yes I saw your emails. No I haven't tried Rodney's branch.

If there are good fixes on the Rodney branch, why aren't they integrated into the master?

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1182#issuecomment-2147915550, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNFUIFBT4MZEYRZIU4LZFXRMNAVCNFSM6AAAAABIXRZSRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHEYTKNJVGA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Reply to this email directly or view it on GitHub: https://github.com/modula3/cm3/issues/1182#issuecomment-2148366510 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

-- Olaf Wagner -- elego Software Solutions GmbH -- http://www.elegosoft.com Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 163 52 11 579 fax: +49 30 23 45 86 95 Geschäftsführer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194