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

endian specificity #995

Open
jaykrell opened this issue Feb 10, 2022 · 42 comments
Open

endian specificity #995

jaykrell opened this issue Feb 10, 2022 · 42 comments

Comments

@jaykrell
Copy link
Contributor

cm3 does provide interopability of Modula-3 bitfields with C bitfields.

Can we decree that that isn't really guaranteed?
Or at least not on big endian systems?
Or at least not if you build with -boot?

i.e. either little endian always, or -boot implies little endian?

I want "one" bootstrap to be endian neutral,
for the larger target matrix to be covered by fewer/one downloads.

@jaykrell
Copy link
Contributor Author

I believe how this really ends up is:

  • cm3 itself has no bitfields
  • m3front writing runtime/GC metadata hardcodes little endian, which is actually neutral
  • bitfields actually end up, unchanged, just not used in cm3
  • we can add Modula-3/C interop tests, that show bitfield layout remains compatible and endian-specific

Bootstrapping the entire system via endian neutral C++ would depend on if bitfields are used.
Bitfields are kinda nice, as a size optimization.

@barracuda156
Copy link

@jaykrell I am interested to build it on PowerPC (Big-endian, of course). Can it be bootstrapped from C/C++, without pre-built binary (which may not exist)?

@jaykrell
Copy link
Contributor Author

Sorta, but it has always been difficult to explain.
Well, er, not sure we have big endian bootstraps, but we ought too.. I'll check..

@jaykrell
Copy link
Contributor Author

I see only little endian, or 64bit big endian bootstraps.
I had a goal to make more portable bootstraps (endian independent, word size independent), but it is quite stalled, sorry.
It is pretty easy though, if you have any other system, to cross build the 32big bit endian bootstrap. I don't know if we ever got PPC64_DARWIN working..shouldn't be difficult..we have so many others..

@barracuda156
Copy link

@jaykrell If there exists a procedure to build it starting from gcc without pre-built cm3 binary, that will be preferable. I wanna make a port for Macports, and using cross-compilation for that purpose it not a workable option.

Modula2 builds fine on Darwin ppc – within gcc, starting with nothing. There should be something similar here?

@mikanystrom
Copy link
Contributor

mikanystrom commented Oct 16, 2023 via email

@barracuda156
Copy link

@mikanystrom Do I need anything besides gcc for that? I.e. some archaic pre-built bootstrap binaries of cm3, or not?

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 20, 2023

( . . .) If there exists a procedure to build it starting from gcc without pre-built cm3 binary, that will be preferable.

You can try this:

  1. cm3-d5.11.9-ZZYYXX-20230928_16-50__cm3-boot-unix64le.7z

or this

  1. cm3-d5.11.9-ZZYYXX-20230928_16-50__cm3-boot-AMD64_LINUX-d5.11.9-20230926_14-06.tar.xz

or this

  1. cm3-boot-AMD64_LINUX-None.tar.xz

from
https://github.com/VictorMiasnikov/cm3/releases/tag/d5.11.9-ZZYYXX-20230928_16-50

P.S. "Linux" and "le" has been used in naming as tradition. All files are universal

@VictorMiasnikov
Copy link
Contributor

( . . .) d5.11.9-ZZYYXX-20230928_16-50

Sorry: Release 16-50 is specific ...

First try cm3-d5.11.9-ZZYYXX-20230928_16-50__cm3-boot-unix64le.7z

As alternate variant You can try files from

from
d5.11.9-ZZYYXX-20230721_16-29

@VictorMiasnikov
Copy link
Contributor

P.S.

( . . .) I am interested to build it on PowerPC (Big-endian, of course). Can it be bootstrapped from C/C++, without pre-built binary (which may not exist)?

Are You have PPC or PPC64?

I've found:

https://raw.githubusercontent.com/macports/macports-ports/master/lang/cm3/Portfile

plus

https://modula3.elegosoft.com/cm3/cm3-min-POSIX-PPC_DARWIN-5.4.0.tgz

@barracuda156
Copy link

barracuda156 commented Oct 20, 2023

@VictorMiasnikov Oh wow, thank you very much! The port seems to outdated and broken across the board, but I will probably be able to fix it.
https://ports.macports.org/port/cm3/details

P. S. Somehow I missed its existence, maybe searched for a different name. Anyway, all good now, thanks everyone for helping with this.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 20, 2023

@VictorMiasnikov Oh wow, thank you very much! The port seems to outdated and broken across the board, but I will probably be able to fix it. https://ports.macports.org/port/cm3/details

You are welcome!

I've found and cm3 5.8.6 on

https://modula3.elegosoft.com/cm3/releng/download.html

P.S.
Last 25 minutes I wanted found this:
https://modula3.elegosoft.com/cm3/uploaded-archives/

and found it.

There is not most modern DARWIN_PPC, but there is SPARC64_SOLARIS
It may be useful for prepare bootstrap

I.e. I hope that it be useful... I only going to try install QEMU for non-ARM32 / non-ARM64 / non-AMD64 CPU architectures

@jaykrell
Copy link
Contributor Author

jaykrell commented Oct 20, 2023

Unfortunately they aren't quite universal.
It was a goal, but I didn't quite get there.
They word-size and endian specific.
So arm32==x86==ppc32le
arm64==amd64==riscv64
sparc64==ppc64be
sparc32==ppc32be

So for "Unix" you'd need 4 bootstraps: LittleEndian32bit, LittleEndian64bit, BigEndian32bit, BigEndian64bit.
And then Windows is another factor, though Windows BigEndian is barely a thing (Xbox360, some Windows CE platforms).

You can just about ignore all this stuff..64bit little endian is prevalent, but here we are discussing 32bit big endian Mac PowerPC.

The endian specificity is due to code breaking down floats into bitfields.
And maybe some bitfields in garbage collector, I don't remember if I fixed those.

@jaykrell
Copy link
Contributor Author

jaykrell commented Oct 20, 2023

It is pretty easy to build all these...we just don't quite have the automation setup, sorry.
Any of them can be cross built from any other.
Also I never finished porting the build scripts from Python2 to Python3...Python3 compatibility, what a mess. :(

@barracuda156
Copy link

@VictorMiasnikov Thank you, this is very helpful.

Do you know if I need exactly the same version for bootstrap binary and the main source? The latest Darwin PPC binary seems to be 5.8.6.

@jaykrell
Copy link
Contributor Author

It is hard to explain. Please consider that Gcc is also written in itself, and doesn't "just work", as if by magic. It is just that people provide the binaries for you.

In the Modula-3 case, you'd cross build the bootstrap from a working system.
You absolutely need a working cm3.

The versions do not have to match though in general..if you build in the right order, which we automate.

@barracuda156
Copy link

Unfortunately they aren't quite universal. It was a goal, but I didn't quite get there. They word-size and endian specific. So arm32==x86==ppc32le arm64==amd64==riscv64 sparc64==ppc64be sparc32==ppc32be

So for "Unix" you'd need 4 bootstraps: LittleEndian32bit, LittleEndian64bit, BigEndian32bit, BigEndian64bit. And then Windows is another factor, though Windows BigEndian is barely a thing (Xbox360, some Windows CE platforms).

You can just about ignore all this stuff..64bit little endian is prevalent, but here we are discussing 32bit big endian Mac PowerPC.

The endian specificity is due to code breaking down floats into bitfields. And maybe some bitfields in garbage collector, I don't remember if I fixed those.

If OS does not matter (which sounds surprising to me, but I have no experience with m3), then there is ppc32 5.9.0, which is BE by definition: cm3-min-PPC32_OPENBSD-d5.9.0-OpenBSD4.6-20100729.tar.gz

@jaykrell
Copy link
Contributor Author

And yeah, those older bootstraps should work.
They'll generate a working cm3, which can then most likely build a newer cm3.
But...if this doesn't work, better approach is to start from a current system and do the cross bootstrap..all well automated in the scripts directory...sorry if I'm not helping enough. We should have more github actions, and produce the 4 bootstraps, either in cmake or autotools form, or the older way that just uses make.

@jaykrell
Copy link
Contributor Author

OS doesn't matter, because all the OS-dependent stuff is in #ifdef'ed C.
But that OpenBSD bootstrap is over 10 years old.

Do you really not have a little endian 64bit Unix system from which to cross build from a current system? It is the right way to do it.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 20, 2023

Do you really not have a little endian 64bit Unix system from which to cross build from a current system? ( . . .)

Exactly little ? Strange, because this "arm32==x86==ppc32le arm64==amd64==riscv64 sparc64==ppc64be sparc32==ppc32be" contain another information.

P.S. In case then really little endian 64bit Unix is good then we can start from cm3-d5.11.9-ZZYYXX-20230928_16-50__cm3-boot-unix64le.7z.

After generate bootstrap by boot1.py

P.P.S.

It looks like, most realistic way is install cm3 on all possible vars of "arm32==x86==ppc32le arm64==amd64==riscv64 sparc64==ppc64be sparc32==ppc32be" with preference "sparc64==ppc64be sparc32==ppc32be" vars.

And after this generate bootstrap(s) by boot1.py

@barracuda156
Copy link

Okay, a lazy approach of merely replacing the version is the portfile did not work:

gcc   -g -arch ppc -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros 				     -Wno-overlength-strings    -DHAVE_CONFIG_H  -o m3cgc1 m3cg/parse.o m3cg/m3-convert.o attribs.o main.o  libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -L/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-sys/m3cc/PPC_DARWIN/./gmp/.libs -L/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-sys/m3cc/PPC_DARWIN/./gmp/_libs -L/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-sys/m3cc/PPC_DARWIN/./mpfr/.libs -L/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-sys/m3cc/PPC_DARWIN/./mpfr/_libs -lmpfr -lgmp
--- shipping from PPC_DARWIN ---

. => /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/destroot/opt/local/cm3/bin
  cm3cg           
 ==> /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-sys/m3cc done

=== package /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3/m3-libs/m3core ===
 +++ cm3 -build -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3_VERSION_TEXT='5.8.6' -DCM3_VERSION_NUMBER='050806' -DCM3_LAST_CHANGED='2010-04-11' -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3VERSION='5.8.6' -DCM3VERSIONNUM='050806' -DCM3LASTCHANGED='2010-04-11' $RARGS  && cm3 -ship $RARGS -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3_VERSION_TEXT='5.8.6' -DCM3_VERSION_NUMBER='050806' -DCM3_LAST_CHANGED='2010-04-11' -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3VERSION='5.8.6' -DCM3VERSIONNUM='050806' -DCM3LASTCHANGED='2010-04-11'  +++
--- building in PPC_DARWIN ---

ignoring ../src/m3overrides

new source -> compiling RTHooks.i3
new source -> compiling RT0.i3
new source -> compiling RuntimeError.i3
new source -> compiling WordRep.i3
new source -> compiling Word.i3
new source -> compiling RTException.i3
new source -> compiling RTHooks.m3
new source -> compiling RT0.m3
new source -> compiling Compiler.i3
new source -> compiling RuntimeError.m3
new source -> compiling Compiler.m3
new source -> compiling RTAllocator.i3
new source -> compiling RTType.i3
new source -> compiling RTMachine.i3
new source -> compiling RTHeapRep.i3
new source -> compiling FloatMode.i3
new source -> compiling RTThread.i3
new source -> compiling Scheduler.i3
new source -> compiling RTOS.i3
new source -> compiling RTMisc.i3
new source -> compiling Cstdlib.i3
new source -> compiling LongRep.i3
new source -> compiling Long.i3
new source -> compiling BasicCtypes.i3
new source -> compiling Ctypes.i3
new source -> compiling Cstddef.i3
new source -> compiling RTAllocCnts.i3
new source -> compiling RTAllocator.m3
new source -> compiling RTAllocStats.i3
new source -> compiling Convert.i3
new source -> compiling TextClass.i3
new source -> compiling Text.i3
new source -> compiling RTProcedureSRC.i3
new source -> compiling Fingerprint.i3
new source -> compiling RTProcedure.i3
new source -> compiling RTStack.i3
new source -> compiling RTAllocStats.m3
new source -> compiling RTHeap.i3
new source -> compiling TextLiteral.i3
new source -> compiling RTHeap.m3
new source -> compiling RTHeapInfo.i3
new source -> compiling Cstring.i3
new source -> compiling Thread.i3
new source -> compiling RTPerfTool.i3
new source -> compiling RTParams.i3
new source -> compiling RTHeapInfo.m3
new source -> compiling RTHeapMap.i3
new source -> compiling RTIO.i3
new source -> compiling RTTypeMap.i3
new source -> compiling RTMapOp.i3
new source -> compiling RTModule.i3
new source -> compiling RTHeapMap.m3
new source -> compiling RTHeapRep.m3
new source -> compiling RTHeapStats.i3
new source -> compiling RTTypeSRC.i3
new source -> compiling RTCollector.i3
new source -> compiling RTHeapStats.m3
new source -> compiling Time.i3
new source -> compiling RTLinker.i3
new source -> compiling RTProcess.i3
new source -> compiling RTHeapEvent.i3
new source -> compiling RTWeakRef.i3
new source -> compiling RTCollectorSRC.i3
new source -> compiling RTCollector.m3
new source -> compiling RTIO.m3
new source -> compiling RTLinkerX.i3
new source -> compiling RTSignal.i3
new source -> compiling RTDebug.i3
new source -> compiling RTLinker.m3
new source -> compiling RTDebug.m3
new source -> compiling RTError.i3
new source -> compiling RTError.m3
new source -> compiling M3toC.i3
new source -> compiling RTException.m3
new source -> compiling RTMapOp.m3
new source -> compiling RTMisc.m3
new source -> compiling RTPacking.i3
new source -> compiling RTPacking.m3
new source -> compiling RTArgs.i3
new source -> compiling RTParams.m3
new source -> compiling RTProcedure.m3
new source -> compiling RTProcess.m3
new source -> compiling RTTipe.i3
new source -> compiling RTTipe.m3
new source -> compiling RTType.m3
new source -> compiling RTTypeFP.i3
new source -> compiling RTTypeFP.m3
new source -> compiling RTTypeMap.m3
new source -> compiling RTutils.i3
new source -> compiling RTutils.m3
new source -> compiling RTHeapDebug.i3
new source -> compiling WeakRef.i3
new source -> compiling RTHeapDebug.m3
new source -> compiling RTArgs.m3
new source -> compiling Uuio.i3
new source -> compiling Usysdep.i3
new source -> compiling Unix.i3
new source -> compiling Cstdint.i3
new source -> compiling Utypes.i3
new source -> compiling Utime.i3
new source -> compiling RTOS.m3
new source -> compiling Uexec.i3
new source -> compiling RTPerfTool.m3
new source -> compiling RTSignalPrivate.i3
new source -> compiling RTSignalC.i3
new source -> compiling RTSignal.m3
new source -> compiling Csetjmp.i3
new source -> compiling RTExFrame.i3
new source -> compiling RTExFrame.m3
new source -> compiling ThreadF.i3
new source -> compiling SchedulerPosix.i3
new source -> compiling MutexRep.i3
new source -> compiling ThreadEvent.i3
new source -> compiling ThreadPThread.i3
new source -> compiling Uerror.i3
new source -> compiling Usched.i3
new source -> compiling Cerrno.i3
new source -> compiling ThreadPThread.m3
new source -> compiling WinBaseTypes.i3
new source -> compiling WinDef.i3
new source -> compiling WinDef.m3
new source -> compiling WinNT.i3
new source -> compiling WinNT.m3
new source -> compiling Unetdb.i3
new source -> compiling Ugrp.i3
new source -> compiling Usignal.i3
new source -> compiling Uutmp.i3
new source -> compiling Umman.i3
new source -> compiling Upwd.i3
new source -> compiling Uugid.i3
new source -> compiling Uprocess.i3
new source -> compiling Unix.m3
new source -> compiling Upthread.i3
new source -> compiling Uin.i3
new source -> compiling Usocket.i3
new source -> compiling Ustat.i3
new source -> compiling Udir.i3
new source -> compiling Uucontext.i3
new source -> compiling Text8CString.i3
new source -> compiling Text8.i3
new source -> compiling M3toC.m3
new source -> compiling Cstdio.i3
new source -> compiling Csignal.i3
new source -> compiling Real.i3
new source -> compiling RealFloat.i3
new source -> compiling LongReal.i3
new source -> compiling LongFloat.i3
new source -> compiling Extended.i3
new source -> compiling ExtendedFloat.i3
new source -> compiling IEEESpecial.i3
new source -> compiling LongRealRep.i3
new source -> compiling RealRep.i3
new source -> compiling IEEESpecial.m3
new source -> compiling Real.m3
new source -> compiling LongReal.m3
new source -> compiling Extended.m3
new source -> compiling DragonInt.i3
new source -> compiling DragonInt.m3
new source -> compiling DragonT.i3
new source -> compiling DragonT.m3
new source -> compiling FPU.i3
new source -> compiling RealFloat.m3
new source -> compiling LongFloat.m3
new source -> compiling ExtendedFloat.m3
new source -> compiling FPU.m3
new source -> compiling FloatMode.m3
new source -> compiling Tick.i3
new source -> compiling Date.i3
new source -> compiling FmtTime.i3
new source -> compiling FmtTime.m3
new source -> compiling TickPortable.m3
new source -> compiling TimePosix.i3
new source -> compiling DateBsd.m3
new source -> compiling TimePosix.m3
new source -> compiling CConvert.i3
new source -> compiling CConvert.m3
new source -> compiling Convert.m3
new source -> compiling String8.i3
new source -> compiling String8.m3
new source -> compiling String16.i3
new source -> compiling String16.m3
new source -> compiling Text16.i3
new source -> compiling Text.m3
new source -> compiling TextClass.m3
new source -> compiling TextLiteral.m3
new source -> compiling Text8Short.i3
new source -> compiling Text8.m3
new source -> compiling Text8Short.m3
new source -> compiling Text8CString.m3
new source -> compiling Text16Short.i3
new source -> compiling Text16.m3
new source -> compiling Text16Short.m3
new source -> compiling TextSub.i3
new source -> compiling TextCat.i3
new source -> compiling TextSub.m3
new source -> compiling TextCat.m3
new source -> compiling TextConv.i3
new source -> compiling TextConv.m3
new source -> compiling Poly.i3
new source -> compiling Fingerprint.m3
new source -> compiling Poly.m3
new source -> compiling PolyBasis.i3
new source -> compiling PolyBasis.m3
new source -> compiling Main.i3
new source -> compiling WeakRef.m3
new source -> compiling Word.m3
new source -> compiling Long.m3
new source -> compiling hand.c
new source -> compiling dtoa.c
new source -> compiling libgcc.c
new source -> compiling RTIOc.c
new source -> compiling RTLinkerC.c
new source -> compiling RTMiscC.c
new source -> compiling RTProcessC.c
new source -> compiling RTOSmmap.c
new source -> compiling RTSignalC.c
new source -> compiling RTStackC.c
new source -> compiling ThreadPThreadC.c
new source -> compiling UtimeC.c
new source -> compiling UnixC.c
new source -> compiling UnixLink.c
new source -> compiling Uexec.c
new source -> compiling Unetdb.c
new source -> compiling Umman.c
new source -> compiling Ugrp.c
new source -> compiling Uin.c
new source -> compiling Uugid.c
new source -> compiling Uuio.c
new source -> compiling Uutmp.c
new source -> compiling Usignal.c
new source -> compiling Upwd.c
new source -> compiling Uprocess.c
new source -> compiling Upthread.c
new source -> compiling Uconstants.c
new source -> compiling UstatC.c
new source -> compiling Usocket.c
new source -> compiling UdirC.c
new source -> compiling CstdlibC.c
new source -> compiling CerrnoC.c
new source -> compiling CstringC.c
new source -> compiling CstdioC.c
new source -> compiling CsignalC.c
new exporters -> recompiling RTHooks.i3
new exporters -> recompiling RTAllocCnts.i3
new exporters -> recompiling RTHeapRep.i3
new exporters -> recompiling RTCollectorSRC.i3
new exporters -> recompiling RTWeakRef.i3
new exporters -> recompiling RTException.i3
new exporters -> recompiling RTModule.i3
new exporters -> recompiling RTThread.i3
new exporters -> recompiling RTProcedureSRC.i3
new exporters -> recompiling RTTypeSRC.i3
new exporters -> recompiling RTOS.i3
new exporters -> recompiling RTSignalPrivate.i3
new exporters -> recompiling Thread.i3
new exporters -> recompiling ThreadF.i3
new exporters -> recompiling Scheduler.i3
new exporters -> recompiling SchedulerPosix.i3
new exporters -> recompiling Time.i3
new exporters -> recompiling Tick.i3
new exporters -> recompiling Date.i3
new exporters -> recompiling Text.i3
 -> archiving libm3core.a
ld: library not found for -lcc_dynamic
fatal error: libtool: internal link edit command failed
  make_lib => 1
librarian failed building: m3core
Fatal Error: package build failed
 *** execution of cm3 -build -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3_VERSION_TEXT='5.8.6' -DCM3_VERSION_NUMBER='050806' -DCM3_LAST_CHANGED='2010-04-11' -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3VERSION='5.8.6' -DCM3VERSIONNUM='050806' -DCM3LASTCHANGED='2010-04-11' $RARGS  && cm3 -ship $RARGS -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3_VERSION_TEXT='5.8.6' -DCM3_VERSION_NUMBER='050806' -DCM3_LAST_CHANGED='2010-04-11' -DROOT='/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_cm3/cm3/work/cm3' -DCM3VERSION='5.8.6' -DCM3VERSIONNUM='050806' -DCM3LASTCHANGED='2010-04-11'  failed ***

This -lcc_dynamic looks weird to me. Anyway, I will deal with this shortly, but perhaps not tonight. Hacking gcc builds is not a very trivial task :)

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 21, 2023 via email

