-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[compiler] Add ability to specify arch
when compiling Swift
#61908
Comments
I don't think that there is. This is why I had stopped the RISCV64 port that I was doing :). There was more stuff that I needed to finish off in the IRGen/LLVM side of the world. You are going to have to make code changes for that. Note that |
Well, I have it working with Soft Float since Swift 5.6, so that's doable with Buildroot. Compiling Swift for Debian |
I am going try my alternative and modify |
@colemancda sorry I'm not sure what you are proposing here. I don't think it is sufficient to just modify the target parser. Also, note that with the next rebase we should be able to enable the relaxation. The |
Ok, well at least this is documented somewhere and my hours digging will help someday. Would be cool for Swift 6.0 release. |
Even when specifying the arch, Swift is still being compiled targeting Soft Float. What is off is that I was able to target |
I don't think this issue is valid as described. You can pass |
Is your feature request related to a problem? Please describe.
I'm trying to build Swift for RISCV64 where the C and CXX code is all built with the following Clang flags:
When building the Swift StdLib, the C and CXX sources are compiled and linking correctly with the Linux runtime libraries, but the Swift sources are built targeting soft float ABI and the linking phase fails. I have been able to convert the following Clang arguments to their
swiftc
equivalents:The last argument,
-march
has no equivalent with the Swift compiler. The Swift compiler should have a flag equivalent to-march
to produce code that has the same CPU features and Floating point ABI as the C code its linking against. Here is the example output I am getting withreadelf
when passing-target-cpu generic-rv64
to the Swift compiler:Meanwhile my C code like
libdispatch.so
output the following, notice the different output ofFlags
:Describe the solution you'd like
A Swift compiler flag like
-target-arch
which configures the underlying LLVM instance the same way Clang's-march
does would solve my problem.Describe alternatives you've considered
There is another argument
-target-cpu
which is the Swift equivalent of Clang's-march
and in some situations this can indirectly provide the desired arch targeted. For example,The Swift arguments
-target-cpu sifive-e20
would be equivalent to-mcpu=sifive-e20 -march=rv32imc
with Clang. The issue that arises is that there are a lot more RISCV CPU variants with different ABIs compared to mainstream processors like x86 and ARM, and submitting an LLVM patch to modifyllvm/include/llvm/Support/RISCVTargetParser.def
for each is both impractical and likely will never be merged. I'm my case I would have to add the following entry toRISCVTargetParser.def
for building for the Allwinner D1 CPU:The default
-target-cpu generic-rv64
does not satisfy my requirements nor do the other entries in that table.Additional context
I am building Swift 5.7 compiler with patches specific to enable RISCV outlined in SR-16005.
The text was updated successfully, but these errors were encountered: