Repository navigation
Conversation
hosking
left a comment
There was a problem hiding this comment.
Thanks, Jay. Using a .cpp wrapper plus cpp_source for the one file that has to be C++ looks right to me, better than a global -TP. All the M3C output is already .cpp, so -TP only ever affected hand-written C. A few things before it goes in:
- Scope
-wd4716to old compilers. It's only needed for older bootstraps, whose generated C has always-raising functions without a return; current M3C emits the pragma itself. Applied globally, it also hides genuine missing-return errors in hand-written C.M3BOOT2seems the natural guard:if defined ("M3BOOT2") args += ["-wd4716"] end. M3BOOT2is defined but unused.boot2.pynow passes-DM3BOOT2, but the only test of it inNT.commonis commented out. Either use it, as in (1), or leave it out ofboot2.pyfor now.- The
M3_USE_STACK_WALKERblock at the end ofNT.common. Both branches set it toFALSE, and it's marked as temporary. Because it comes at the end ofNT.common, andAMD64_NTincludesNT.common, it would also override any setting a target config makes before the include. Could it come out of this PR and be decided in #1346, where NT moves toex_stack? It's good to see that nothing here turnsex_stackon for Windows; master's NT targets stay onex_frame(relevant to #1287). - Hand-written C on NT is now compiled as C. Anything relying on C++-only constructs would now fail. CI's NT jobs passed, which covers what CI builds. Did you build any packages outside CI's set on NT with this?
- Small things.
- The comment says
RTSTackC.c; the file isRTExStackC.c. - "i.e. for jmpbuf, which ought to be rendered as jmpbuf" reads as if a word is missing.
- The
UNWINDlines inNT.commonand the blank line inscripts/python/boot2.pyare CRLF-to-LF conversions. That's a fine cleanup, but a separate commit would keep this diff to the functional change.
- The comment says
🤖 Generated with Claude Code
I hadn't thought of this. Mildly agreed. I have a draft where we get the old m3core/libm3 source via github.
CRLF changes are usually an accident, my editor, and then
Maybe I can trim comments.
Yeah it broke I386_NT. Agreed, can make it more flexible. |
d2c236d to
cbf9586
Compare
|
I left it as M3BOOT2 but open to other. |
|
Rewrote jmpbuf comment shorter. |
In the boot1+boot2 workflow, old compilers use current config. This might be something to fix. Maybe they should carry config. The bootstrap I am working from has .c files, that are not quite valid C++. The mistake is they declare alloca without extern "C" and so fail to link. In this context, unconditional global -TP is bad. It breaks building the bootstrap. To deal with this... two tactics here, one commented out. - When running boot2, define M3BOOT2, to guide config into a more compatible mode. That is, skip -TP. This is commented, but probably reasonable and works. - Another line of thinking.. Years ago people complained when I compiled all the .c files in the tree as C++. cpp_source was proposed. It doesn't look like I completed this. My preferences for/against C and C++ do wax and wane, I admit. So the, we can observe, that vast majority of the .c files in tree: - Have remained valid C (and C++). - Have no super compelling reason to compelling reason to compile as C++. - Except to allow this global configuration. Compiling as C++ does have significant but not universal use-case. It is needed for any Modula-3 file wity TRY/EXCEPT/FINALLY when using ex_stack. It is needed in one hand written file, RTExStackC.c that contains a throw statement. We can address these needs in multiple ways. - The -TP switch, as so far attempted, mostly works, except with old bootstraps. We could also patch up bootstrap alloca references. We could move forward to a newer bootstrap, though I really like seeing how far back we can go. It has mostly worked well. - File extension guides the compiler. All the M3C outputs were long ago changed to .cpp. So all Modula-3 code through C++ backend is compiled as C++, whether or not it has TRY/EXCEPT/FINALLY. You could actually imagine making this conditional, and measuring if C frontend is faster than C++. - Similarly, for this one file, RTExStackC, we can can have RTExStackCpp.cpp, that #includes RTExStackC.c and use m3build cpp_source, if it is defined. Leaving all the other hand written .c as C. That last option is presented in this PR. I'm not done validating it (check the commands/logs), but it is convincing. Clearly, as stated, there are many ways to address the situation. It might seem like backward compatible config is a lost cause but I've worked it at a lot, successfully. Obviously yet another approach is, not for the bootstrap per se to carry its config but go back to the old git hash, and get and use those files. Repair the bootstrap retroactively. Or again, patch the alloca with sed or such.
In the boot1+boot2 workflow, old compilers use current config. This might be something to fix. Maybe they should carry config.
The bootstrap I am working from has .c files, that are not quite valid C++. The mistake is they declare alloca without extern "C" and so fail to link.
In this context, unconditional global -TP is bad. It breaks building the bootstrap.
To deal with this... two tactics here, one commented out.
When running boot2, define M3BOOT2, to guide config into a more compatible mode. That is, skip -TP. This is commented, but probably reasonable and works.
Another line of thinking.. Years ago people complained when I compiled all the .c files in the tree as C++. cpp_source was proposed. It doesn't look like I completed this. My preferences for/against C and C++ do wax and wane, I admit.
So then, we can observe, that vast majority of the .c files in tree:
This global configuration is because compiling as C++ does have significant but not universal use-case. It is needed for any Modula-3 file with TRY/EXCEPT/FINALLY when using ex_stack. It is needed in one hand written file, RTExStackC.c that contains a throw statement.
We can address these needs in multiple ways.
That last option is presented in this PR.
Complete AMD64_NT bootstrap ex_frame => ex_stack has not completed, but logs show this works.
Clearly, as stated, there are many ways to address the situation. It might seem like backward compatible config is a lost cause but I've worked it at a lot, successfully.
Obviously yet another approach is, not for the bootstrap per se to carry its config but go back to the old git hash, and get and use those files. Repair the bootstrap retroactively. Or again, patch the alloca with sed or such.
Older bootstraps also error some:
i.e. in functions that always throw.
At least when compiled as C++. Maybe C was OK?
Tony pointed out that C stands the test of time as a stable redistributable format, but there are gaps/flaws.
So disable that here. Current HEAD M3C.m3 outputs a pragma to disable it.
In time we might invest in "noreturn", but it is tricky matter, as to who knows what? How does what analysis?
Well, rather than marking these functions as anything, we should make M3Throw as noreturn.
A decent C++ compiler will either backpropagate that information and not warn because is not true, or not warn because it does no analysis. Maybe we self-inflict a problem here by wrapping longjmp in m3_longjmp.
In any case, move along, not much to see...