@barracuda156
Copy link

Bootstrap binary seems perfectly okay:

sergey-fedorovs-power-mac-g5:~ svacchanda$ /opt/local/var/macports/buCSnowLeopardPorts_lang_cm3/cm3/work/bootstrap/bin/cm3 
--- building in PPC_DARWIN ---

^C

This is 5.8.6, from the link you shared above.

No, I do not have non-macOS systems that are functional. (I tried installing FreeBSD recently, but upstream has broken multicore support in v. 13, and on G4 it will take forever to build anything; in any case, I have no experience with it, so macOS is way easier).
I do have x86 and aarch64 hardware, but I wanna make sure PPC build works first; once that is done, presumably more common builds will be trivial to set up.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 21, 2023 via email

@jaykrell
Copy link
Contributor Author

I do have x86 and aarch64 hardware,
but I wanna make sure PPC build
works first

Do it the other way around. First run amd64 or x86 on any system. Windows, Mac, Linux, anything. Then cross to Macppc. Do not favor an old “closer” match.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 21, 2023 via email

@barracuda156
Copy link

@jaykrell Cross-compiling is not an option for Macports. We need to implement a process that works for everyone, not just a hack to make it work locally for me.
I could try building on i386 for i386, of course, to see if that works.

@VictorMiasnikov I do not think anything le gonna work for the discussed purpose, since ppc32 is always BE, on any system. ppc64 is bi-endian, but on macOS it is only BE too.

@jaykrell
Copy link
Contributor Author

You must/should start with cross building.
Get cm3 working on some system.
Then use boot1.py or similar to cross build a natively buildable compiler. It outputs a bunch of .c. Do not bother with any other approach. This works, has worked countless times.

@barracuda156
Copy link

@jaykrell Why not use existing boot binaries though? I mean, I realize you know better, I just want to understand why it is the case.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 22, 2023 via email

@barracuda156
Copy link

@VictorMiasnikov So, I have used this above: cm3-bin-min-PPC_DARWIN-5.8.6-REL.

It is from your link: https://modula3.elegosoft.com/cm3/releng/download.html

The latest one explicitly referring to ppc32 is 5.9.0, but it is only for OpenBSD, here: https://modula3.elegosoft.com/cm3/uploaded-archives

I used this portfile, replacing versions accordingly (both for bootstrap binary and the source): https://github.com/macports/macports-ports/blob/master/lang/cm3/Portfile
Looks like this worked earlier on Darwin PPC as-is. I did not try building 5.2.6 though, no point to resurrect that much outdated version anyway. We should amend it to build the current one, plus support Apple Silicon and Intel.

@barracuda156
Copy link

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 23, 2023

@VictorMiasnikov So, I have used this above: cm3-bin-min-PPC_DARWIN-5.8.6-REL.

