Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the "native" backend? #1182

Open
mikanystrom opened this issue Jun 4, 2024 · 12 comments
Open

How to use the "native" backend? #1182

mikanystrom opened this issue Jun 4, 2024 · 12 comments

Comments

@mikanystrom
Copy link
Contributor

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:

  • CM3_FLAGS = CM3_FLAGS + " -DM3_BACKEND_MODE=C"
    +#if _CBackend:
    +# CM3_FLAGS = CM3_FLAGS + " -DM3_BACKEND_MODE=C"

#-----------------------------------------------------------------------------

(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 <MI_FinDate>) at ../src/runtime/common/RTLinker.m3:409
#10 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa58a80 <MI_HMTime>) at ../src/runtime/common/RTLinker.m3:389
#11 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa58460 <MM_SafeTZ>) at ../src/runtime/common/RTLinker.m3:389
#12 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa57fc0 <MI_TZ>) at ../src/runtime/common/RTLinker.m3:389
#13 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa536c0 <MM_Debug>) at ../src/runtime/common/RTLinker.m3:389
#14 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa53580 <MI_Debug>) at ../src/runtime/common/RTLinker.m3:389
#15 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cd80 <MM_SchemeUtils>) at ../src/runtime/common/RTLinker.m3:389
#16 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cc00 <MI_SchemeUtils>) at ../src/runtime/common/RTLinker.m3:389
#17 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4cac0 <MM_SchemePair>) at ../src/runtime/common/RTLinker.m3:389
#18 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4c960 <MI_SchemePair>) at ../src/runtime/common/RTLinker.m3:389
#19 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4c7a0 <MI_SchemeClass>) at ../src/runtime/common/RTLinker.m3:389
#20 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4ba40 <MM_Scheme>) at ../src/runtime/common/RTLinker.m3:389
#21 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa4b7c0 <MI_Scheme>) at ../src/runtime/common/RTLinker.m3:389
#22 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa50d60 <MM_SchemeBoolean>) at ../src/runtime/common/RTLinker.m3:389
#23 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa50ca0 <MI_SchemeBoolean>) at ../src/runtime/common/RTLinker.m3:389
#24 0x00000000006e8435 in RTLinker__RunMainBody (m_L_92=0xa3e9c0 <MM_Main>) at ../src/runtime/common/RTLinker.m3:389
#25 0x00000000006e7316 in RTLinker__AddUnitI (m_L_95=0xa3e9c0 <MM_Main>) at ../src/runtime/common/RTLinker.m3:116
#26 0x00000000006e7433 in RTLinker__AddUnit (b_L_83=0x418f93 <Main_M3>) at ../src/runtime/common/RTLinker.m3:125
#27 0x00000000004183f8 in main (argc=1, argv=0x7fffffffd698, envp=0x7fffffffd6a8) at _m3main.cpp:53
(gdb)

@VictorMiasnikov
Copy link
Contributor

( possible duplicate)

Do You see Rodney branch?

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

@mikanystrom
Copy link
Contributor Author

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
Copy link
Contributor

VictorMiasnikov commented Jun 4, 2024 via email

@RodneyBates
Copy link
Contributor

RodneyBates commented Jun 4, 2024 via email

@mikanystrom
Copy link
Contributor Author

mikanystrom commented Jun 4, 2024 via email

@mikanystrom
Copy link
Contributor Author

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
Copy link
Contributor

VictorMiasnikov commented Jun 4, 2024 via email

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Jun 4, 2024 via email

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Jun 4, 2024 via email

@RodneyBates
Copy link
Contributor

RodneyBates commented Jun 4, 2024 via email

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Jun 5, 2024 via email

@olaf-wagner
Copy link
Contributor

olaf-wagner commented Jun 5, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants