Skip to content

Support -Crelocation-model #205

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

Closed
bjorn3 opened this issue Aug 17, 2022 · 5 comments
Closed

Support -Crelocation-model #205

bjorn3 opened this issue Aug 17, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@bjorn3
Copy link
Member

bjorn3 commented Aug 17, 2022

This is necessary for compiling rust-for-linux with cg_gcc.

@antoyo
Copy link
Contributor

antoyo commented Aug 19, 2022

It seems the LLVM codegen uses LLVMRustSetDSOLocal: I'm not exactly sure what is the GCC equivalent.

Adding the GCC flags -mcmodel=kernel -fno-pie when relocation_model is static allow compiling rust-for-linux with cg_gcc. But I'm not sure whether this would be correct.

@bjorn3
Copy link
Member Author

bjorn3 commented Aug 19, 2022

Adding the GCC flags -mcmodel=kernel -fno-pie when relocation_model is static allow compiling rust-for-linux with cg_gcc. But I'm not sure whether this would be correct.

Yeah, that worked for me too. There is a bug somewhere in how kernel module parameters are codegened causing the respective sample to crash during early boot though.

The code model option can be directly translated to -mcmodel=<code model> I think. The relocation model will probably need a match and then pass the appropriate -f argument corresponding to LLVM's relocation model.

@antoyo
Copy link
Contributor

antoyo commented Aug 19, 2022

My other change to allow running the kernel modules is to remove all the SIMD flags.

@bjorn3
Copy link
Member Author

bjorn3 commented Aug 19, 2022

I added the -mno-... flags that are passed to GCC when by linux when compiling C code. That worked too with the exception of disabling sse. Even with the soft float abi it complains. See #206 (comment).

@antoyo antoyo added the enhancement New feature or request label Sep 14, 2022
@antoyo
Copy link
Contributor

antoyo commented Jan 12, 2025

Implemented in #578.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants