casaroli opened a new pull request, #20530:
URL: https://github.com/apache/nuttx/pull/20530

   ## Summary
   
   `make export` now installs a compiler wrapper in the export package: 
`bin/nuttx-cc` and `bin/nuttx-c++`, with the flags of the configuration in 
`scripts/nuttx-cc.conf`. A program outside the tree can then be built with one 
compiler command:
   
   ```
   nuttx-cc -O2 -o hello hello.c
   ./configure --host=aarch64-none-elf CC=$EXPORT/bin/nuttx-cc
   ```
   
   * It compiles with `-nostdinc`, the exported headers and the compiler's own 
headers, so a header that NuttX does not have is reported missing and not taken 
from the toolchain's C library.
   * It keeps the CPU, ABI and define options of the configuration and leaves 
out its warning options (`-Werror` and others).
   * When it links, it adds `startup/crt0.o`, `scripts/gnu-elf.ld` (if the 
package has it) and, in a kernel build, the user-space libraries. Paths into 
the build tree, which some boards put in `LDELFFLAGS`, are left out.
   * In a kernel build a program is a relocatable (`-r`) ELF, and a relocatable 
link does not fail on an undefined symbol. Nothing resolves the symbol at load 
time, so the wrapper checks with `nm` and fails the link.
   * It finds the package from its own location, so the package can be moved to 
another computer.
   
   Documentation: `Documentation/components/tools/nuttx-cc.rst`.
   
   ## Impact
   
   `make export` and the export package only. No change to the target code. The 
CMake build has no export target.
   
   ## Testing
   
   * `qemu-armv8a:knsh`: export built on macOS. A test program built with 
`nuttx-cc` on macOS, and in a Debian arm64 container with the Linux-host Arm 
GNU 14.2 toolchain, runs on the target (QEMU 11) from hostfs: arguments, 
environment, `stat()` and floating-point `printf()` are correct.
   * An undefined function makes the link fail and removes the output; `-c` 
still works.
   * `mps2-an500:nsh` (flat build): the export works, and the wrapper compiles 
and links a test program (a relocatable ELF whose undefined symbols the 
firmware symbol table resolves).
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to