Skip to content
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

tools: Export LLVM flags for kernel build #15696

Merged
merged 1 commit into from
Jan 26, 2025
Merged

Conversation

no1wudi
Copy link
Contributor

@no1wudi no1wudi commented Jan 26, 2025

##Summary

  • Added LLVM_ARCHTYPE, LLVM_CPUTYPE, and LLVM_ABITYPE to the exported build configuration in both Export.mk and mkexport.sh
  • These flags are now included in the generated makeinfo.sh, Make.defs, and target.cmake files during the export process

##Impact

  • Enables LLVM-specific build configurations to be properly exported and used in kernel builds
  • Improves compatibility with LLVM-based toolchains by ensuring necessary architecture, CPU, and ABI information is available during the build process
  • No functional changes for non-LLVM builds, as these flags are only used when LLVM toolchains are specified

Testing

GitHub CI and local board

Summary:
- Added LLVM_ARCHTYPE, LLVM_CPUTYPE, and LLVM_ABITYPE to the exported build configuration in both `Export.mk` and `mkexport.sh`
- These flags are now included in the generated `makeinfo.sh`, `Make.defs`, and `target.cmake` files during the export process

Impact:
- Enables LLVM-specific build configurations to be properly exported and used in kernel builds
- Improves compatibility with LLVM-based toolchains by ensuring necessary architecture, CPU, and ABI information is available during the build process
- No functional changes for non-LLVM builds, as these flags are only used when LLVM toolchains are specified

Signed-off-by: Huang Qi <[email protected]>
@github-actions github-actions bot added Area: Tooling Area: Build system Size: XS The size of the change in this PR is very small labels Jan 26, 2025
@no1wudi
Copy link
Contributor Author

no1wudi commented Jan 26, 2025

@lupyuen Could you try this patch for rust support with kernel mode?

@lupyuen
Copy link
Member

lupyuen commented Jan 26, 2025

Sorry @no1wudi the hello_rust_cargo ELF seems to be missing from apps/bin? Other apps are OK. Thanks :-)
https://gist.github.com/lupyuen/98e110d5228c9d2eaee16e8a3734055b

$ tools/configure.sh rv-virt:knsh64

nsh> uname -a
NuttX 10.0.1 caebb3ecc2 Jan 26 2025 12:41:22 risc-v rv-virt

nsh> hello
Hello, World!!

nsh> hello_rust_cargo
nsh: hello_rust_cargo: command not found

$ ls -l ../apps/bin
total 496
-rwxr-xr-x@ 1 luppy  staff  21504 Jan 26 12:41 getprime
-rwxr-xr-x@ 1 luppy  staff   9048 Jan 26 12:41 hello
-rwxr-xr-x@ 1 luppy  staff  64864 Jan 26 12:41 init
-rwxr-xr-x@ 1 luppy  staff  83296 Jan 26 12:41 ostest
-rwxr-xr-x@ 1 luppy  staff  64864 Jan 26 12:41 sh

$ grep HELLO_RUST_CARGO .config
CONFIG_EXAMPLES_HELLO_RUST_CARGO=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO_PROGNAME="hello_rust_cargo"
CONFIG_EXAMPLES_HELLO_RUST_CARGO_PRIORITY=100
CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE=16384

@no1wudi
Copy link
Contributor Author

no1wudi commented Jan 26, 2025

So for this issue it's not enough by just add LLVM relative flags, it can make Rust app build as static lib, but need further work to build an ELF file from Rust toolchain directly.

@xiaoxiang781216 xiaoxiang781216 merged commit 49dd1e0 into apache:master Jan 26, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Build system Area: Tooling Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants