riscv: add bash configure script support for riscv#1904
riscv: add bash configure script support for riscv#1904Dead2 merged 1 commit intozlib-ng:developfrom
Conversation
|
""" WalkthroughThe changes introduce support for the RISC-V 64-bit architecture and its Vector Extension (RVV) into the build system. A new Makefile for RISC-V is added, specifying compilation rules for RVV-optimized source files and handling both regular and position-independent object files. The configure script is updated to detect the RISC-V architecture, test for RVV support, and adjust build variables and object lists accordingly. If RVV is available, appropriate compiler flags and source files are included in the build. The GitHub Actions workflows are extended to include RISCV64 cross-compilation and testing configurations. Standard cleaning and build targets are defined for the new architecture. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ConfigureScript
participant Compiler
participant Makefile
User->>ConfigureScript: Run configure
ConfigureScript->>Compiler: Detect architecture (riscv64)
Compiler-->>ConfigureScript: Returns architecture info
ConfigureScript->>Compiler: Test compile with -march=rv64gcv for RVV
Compiler-->>ConfigureScript: Success/Failure
alt RVV supported
ConfigureScript->>ConfigureScript: Set HAVE_RVV=1, update flags, add RVV objects
else RVV not supported
ConfigureScript->>ConfigureScript: Set HAVE_RVV=0, skip RVV objects
end
ConfigureScript->>Makefile: Generate/adjust Makefile with appropriate targets and flags
User->>Makefile: Build project (make)
Makefile->>Compiler: Compile RVV and other source files as needed
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
arch/riscv/Makefile.in (1)
6-11: Consider default values for build variables.Currently,
CC,CFLAGS, andSFLAGSare defined but not initialized to defaults. If the build environment fails to provide them, it may cause confusion.An example approach:
-CC= -CFLAGS= -SFLAGS= +CC ?= gcc +CFLAGS ?= -O2 +SFLAGS ?= -O2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
arch/riscv/Makefile.in(1 hunks)configure(2 hunks)
🔇 Additional comments (6)
configure (2)
346-347: Looks consistent with other architectures.Introducing a
riscv64)case under the existingARCHdetection logic aligns well with the structure used for other architectures. No immediate issues spotted with syntax or logic here.
1972-2004:Details
❓ Verification inconclusive
Verify backward compatibility with older RISC-V compilers.
While the RVV detection and flag application look correct, ensure that compilers lacking
-march=rv64gcvsupport gracefully proceed (or fall back) rather than failing outright.Would you like to confirm compatibility by compiling this snippet against an older RISC-V GCC toolchain?
🏁 Script executed:
#!/bin/bash # Checking if older RISC-V compilers gracefully ignore or fail on -march=rv64gcv echo 'int main(){return 0;}' > old_riscv_test.c "$CC" -march=rv64gcv $CFLAGS -o /dev/null old_riscv_test.c 2>&1Length of output: 171
Action Required: Validate Compatibility with Older RISC-V Compilers
It appears that the compatibility test using the
-march=rv64gcvflag didn’t run as intended because the$CCvariable wasn’t set (resulting in a "command not found" error). This makes it unclear whether older RISC-V compilers would gracefully ignore the flag or fall back properly. Please ensure that a valid, older RISC-V GCC toolchain is specified (by setting$CC) and re-run the check, or manually verify that unsupported compilers proceed without failure.arch/riscv/Makefile.in (4)
1-5: License headers are clearly stated.The inclusion of the copyright and distribution notice is explicit and straightforward.
19-24: Solid grouping of object files.Bundling all
.oand.lotargets together under thealltarget is a clear and concise approach, ensuring consistent build steps for both static and PIC artifacts.
26-55: Compilation rules appear correct.Each object file is compiled both normally and with
-DPICfor position-independent usage. This is standard practice for producing static and shared libraries.
56-63: Cleanup targets are comprehensive.The
mostlyclean,clean, anddistcleantargets effectively address temporary files, object files, coverage data, and Makefile removal, aligning with typical GNU conventions.
|
This needs CI run added to verify there is no errors or will be regressions. |
9a5f11d to
072c719
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
configure (1)
1649-1656: Consider using a defined constant for RVV capability detection.The code uses a bit shift operation
(1 << ('V' - 'A'))to check for the RISC-V Vector extension capability bit. Using a predefined constant likeHWCAP_ISA_V(if available in standard headers) might be more maintainable and less error-prone across different systems.- return (hwcap & (1 << ('V' - 'A'))); // HWCAP_ISA_V + // Use the defined constant if available, otherwise fall back to bit calculation + #ifdef HWCAP_ISA_V + return (hwcap & HWCAP_ISA_V); + #else + return (hwcap & (1 << ('V' - 'A'))); // HWCAP_ISA_V + #endif
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
arch/riscv/Makefile.in(1 hunks)configure(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- arch/riscv/Makefile.in
🔇 Additional comments (8)
configure (8)
102-102: New build flag for RVV support added correctly.The new
buildrvv=1flag follows the same pattern as other architecture-specific build flags.
121-121: New compiler flag variable for RVV added correctly.The
rvvflag=variable is properly initialized as an empty string, consistent with other architecture-specific compiler flags.
175-175: Help text added for the new command-line option.The help text for
--without-rvvfollows the established pattern and clearly describes its purpose.
212-212: Command-line option handling added properly.The
--without-rvvoption processing is correctly implemented, settingbuildrvv=0when specified.
350-351: RISC-V architecture detection added correctly.Detection for
riscv64architecture is properly implemented in the compiler detection phase.
1615-1663: RVV compiler flag detection function is comprehensive.The
check_rvv_compiler_flagfunction correctly:
- Tests for RVV-related march flags in order of preference
- Verifies RVV intrinsics compilation using the RISC-V vector header
- Checks for runtime detection support via auxiliary vector
The implementation follows the same pattern as other architecture-specific detection functions in the script.
2026-2050: RISC-V architecture-specific configuration is well implemented.The implementation correctly:
- Sets
QEMU_ARCH=riscv64for cross-compilation- Configures the architecture directory as
arch/riscv- Calls
check_rvv_compiler_flagwhen optimizations are enabled- Adds the appropriate RVV-specific object files when supported
- Appends
+rvvto the architecture stringThis follows the pattern established for other architectures and properly enables RVV optimizations when available.
1615-2050: Add CI testing for RISC-V configuration.As mentioned in PR comments, ensure that CI testing is set up for the RISC-V architecture support to verify that these changes work correctly and don't introduce regressions.
This could be tested by setting up a RISC-V build environment in CI or using emulation to verify the build process with various RVV-related options.
Hi, I have fixed some issues, tested in qemu and it seems working fine, so how can I get CI run for this MR? |
Edit |
|
Consider also adding it to pkgcheck.yml, that way it will build using both CMake and Configure and throw an error if they end up being different. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1904 +/- ##
===========================================
- Coverage 83.42% 81.96% -1.47%
===========================================
Files 144 146 +2
Lines 12948 13269 +321
Branches 2857 2944 +87
===========================================
+ Hits 10802 10876 +74
- Misses 1202 1446 +244
- Partials 944 947 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7d1fc6a to
785ce99
Compare
|
Hi, Any more comments here? |
Still fails CI... |
Summary by CodeRabbit
New Features
Chores