It is from your link: https://modula3.elegosoft.com/cm3/releng/download.html

The latest one explicitly referring to ppc32 is 5.9.0, but it is only for OpenBSD, here: https://modula3.elegosoft.com/cm3/uploaded-archives

I used this portfile, replacing versions accordingly (both for bootstrap binary and the source): https://github.com/macports/macports-ports/blob/master/lang/cm3/Portfile Looks like this worked earlier on Darwin PPC as-is. I did not try building 5.2.6 though, no point to resurrect that much outdated version anyway. We should amend it to build the current one, plus support Apple Silicon and Intel.

+

@VictorMiasnikov UPD. In fact, we do seem to have 5.9.0 for Darwin PPC: https://modula3.elegosoft.com/cm3/snaps/cm3-bin-core-PPC_DARWIN-d5.9.0-powerpc-apple-darwin8.11.0-2012-08-21-21-26-33.tgz

Thank for answer!

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 23, 2023

Get cm3 working on some system.
Q: I.e. we can use LE systems?For example I386_NT ?Or even AMD64_NT or AMD64_LINUX?
Then use boot1.py
I can run " boot1.py DARWIN_PPC ". ( I am going to do this on Monday)

cm3-boot-PPC_DARWIN-d5.11.9-20231023_11-47.tar.xz

P.S. Replaced by

cm3-boot-PPC_DARWIN-d5.11.9-20231023_15-08.tar.gz

@barracuda156
Copy link

@VictorMiasnikov Awesome, thank you very much!

Initial run of make on the extracted contents failed on:

In file included from CerrnoC.c:6:
m3core.h:721: error: redefinition of typedef ‘Usocket__socklen_t’
m3core.h:698: error: previous declaration of ‘Usocket__socklen_t’ was here
make: *** [CerrnoC.o] Error 1

This is not via portfile. I just manually extracted, cd to top directory and ran make.

@VictorMiasnikov
Copy link
Contributor

@VictorMiasnikov Awesome, thank you very much!

Initial run of make on the extracted contents failed on:

In file included from CerrnoC.c:6:
m3core.h:721: error: redefinition of typedef ‘Usocket__socklen_t’
m3core.h:698: error: previous declaration of ‘Usocket__socklen_t’ was here
make: *** [CerrnoC.o] Error 1

This is not via portfile. I just manually extracted, cd to top directory and ran make.

May be simple remove line 721 ?..

@barracuda156
Copy link

Removing that line, build proceeded until:

M3CC.c:9: error: redefinition of typedef ‘BOOL’
m3core.h:46: error: previous declaration of ‘BOOL’ was here
make: *** [M3CC.o] Error 1

This apparently happens because M3CC.c includes m3core.h but the defines the same type over again.

@barracuda156
Copy link

Trashing a duplicate BOOL define, next one is:

Uconstants.c:331: error: redefinition of typedef ‘const_INTEGER’
m3core.h:500: error: previous declaration of ‘const_INTEGER’ was here
make: *** [Uconstants.o] Error 1

P. S. I wonder why these errors do not show up on Linux.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 23, 2023

Trashing a duplicate BOOL define, next one is:

Uconstants.c:331: error: redefinition of typedef ‘const_INTEGER’
m3core.h:500: error: previous declaration of ‘const_INTEGER’ was here
make: *** [Uconstants.o] Error 1

P. S. I wonder why these errors do not show up on Linux.

I going to prepare cm3-boot-PPC_DARWIN-d5.11.9-20231023_15-08.tar.gz with this:

--- M3CC.c 000  Mon Oct 23 11:47:46 202
+++ M3CC.c      Mon Oct 23 15:00:51 202
@@ -6,9 +6,10 @@
 extern "C" {
 #endif

-typedef int BOOL;
-#define FALSE 0
-#define TRUE 1
+
+
+

 TEXT
 __cdecl

Of course, all this will be temporаry solution

P.S. Done. Please see:

cm3-boot-PPC_DARWIN-d5.11.9-20231023_15-08.tar.gz

@barracuda156
Copy link

@VictorMiasnikov Here we go:

36-6% /Users/svacchanda/Dev_tmp/cm3/cm3-boot-PPC_DARWIN-d5.11.9-20231023/cm3 --version 
Critical Mass Modula-3 version d5.11.9
  GitInfo: /commit/d2fcac6eb0cd71f490e1ef37faff0971c98a4084
           /commits/heads/d5.11.9-ZZYYXX-20230721_17-25
           remote: 
           revision: d2fcac6eb0cd71f490e1ef37faff0971c98a4084
           branch: heads/d5.11.9-ZZYYXX-20230721_17-25
  last updated: 2022-02-05
  compiled: 2023-10-23 20:15:44
  configuration: 
PPC_DARWIN POWER MACINTOSH32_DARWIN

I had to amend Makefile to use CXX, as it should. With CC it pulls cc, which is a symlink to gcc-4.2, and it fails at linking, since g++-4.2 must be used. (I have seen that Makefile lazily sets CC to g++, but it does not work.)

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Oct 23, 2023 via email

VictorMiasnikov added a commit to VictorMiasnikov/cm3 that referenced this issue Oct 26, 2023
FIX 2 errors on PPC_DARWIN

 1)
FIX error on PPC_DARWIN by adding M3_BOOL_H_INCLUDED
modula3#995 (comment)
= =
M3CC.c:9: error: redefinition of typedef ‘BOOL’
m3core.h:46: error: previous declaration of ‘BOOL’ was here
make: *** [M3CC.o] Error 1
= =

 a-la
m3-sys\m3gdb\gdb\gdb\m3-bool.h
==

#ifndef M3_BOOL_H_INCLUDED
#define M3_BOOL_H_INCLUDED
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#endif

==

 2)

FIX error on PPC_DARWIN by adding M3_USOCKET__SOCKLEN_T_H_INCLUDED

modula3#995 (comment)
= =
In file included from CerrnoC.c:6:
m3core.h:721: error: redefinition of typedef ‘Usocket__socklen_t’
m3core.h:698: error: previous declaration of ‘Usocket__socklen_t’ was here
make: *** [CerrnoC.o] Error 1
= =

 by preprocessor var M3_USOCKET__SOCKLEN_T_H_INCLUDED :

#ifndef M3_USOCKET__SOCKLEN_T_H_INCLUDED
#define M3_USOCKET__SOCKLEN_T_H_INCLUDED

typedef m3_socklen_t Usocket__socklen_t;

#endif
VictorMiasnikov added a commit to VictorMiasnikov/cm3 that referenced this issue Nov 17, 2023
FIX 2 errors on PPC_DARWIN

 1)
FIX error on PPC_DARWIN by adding M3_BOOL_H_INCLUDED
modula3#995 (comment)
= =
M3CC.c:9: error: redefinition of typedef ‘BOOL’
m3core.h:46: error: previous declaration of ‘BOOL’ was here
make: *** [M3CC.o] Error 1
= =

 a-la
m3-sys\m3gdb\gdb\gdb\m3-bool.h
==

#ifndef M3_BOOL_H_INCLUDED
#define M3_BOOL_H_INCLUDED
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#endif

==

 2)

FIX error on PPC_DARWIN by adding M3_USOCKET__SOCKLEN_T_H_INCLUDED

modula3#995 (comment)
= =
In file included from CerrnoC.c:6:
m3core.h:721: error: redefinition of typedef ‘Usocket__socklen_t’
m3core.h:698: error: previous declaration of ‘Usocket__socklen_t’ was here
make: *** [CerrnoC.o] Error 1
= =

 by preprocessor var M3_USOCKET__SOCKLEN_T_H_INCLUDED :

#ifndef M3_USOCKET__SOCKLEN_T_H_INCLUDED
#define M3_USOCKET__SOCKLEN_T_H_INCLUDED

typedef m3_socklen_t Usocket__socklen_t;

#endif
VictorMiasnikov added a commit to VictorMiasnikov/cm3 that referenced this issue Nov 24, 2023
FIX 2 errors on PPC_DARWIN

 1)
FIX error on PPC_DARWIN by adding M3_BOOL_H_INCLUDED
modula3#995 (comment)
= =
M3CC.c:9: error: redefinition of typedef ‘BOOL’
m3core.h:46: error: previous declaration of ‘BOOL’ was here
make: *** [M3CC.o] Error 1
= =

 a-la
m3-sys\m3gdb\gdb\gdb\m3-bool.h
==

#ifndef M3_BOOL_H_INCLUDED
#define M3_BOOL_H_INCLUDED
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#endif

==

 2)

FIX error on PPC_DARWIN by adding M3_USOCKET__SOCKLEN_T_H_INCLUDED

modula3#995 (comment)
= =
In file included from CerrnoC.c:6:
m3core.h:721: error: redefinition of typedef ‘Usocket__socklen_t’
m3core.h:698: error: previous declaration of ‘Usocket__socklen_t’ was here
make: *** [CerrnoC.o] Error 1
= =

 by preprocessor var M3_USOCKET__SOCKLEN_T_H_INCLUDED :

#ifndef M3_USOCKET__SOCKLEN_T_H_INCLUDED
#define M3_USOCKET__SOCKLEN_T_H_INCLUDED

typedef m3_socklen_t Usocket__socklen_t;

#endif
@VictorMiasnikov
Copy link
Contributor

Trashing a duplicate BOOL define, next one is:

Uconstants.c:331: error: redefinition of typedef ‘const_INTEGER’
m3core.h:500: error: previous declaration of ‘const_INTEGER’ was here
make: *** [Uconstants.o] Error 1

P. S. I wonder why these errors do not show up on Linux.

I going to prepare cm3-boot-PPC_DARWIN-d5.11.9-20231023_15-08.tar.gz with this:

--- M3CC.c 000  Mon Oct 23 11:47:46 202
+++ M3CC.c      Mon Oct 23 15:00:51 202
@@ -6,9 +6,10 @@
 extern "C" {
 #endif

-typedef int BOOL;
-#define FALSE 0
-#define TRUE 1
+
+
+

 TEXT
 __cdecl

Of course, all this will be temporаry solution

Please, see

#1172

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