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

[SR-16005] RFE: RISCV64 Support #58266

Closed
colemancda opened this issue Mar 17, 2022 · 12 comments · Fixed by apple/swift-tools-support-core#360 or #61815 · May be fixed by #61891 or apple/llvm-project#5551
Closed

[SR-16005] RFE: RISCV64 Support #58266

colemancda opened this issue Mar 17, 2022 · 12 comments · Fixed by apple/swift-tools-support-core#360 or #61815 · May be fixed by #61891 or apple/llvm-project#5551
Assignees
Labels
architecture support compiler The Swift compiler in itself feature A feature request or implementation riscv Architecture: RISC-V standard library Area: Standard library umbrella

Comments

@colemancda
Copy link
Contributor

Previous ID SR-16005
Radar None
Original Reporter @colemancda
Type New Feature
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels New Feature
Assignee @colemancda
Priority Medium

md5: 8edf88e5efa8c04d21ce395d890ee837

Issue Description:

Swift should support compiling to riscv64.

@colemancda
Copy link
Contributor Author

Attached Swift 5.6 patches for RISCV64.

@colemancda
Copy link
Contributor Author

Failing to build StdLib due to being unable to pass `-mno-relax` to the Swift compiler / linker.

ld.lld: error: stdlib/public/core/LINUX/riscv64/Swift.o: cannot link object files with different floating-point ABI
ld.lld: error: Swift.o🙁.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax

@colemancda
Copy link
Contributor Author

@buttaface Do you have any suggestions? Everything from the compiler to the StdLib is building, but its failing at the linking stage. Passing `-mno-relax` to the Cmake C Flags fixes all C and C++ linking (e.g. libdispatch and Swift Runtime) but not sure how to pass to C compiler.

@colemancda
Copy link
Contributor Author

CodaFi (JIRA User) I have tried a lot of options based on your document https://gist.github.com/CodaFi/b1e0d0f37cd2890c07c5 and passing them via `
-DSWIFT_STDLIB_EXTRA_SWIFT_COMPILE_FLAGS` to cmake for cross compiling the StdLib.

@finagolfin
Copy link
Contributor

@colemancda
Copy link
Contributor Author

@buttaface Your suggestion helped me overcome the linking issue. Now my issue is that my C nd C++ code is being compiled with hard float (double) but the Swift code is not. Swift doesn't have the `-march`, `-mabi` `-mcpu` flags that Clang does. To my knowledge, based on review of Clang's code, when targeting Linux and RISCV64, if none of that is specified, it will default to lp64d .

@colemancda
Copy link
Contributor Author

I can attempt to build the Linux image with Soft Float ABI, but there will be a significant performance penalty. Also pretty much all RISC64 cores available to buy have double Float support, hence why Buildroot makes it the default.

@colemancda
Copy link
Contributor Author

(bullseye)root@mac-mini:/home/coleman/Developer/buildroot# /usr/sbin/chroot ./output/target/ /usr/bin/qemu-riscv64-static /usr/bin/hello
Hello, world!

@colemancda
Copy link
Contributor Author

I got the RISCV64 Soft Float build working.

@colemancda
Copy link
Contributor Author

@colemancda
Copy link
Contributor Author

#42055

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@colemancda
Copy link
Contributor Author

Opened new PRs

#61815
apple/swift-tools-support-core#360

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture support compiler The Swift compiler in itself feature A feature request or implementation riscv Architecture: RISC-V standard library Area: Standard library umbrella
Projects
None yet
3 participants