-
Notifications
You must be signed in to change notification settings - Fork 36
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
Error building Swift 5.2 #66
Comments
Yup, I hope this is the last one, tried a few things but haven't fixed it yet. |
++ needs a release update for swift-tools v5.2 on my end (paging @uraimo) |
Any plans to put out a 5.3 build? I just put out a release for Android ARMv7, termux/termux-packages#5843, and you'll be happy to know it didn't require much patching (though I now see you hit that |
Hey @buttaface , quite happy indeed, since I see no problem in skipping 5.2 altogether and go straight to 5.3, I'll launch a build and see how it goes. |
I don't know to what extent, but I assume completely since basic constants like Does a basic Swift file like this compile with 5.1 on ARM?
That works for me on AArch64, but with the Android ARMv7 compiler I get:
|
Can confirm it works with 5.1.5, I've aligned all the patches to 5.3 (added the static linking fix too as you did) and I'm building now. Are you sure that the patch for FSWatch is enough? It's only the first half of mine. |
Good to know, that means diffing that Swift ClangImporter source to 5.3 might turn up something, assuming you hit this bug with 5.3 too.
Nice, use the original patch from the release/5.3 branch, not mine, as mine is tweaked a little to account for my other Android patches.
Yep, it's enough to build SPM, and that code is not tested normally or may not even be used for all I know. I'm suspicious that their code divides by different numbers for |
I patched that more than one year ago but never added it upstream because a cleaner solution would have been to import that stuff in the swift glibc shim (takes more time 😅) instead of reimplementing it like they did in 5.0 (see #41) |
Btw, the static stdlib patch I used is mostly swiftlang/swift@e8fe229 combined with a one-line fix added later, swiftlang/swift@da65420, and of course a couple Android tweaks. |
Any luck with that build or is it still compiling? 😉 I tracked that Macro ClangImporter bug to when it's loading C modules in Since the same code works fine on AArch64, I don't know if this is a portability mixup somewhere or a codegen bug, as sticking those printfs in the relevant LLVM function called from Anyway, let me know if you hit the same bug with your glibc/ARM builds, could be a Bionic issue for all we know. |
Just finished a few seconds ago, both armv7 and armv6 still fail with the same error, very strange, I wonder what's different for the android target+your patches, nothing in the patches seems to be able to fix the error above. |
This could also be some sort of regression introduced by the patch for the static linking issue, looking at the files it touches, hmm. |
Ok, noticed that an armv6 patch got applied to armv7 too, giving it another try, brb (6 hours). |
Meaning you cannot import Macro constants too? Does hello world work? That is fine on Android ARMv7 and I'm also able to build a Swift package like swift-numerics with SPM, though building its tests fails. |
Sadly no, I still have the original alignment error reported here... and the last build failed again. |
Is that |
Here's the list of compiler flags used to compile
|
It's probably still necessary since there are assertions that verify the alignment somewhere else in the source for this type (found them a few months ago), already tried removing it, without that a few things started to fail when compiling some files in the stdlib, es:
If I remember correctly even removing all of these to see what's next, you hit one of those assertions on alignment. The clang options are the same, I've just a few additional defines |
Hmm, that is weird: are you compiling natively or cross-compiling? I'm doing the latter and I use the Android NDK clang to cross-compile the Swift compiler, so our different results could be because the Swift-forked clang acts differently. I've now cross-compiled a debug build of the Swift compiler and will be tracing that C module visibility issue in lldb. |
Natively and in my case it should be using the llvm toolchain included with swift, another thing that could be happening is some wrongly sized field imported by some obscure include... yep, the setup is very different, anything could be happening. |
I just looked into it and the native build uses the host clang to build the Swift compiler, ie the same host clang used to compile the LLVM toolchain source shipped with Swift, the ninja command above should tell you which clang. You could try building the Swift compiler with the freshly-built Swift-forked clang instead, by copying these two lines and pasting them here. |
Fixed my Macro ClangImporter issue and seem to have a working toolchain on Android ARMv7, though I haven't run the Swift testsuite to make sure. My problem turned out to be a mismatch between the preprocessor defines set when compiling the LLVM backend versus the Swift frontend, you may want to double-check those defines for your build and see if that's a problem for you too. |
Got my ARM patch merged upstream, swiftlang/swift#34160, you may want to backport it to 5.3, as I do for my Android build, and try that. |
Thanks for the heads up... I've been kinda MIA lately but will be back. |
I get this alignment error reported here when I am trying to build Swift 5.2.5 on Ubuntu server 20.04 (32 bits) with Raspberry PI 3B+. This error is it fixed? If so, where can I find the patch? Thanks in advance |
No, it's not fixed, which is why this repo is still stuck at 5.1.5. I build the Swift toolchain for Android ARMv7 and haven't had that problem there, so it may be an issue in the glibc headers causing this, which isn't there in Android's BSD-derived Bionic libc. |
Thanks for the info. I am going back to the Ubuntu focal's 64-bit release, for which swift 5.3 works. |
I'm going to try and help fix this. I have a desire to use swift on some odroid boards here, and being stuck on 5.1.5 just won't cut it. I'm new to compiling swift itself, but i've done the following already:
I'm going to keep at it. If anyone has any ideas or hints I should try, please let me know. |
While the scripts are building llvm, i noticed that it appears to be using the wrong triple argument
In other calls I see running I see it using the correct triple (armv7l). I am currently trying to track down where/why the wrong triple is happening. [edit] |
That's actually perfect; I applied a patch I found for the crash I reported. Now I am crashing with the same error you are.
|
I switched back to work 5.3 dev and I seem to have a working release installation with it. All patches for 5.3 specifically can be found here. Moving on to testing it on some of my bigger projects now. [edit] Tested my project, seems to run great; no performance issues as related in that other ticket[/edit] |
Makes sense, as 5.3 works well for me on Android armv7, before these stdlib issues cropped up. You should probably look at re-enabling that LLVM pointer alignment error once you find what's triggering it. Since I don't hit it with Bionic, my guess is that something in a glibc header is throwing off some struct alignment on linux armv7. |
Great work so far. 5.3 would be way better than 5.1, so could I ask you for a binary release? The big things are coming forward with 5.5 though (async, actors, enhanced protocols and property wrappers), so it might as well make sense to skip 5.4 and have a look whether it would be possible to get some patches into mainline? |
Getting back to this now, I suspect the stdlib assertion when optimized is related to that issue with prespecialized generic metadata: @KittyMac, did you try applying that upstream compiler pull that disabled it altogether? I'm going to try applying it and building the Swift 5.4 compiler from scratch. |
@buttaface I haven't done any more since I got 5.3 working; its been working 100% for me so I've been content to move on. Is this the patch you are referring to? I can give it a whirl and see if it fixes it. |
Yep, that's the one: apply it instead of mine that modified |
Yeah, that's it. Applying that compiler patch gets the Swift 5.4 stdlib working for me for Android armv7 again, I can use SPM to build and test packages again. @drexin, what do you think about getting swiftlang/swift#36658 merged into the 5.4 branch for the next point release? |
so if i pull the latest 5.4 release and apply that patch should i be able to build an armv7 swift compiler? or is there a list of other patches I need? having that is the first step in building my mac -> pi cross-compiler chain is why I ask. i'm hoping to teach on that next spring. |
@buttaface happy to report that patch fixed it for me as well; Swift 5.4 on Ubuntu 18.04 armv7 release build. I compiled and ran my large swiftpm project without issue. @rvsrvs I needed more than just this last patch. Full list of patches I used are on my fork here |
Sorry to drop in like this now guys, @KittyMac do you plan to open a PR to merge it (optional)? |
Thanks @KittyMac , I'm importing everything in a swift-5.4 branch and doing some test. The legendary a92236 that has been there since 2015 for an llvm and a few other more related to syntax were not present in the dev branch so I'm going to verify if we still need them, likely not. |
I noticed under 5.3 that there had been changes to the way the triples for the compiler were generated. Wonder if there's one now for arm6 so that I don't have to build an entire swift toolchain to cross-compile for the pi zero. |
I built 5.5-05142021 yesterday (Ubuntu 18.04 armv7 release build); ran a simple actor/await/async thing, appeared to work. |
I'm seeing segfaults when building with the latest Swift 5.5 June 13 source snapshot on Android armv7, some other issue has come up. |
Alright, I have the Swift 5.5 source snapshots working again on Android armv7, some linker issues that shouldn't hit on linux. Btw, @uraimo, someone on the forums was having problems building a recent NIO with Swift 5.1, some problem getting Swift 5.4 into the arm apt repos? |
fyi @uraimo the 5.4 branch builds on ubuntu focal armv7 out of the box. Doesn’t seem to build on Raspbian. Looking at why. And I can’t find the magic to get the Pi Zero to even successfully clone. Any advice? |
I've been building Swift 5.5 just fine for Android armv7 with these patches, though most are for cross-compiling to Android. However, I'm seeing errors compiling the last trunk snapshot from Dec. 23 for Android armv7 (which is technically 5.7/6.0, since it's after the recent Swift 5.6 branch), patches here, when cross-compiling some C++ files in the Swift compiler. I have not looked into those issues, just a head's up that you may hit them too. Update: this is the error I'm seeing, guessing it will hit you too. |
Now that Swift 5.6 is out, I kicked off a build for Android armv7, which is still failing with the same compilation error:
It appears the compiler is trying to place a small integer into a pointer, a pointer union in this case, and failing to get enough space at compile-time, because the pointer union likely doesn't have enough bits available in a 32-bit pointer, as it normally would in a 64-bit pointer on common platforms. Since this code is all fairly old and had been compiling for a while, my guess is that one of those constituent pointers changed last year, making less bits available to the pointer union. If anyone is more familiar with these constexpr/template issues, let me know what you think. I try to avoid C++ as much as possible. |
Found a later trunk commit by @xedin that fixes that compile-time issue, after a suggestion by @kateinoigakukun of what header to look at. I ran the resulting 5.6.1 toolchain for Android armv7 on my Android AArch64 phone and was able to build and test several Swift packages for armv7 without a problem. |
@futurejones has announced an armv7 CI running on his AArch64 server on the Swift forum, though it currently fails when building the stdlib. He plans to take outside pulls to get that going, which I'll chip into, maybe others here will too. Perhaps he will make available those armv7 toolchain builds once it is working. |
@colemancda just announced a build of the latest Swift 5.7.1 release for linux armv7, try it out and let him know how it works there. |
@buttaface I have been working with @futurejones in the Swift ARM Slack and he was been updating his repos with my binaries. |
Good to hear your build will be added to Neil's repos. Personally, I hate Slack and avoid it as much as possible. I'd be happy to communicate over email or something else instead. |
I am trying to build Swift 5.2 on Raspbian Buster and get keep getting the following error.
The text was updated successfully, but these errors were encountered: