Repository navigation
Conversation
|
Wow, @Mellvik, this is some fantastic investigative and repair work you have accomplished, thank you!! You must be running on a very fast system to have the time and patience to have figured all this out, considering the build times and gcc complexities involved. I haven't had time to delve in to trying these (and don't have an ARM mac laptop yet) but thought to comment. There's an ELKS user with the fdopen problem I'll send over who will appreciate this major fix for Darwin users.
Amazing. How did you figure this one out?
Is GCC accepting a member of an alternate struct with
I think this problem was fixed by tkchia before he left GitHub in tkchia/gcc-ia16@a4c99e2. Are you using his latest git HEAD, or something prior? Because of all the problems of macOS compilation(s), I have held off with upgrading tools/Makefile to techie's latest, and am curious which commit you started with. Here's his last commits before leaving the platform. ELKS is using the build from Jan 18, 2023 and has not included the proposed host-hooks fix. Given that tkchia has left GitHub, do you think having a bug-fixed fork with these kinds of fixes are worthwhile? Our projects are dependent on the Github repo remaining, while most other repos were deleted just before the move to GitLab. I check over there occasionally, and don't see much action. Thank you for tackling this time-consuming set of problems, much appreciated!! |
Being stubborn is sometimes a trait, other times a curse. This time - on day 3 - it felt like the latter ... Getting the toolchain to work on my M1 was the first thing I did after forking ELKS 3 years ago. It took a few of hours - including writing the build instructions. I've been using those binaries since (I'm now in a M4 mini). The arrival of slightly 'hotter' M4 in the house (I convinced/coerced my wife to upgrade) prompted me to do a clean install of TLVC, a 'reference installation' if you like. And while expecting trouble with the cross tools build, I certainly didn't expect what I got. Yes, the M4s are indeed incredibly fast.
Not understanding how this could possibly be bad in one setting and good in another, I sent the entire error message to Google, and eventually found a German dude who had the exact same problem in a different context, and had more or less accidentally found the solution...
This is C++ code. I'm no good at that, so I ended up sending the problem to Claude, who (I hesitate to say 'who' about a machine ...) explained it and provided a fix. There is actually a logic to the fact that gcc is forgiving about the error. And that clang is going the more pedantic route. I can share the full response from Claude with you if you're interested. The short version is this: "Ah, I see the issue now! On line 481, the code is trying to access min as if it's a member variable, but min() is actually a member function (defined on line 197)."
I'm using the unmodified scripts from ELKS, the fork happened about that time. I need to look into this, there may be fixes no longer required here. Thanks!
I had forgotten about @tkchia's exit. Yes, I think that would be worthwhile. Our systems are completely dependent on these tools, and being able to fix bugs instead of patching around them (like I've done here) is the right way. I'm not a potential owner of such a project, but I could easily see myself as a contributor. Thanks. |
|
@ghaerr, I just tested the tool-versions from ELKS: they work fine, but don't fix the host_hooks issue. I'm pushing a final version of the new Makefile with the new(er) version numbers before merging. Thanks for the hint. |
Thanks for the testing. My plan is to move GCC_VER to the final Github version of ia16-elf-gcc (18 Feb 2024), which does include a host_hooks fix (from 4 Jul 2023), possibly in two commits: the first to fix all the issues above, and the second to increment the GCC_VER number greater than what ELKS has been fully tested with. There are a couple of commits that might change the gcc code generated, which I may want to test before jumping into. The good news is that the current host_hooks fix can likely be just "left in" tools/Makefile even when GCC_VER is incremented past tkchia's host_hooks fix without causing any problems. I will make a final decision on the GCC_VER increment after looking more closely at the actually GCC compiler modifications. |
| mv $(TMPFILE) binutils-src/zlib/zutil.h | ||
| # make sure we don't terminate on warnings | ||
| cd $(BUILDDIR)/binutils-src/bfd; \ | ||
| sed 's/development=.*/deveopment=false/' development.sh > $(TMPFILE); \ |
There was a problem hiding this comment.
Note: development=false is misspelled above, but seems to work because development=true isn't set.
There was a problem hiding this comment.
Oops, good catch, thanks. And you're right, it doesn't matter, but still wrong.
Building the TLVC toolchain on MacOS on ARM architecture systems has always been a challenge. Since MacOS 26/Tahoe, building has been an impossibility on all Macs. The TLVC/ELKS IA16 cross toolchain is created for gcc, not for
clang, and doesn't even try to recognize the Darwin/arm64 combination. And while the changes needed to get a build on the previous macOS v version and early M1-3 systems, it has now become a big deal.While some of the problems are easily fixed locally in the TLVC build scripts or Makefiles, most of them are inherent to the toolchain and must be fixed there, outside the direct reach from TLVC. Getting such changes prioritized may be a long shot though - and instead of waiting, this PR makes changes to the build process that automatically fix the problems. Changes are restricted to two TLVC files,
tools/build.shandtools/Makefile. Mere's a summary of the problems and how they are fixed:fdopenon the MacOS platform as it should but in the zlib directory forgets about it, and '#defines'fdopenas a NULL macro. This eventually creates a compilation error. Without even trying to find the root cause, the simple trick is toawkthe actual file,binutils-src/zlib/zutil.hto comment out the #define line. There are two occurrences of this - zlib exists in both the binutils chain and the gcc chain.sedwould be a more natural choice, butawkturned out to be simpler since we want to restrict the edit to one single occurrence.cross/build/binutils-src/bfd/development.shwheredevelopment=true. The top level Makefile changes this tofalsevia a simplesedcommand.options.h), where macros likeOPT_Oetc. are continuously being redefined. The solution is as weird as the problem: Make sure the locale-variable LC_COLLATE is set to "C". This problem will IOW hit only if your system is set up with a locale different from C (or possibly 'en_US'). The fix is to set this environment variable in thetools/build.shscript.gcc, the fibonacci heap code (gcc-src/gcc/fibonacci_heap.h) has syntax errors which interestingly are accepted by gcc but not by clang. Again asedcommand fixes is, changingif (heapb->min->compare (heapa->min) < 0)toif (heapb->m_min->compare (heapa->m_min) < 0).gcc/config/host-darwin.cfile, which turned out to be really hard withsedinside a Makefile, so awkward was used instead.Using
sed's in-place editing capability would be simpler than the (old fashioned) save-and-copy method, but the-ised-option turns out to be incompatible across platforms.The fixes have been added in such a way so as to not get in the way if the fixes have already been made or if running on other platforms. Tested on
Ideally most of these fixes should be applied to the toolchain itself, and that may happen at some time. For now this will do, and the changes should not be in the way whenever the toolchain gets updated.