rules_swift icon indicating copy to clipboard operation
rules_swift copied to clipboard

How to build shared libraries using rule_swift (.so)?

Open renmeng0531 opened this issue 1 year ago • 6 comments

I’m having trouble compiling Swift code into a shared library using rule_swift(.so). I’ve tried many methods, but none of them have worked. Is rule_swift still not supported for this purpose? Are there any other ways to achieve this? Thank you for your answer

renmeng0531 avatar Dec 15 '23 01:12 renmeng0531

right now there isn't a swift rule for this https://github.com/bazelbuild/rules_swift/issues/7, if you're building for apple platforms you can use a rule from rules_apple to build a dynamic framework

keith avatar Dec 15 '23 04:12 keith

right now there isn't a swift rule for this #7, if you're building for apple platforms you can use a rule from rules_apple to build a dynamic framework

Thank you very much for your response. So, if I am on a Linux platform and want to compile a .so file, do I have to extend swift_binary myself, similar to how cc_binary works?

renmeng0531 avatar Dec 15 '23 04:12 renmeng0531

Yes, I think a change like that would be best

keith avatar Dec 15 '23 04:12 keith

Yes, I think a change like that would be best

OK, I understand now, thanks again :)

renmeng0531 avatar Dec 15 '23 04:12 renmeng0531

Just curious if some progress has been made on shared library support?

Documentation might need to be corrected, as currently it shows "linkstatic ... Set to False to build a .so or .dll. "

vsarunas avatar Jan 17 '24 14:01 vsarunas

No progress, you're right, that doc only applies to windows at the moment I believe, I'm not actually sure if setting linkstatic = False even on windows produces something valid

keith avatar Jan 17 '24 18:01 keith