patacongo commented on pull request #3589: URL: https://github.com/apache/incubator-nuttx/pull/3589#issuecomment-828071751
No, your understanding is not quite correct. In the FLAT build, only one copy of the libraries is built. The OS and the applications link to the same libraries. For example, libs/libc builds libc.a for both the applications and the OS code. Only a single libc.a is needed because only one "blob" is built. In the PROTECTED and KERNEL builds, the applications and OS are separately linked: two blobs for the PROTECTED case and many for the KERNEL case. And two different libraries are built: libuc.a for the user/application space blob and libkc.a for the kernel-space OS blob. These blobs are different because applications and the OS use different different interfaces. The application, for example, never calls directly into the OS but gets into the OS via system calls (call gates that switch from user to supervisor modes). When building the application space library, libuc.a, __KERNEL__ must not be defined. This tells the system that we are building the application space version of the library. For libkc.a, __KERNEL__ must be defined. This tells the build that we are building for code that runs inside the OS. This is done via a two pass build. For the PROTECTED mode, the application blob is built first and linked with the system call proxies. In the second pass, the OS blob is built and linked with the system call stubs. KERNEL mode is a little different because the applications are build as executable that run from a file system, much like with Linux. Part of the build is manual. That is description in board README's like boards/arm/sama5/sama5d4-ek/README.txt for knsh cconfiguration. The simulator also depends on a 2-pass build, but for different reasons. See boards/sim REAME file. Please be careful and don't break. This is pretty complex and delicate logic and critical to the future of the OS. Greg On 4/27/2021 4:41 PM, Matias N. wrote: > > I made some more progress and I realize I now need to correctly handle > |__KERNEL__|. So far I used this for all static libs created from > top-level directories but I realize this is not correct. My > understanding is that this should not be defined for subdirectories of > |libs|, |mm| nor for applications. Any other OS library should have it > defined. Is that correct? > > I realize this ties into the two-pass build (which I haven't fully > looked into yet) and kernel/protected mode. Do both of these modes use > the two-pass build? Is there any documentation and how the build > system works in this case? I'm looking at the makefiles but it isn't > very clear to me how it all works together. > > cc: @patacongo <https://github.com/patacongo> > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/apache/incubator-nuttx/pull/3589#issuecomment-827992528>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABFUG6WGONHLFS4YVXSHQR3TK44PZANCNFSM43MSFWZQ>. > -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
