-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AVR] standard library support for AVR #75127
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
[AVR] standard library support for AVR #75127
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test |
OK @kubamracek, I addressed a couple of your suggestions, they were all good ideas. I also sent up a small patch on The last couple of days I've been flexing the muscles of the compiler with this patched standard library and trying to build our core hardware library, which is a good test! This fix came out of that work, along with a load of other cherry-picks from other compiler work I've needed in the past... none of which are suitable for this PR! They will come later, if required. There are question marks around the synchronisation stuff here. that might be a bit of a hack to get things compiling and I'm not sure it's right. The big question is around what to do with String. As discussed elsewhere! |
DoneOn 15 Jul 2024, at 23:06, Kuba (Brecka) Mracek ***@***.***> wrote:
@kubamracek commented on this pull request.
In stdlib/public/Synchronization/Atomics/AtomicFloats.swift:
@@ -118,7 +118,7 @@ extension Float: AtomicRepresentable {
// Double AtomicRepresentable conformance
//===----------------------------------------------------------------------===//
-#if (_pointerBitWidth(_32) && _hasAtomicBitWidth(_64)) || _pointerBitWidth(_64)
+#if ((_pointerBitWidth(_32) || _pointerBitWidth(_16)) && _hasAtomicBitWidth(_64)) || _pointerBitWidth(_64)
Hmm, now I wonder if we could just for the sake of keeping the size of this PR sane, postpone the porting of the Synchronization library (by not building it for AVR with the same CMake logic you use in the Unicode library). Would you mind doing that and then we can follow up on this after we get the stdlib to build? Thanks :)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@swift-ci please test |
I've reviewed the whole PR, I don't have any more comments besides the ones I just added, with those addressed, I think this PR is ready to go, assuming it passes tests. But let's please also give @phausler a chance to review. Great work, @carlos4242 ! |
- when compiling embedded cross compile target standard libraries, include AVR - add 16-bit pointer as a conditional compilation condition and get the void pointer size right for gyb sources - attempt to fix clang importer not importing __swift_intptr_t correctly on 16 bit platforms - changed the unit test target to avr-none-none-elf to match the cmake build [AVR] got the standard library compiling in a somewhat restricted form: General - updated the Embedded Runtime - tweaked CTypes.swift to fix clang import on 16 bit platforms Strings - as discussed in https://forums.swift.org/t/stringguts-stringobject-internals-how-to-layout-on-16-bit-platforms/73130, I went for just using the same basic layout in 16 bit as 32 bit but with 16 bit pointers/ints... the conversation is ongoing, I think something more efficient is possible but at least this compiles and will probably work (inefficiently) Unicode - the huge arrays of unicode stuff in UnicodeStubs would not compile, so I skipped it for AVR for now. Synchronization - disabled building the Synchronization library on AVR for now. It's arguable if it adds value on this platform anyway.
58c09af
to
3689427
Compare
Hi @kubamracek @rauhul, the test currently failing is The error output from lit is...
I'm thinking, perhaps it makes sense that these not be present on the standard library on MacOS? I think the change that broke this is probably adding 16 bits to this section in
There's two or three approaches we can take. Firstly, simplest, I can just revert this change? I've already removed all the other work on atomics and the synchronisation library from this PR. Secondly, I can change the above so that it only runs for a number of bits suitable for the platform, so that 16 bit is only emitted for the AVR standard library? Or lastly, if this should be present, presumably I can change the test to pass on MacOS and add ss32_swift_stdlib_atomicFetchOrInt166object7operands0F0VSpyAEG_AEtF etc. to the expected symbols from the standard library. What do you think is the best approach? If you have no opinion, I'll probably just revert the original change that broke this test, as it's the simplest approach. |
This ABI/API addition seems pretty reasonable to me, but neither me nor @rauhul can sign off on that, that's more of a question for @lorentey and maybe @phausler. In any case, I think it should go in as a separate change, so what I'd suggest is to drop that change for now, and let's see what @lorentey and @phausler say -- if the change is useful then let's have a separate PR for it. |
@swift-ci please test |
I suggest we change the test back to only do -typecheck instead of -emit-ir. And then work on fixing this separately. |
Alright. I’ve seen a lot of these cast fails over the years. They’re nearly always address space issues. The front end doesn’t take account of program address space. To be fair it’s a fairly new part of llvm. It was only added to support the AVR platform a few years ago!On 17 Jul 2024, at 04:22, Kuba (Brecka) Mracek ***@***.***> wrote:
FAIL: Swift(macosx-x86_64) :: embedded/avr/testStdlibFunctioning.swift (9815 of 18049)
******************** TEST 'Swift(macosx-x86_64) :: embedded/avr/testStdlibFunctioning.swift' FAILED ********************
Script:
--
: 'RUN: at line 1'; ...
--
Exit Code: 134
Command Output (stderr):
--
<unknown>:0: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=<mcu name>
Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file Instructions.cpp, line 3427.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: ...
1. Apple Swift version 6.0-dev (LLVM 4ee06774aa7ace9, Swift 42aa116)
2. Compiling with effective version 4.1.50
3. While evaluating request IRGenRequest(IR Generation for module testStdlibFunctioning)
4. While emitting IR SIL function ***@***.***_once".
I suggest we change the test back to only do -typecheck instead of -emit-ir. And then work on fixing this separately.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
OK done. |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the standard library side looks pretty good to me. The one place where I am not sure 100% is the string side of things - I will try to drudge up some additional reviews for ya
@swift-ci please test Linux platform |
I must admit I can't understand the logs from the linux test run failure. Are they real test failures do you think? |
@swift-ci please test linux |
The linux failures don't seem to be something that would be caused by this set of changes from what I can tell. It did not introduce a |
OkHopefully rerunning it will fix them. Thanks PhilippeOn 17 Jul 2024, at 23:14, Philippe Hausler ***@***.***> wrote:
The linux failures don't seem to be something that would be caused by this set of changes from what I can tell. It did not introduce a --parallel option, nor did it remove that.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@swift-ci please test Linux platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me.
Lots of green checks, I'll go ahead and merge |
Standard library support for AVR
@kubamracek this is the first attempt to get the standard library compiling