From 9391f38c6f1b4ae70cb937ea5c1a0d10bd228253 Mon Sep 17 00:00:00 2001 From: LunaStev Date: Sat, 13 Dec 2025 16:09:22 +0900 Subject: [PATCH 1/2] feat: add LLVM backend version reporting and improve help formatting Add compile-time LLVM version detection and display in --version output, plus improve help text readability with aligned columns. Changes: - Set LLVM version at build time via cargo:rustc-env: - Export WAVE_LLVM_MAJOR=14 in all platform-specific linkers - Linux (linux_original), macOS (link_macos), Windows (link_windows) - Add backend() function to llvm_temporary/lib.rs: - Retrieve WAVE_LLVM_MAJOR from compile-time environment - Return formatted string "LLVM {version}" or None - Display backend version in --version output: - Call llvm_temporary::backend() from version_wave() - Print "backend: LLVM 14" with gray color formatting - Fallback to "backend: unknown backend" if unavailable - Improve help text formatting in print_help(): - Use consistent column width alignment ({:<18}, {:<22}) - Add descriptive text for each command and option - Group related options (Commands, Optimization, Debug) - Expand optimization flag descriptions (-O0..-O3, -Oz, -Ofast) - Clarify debug option purposes (tokens, AST, IR, MC, hex) - Keep practical usage examples at bottom Output example: wavec 0.1.5-pre-beta (Linux 6.x.x) backend: LLVM 14 This provides transparency about the compiler toolchain configuration and improves CLI user experience with readable help formatting. Signed-off-by: LunaStev --- llvm_temporary/build.rs | 4 ++ llvm_temporary/src/lib.rs | 5 +++ src/lib.rs | 7 ++++ src/main.rs | 81 ++++++++++++++++++++++++++++++++------- 4 files changed, 84 insertions(+), 13 deletions(-) diff --git a/llvm_temporary/build.rs b/llvm_temporary/build.rs index 1e503370..616d9385 100644 --- a/llvm_temporary/build.rs +++ b/llvm_temporary/build.rs @@ -27,6 +27,8 @@ fn linux_original() { println!("cargo:rustc-link-lib=llvm-14"); println!("cargo:rustc-link-search=native=/usr/lib/llvm-14/lib"); + println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14"); + println!("cargo:rustc-link-lib=stdc++"); println!("cargo:rustc-link-lib=ffi"); println!("cargo:rustc-link-lib=z"); @@ -53,6 +55,7 @@ fn try_macos_paths() { } fn link_macos(prefix: PathBuf) { + println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14"); let lib = prefix.join("lib"); println!("cargo:rustc-link-search=native={}", lib.display()); @@ -83,6 +86,7 @@ fn try_windows_paths() { } fn link_windows(prefix: PathBuf) { + println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14"); let lib = prefix.join("lib"); println!("cargo:rustc-link-search=native={}", lib.display()); diff --git a/llvm_temporary/src/lib.rs b/llvm_temporary/src/lib.rs index e4cbf9fe..976c7508 100644 --- a/llvm_temporary/src/lib.rs +++ b/llvm_temporary/src/lib.rs @@ -1 +1,6 @@ pub mod llvm_temporary; + +pub fn backend() -> Option { + option_env!("WAVE_LLVM_MAJOR") + .map(|v| format!("LLVM {}", v)) +} diff --git a/src/lib.rs b/src/lib.rs index b3471a91..99b70664 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ use colorex::Colorize; use crate::version::get_os_pretty_name; use commands::DebugFlags; +use llvm_temporary::backend; pub unsafe fn compile_and_run(path: &Path, opt_flag: &str, debug: &DebugFlags) { runner::run_wave_file(path, opt_flag, debug); @@ -26,4 +27,10 @@ pub fn version_wave() { version::version().color("2,161,47"), os ); + + if let Some(backend) = backend() { + println!(" backend: {}", backend.color("117,117,117")); + } else { + println!("{}", " backend: unknown backend".color("117,117,117")); + } } diff --git a/src/main.rs b/src/main.rs index 685c310a..2b03144a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,29 +85,84 @@ fn print_usage() { } fn print_help() { - println!("{}", "Wave Compiler — Commands & Options".color("145,161,2")); + println!("{}", "Wave Compiler".color("145,161,2")); + println!("{}", "Commands & Options"); print_usage(); println!("\nCommands:"); - println!(" {} {}", "run ".color("38,139,235"), "Execute Wave file"); - println!(" {} {}", "build ".color("38,139,235"), "Compile Wave file"); - println!(" {} {}", "--help".color("38,139,235"), "Show help"); - println!(" {} {}", "--version".color("38,139,235"), "Show version"); + println!( + " {:<18} {}", + "run ".color("38,139,235"), + "Execute Wave file" + ); + println!( + " {:<18} {}", + "build ".color("38,139,235"), + "Compile Wave file" + ); + println!( + " {:<18} {}", + "--help".color("38,139,235"), + "Show this help message" + ); + println!( + " {:<18} {}", + "--version".color("38,139,235"), + "Show compiler version" + ); println!("\nOptimization:"); - println!(" -O0, -O1, -O2, -O3, -Oz, -Ofast"); + println!( + " {:<18} {}", + "-O0 .. -O3".color("38,139,235"), + "Set optimization level" + ); + println!( + " {:<18} {}", + "-Oz".color("38,139,235"), + "Optimize for binary size" + ); + println!( + " {:<18} {}", + "-Ofast".color("38,139,235"), + "Enable aggressive optimizations" + ); println!("\nDebug options:"); - println!(" --debug-wave=tokens"); - println!(" --debug-wave=ast"); - println!(" --debug-wave=ir"); - println!(" --debug-wave=mc"); - println!(" --debug-wave=hex"); - println!(" --debug-wave=all"); + println!( + " {:<22} {}", + "--debug-wave=tokens".color("38,139,235"), + "Print lexer tokens" + ); + println!( + " {:<22} {}", + "--debug-wave=ast".color("38,139,235"), + "Print AST" + ); + println!( + " {:<22} {}", + "--debug-wave=ir".color("38,139,235"), + "Print LLVM IR" + ); + println!( + " {:<22} {}", + "--debug-wave=mc".color("38,139,235"), + "Print machine code" + ); + println!( + " {:<22} {}", + "--debug-wave=hex".color("38,139,235"), + "Print raw hex output" + ); + println!( + " {:<22} {}", + "--debug-wave=all".color("38,139,235"), + "Enable all debug outputs" + ); println!("\nExamples:"); println!(" wavec run test.wave"); println!(" wavec run -O3 test.wave"); println!(" wavec run --debug-wave=ir test.wave"); println!(" wavec run -Ofast --debug-wave=all test.wave"); -} \ No newline at end of file +} From 345367dc43730a409e162d42c7e6b2cf40a86e3f Mon Sep 17 00:00:00 2001 From: LunaStev Date: Sat, 13 Dec 2025 16:32:01 +0900 Subject: [PATCH 2/2] add fedora ci Signed-off-by: LunaStev --- .github/workflows/rust.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c5d5c957..4a402dac 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -31,6 +31,27 @@ jobs: - name: Run tests run: cargo test --verbose + build-fedora: + runs-on: fedora-latest + + steps: + - uses: actions/checkout@v4 + - name: Install LLVM 14 + run: | + sudo dnf update + sudo dnf install -y llvm14 llvm14-devel clang clang-libs + sudo ln -s /usr/lib64/llvm14/lib/libLLVM-14.so /usr/lib64/libllvm14.so + - name: Set LLVM environment variables + run: | + export LLVM_SYS_140_PREFIX=/usr/lib64/llvm14 + - name: Build + run: | + source ~/.bashrc + cargo clean + cargo build --verbose + - name: Run tests + run: cargo test --verbose + build-macos: runs-on: macos-latest