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

Cross-compiling in LDC? #283

Open
TurkeyMan opened this issue Nov 12, 2024 · 2 comments
Open

Cross-compiling in LDC? #283

TurkeyMan opened this issue Nov 12, 2024 · 2 comments

Comments

@TurkeyMan
Copy link

I need to start doing ARM/RISC-V/XTENSA builds... LDC can target these platforms with compiler flags, but I'm not sure how to support this in the VS configuration matrix.
The wizard creates configurations that target Windows x86/x64, and it builds MS-COFF and uses the MS linker.
I need to add a new item to the 'platform' column in the matrix, where such configurations cause LDC to emit ELF (just needs to give -mtriple=riscv32-unknown-elf to the compiler), but also swap the MS linker for the LLVM linker... which seems more complicated.

I tried to hack this by cloning the x64 config and use a post-build step to link instead of the linker, but when I add a platform to the matrix, configurations for that new platform seem to have the LDC compiler disappear from the configuration completely...

What's the process to do this nicely?

@rainers
Copy link
Member

rainers commented Nov 12, 2024

For platforms that VS supports already (e.g. ARM), you can copy the D releated files from "c:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Microsoft\VC\v170\Platforms\x64\ImportBefore" and ImportAfter to the respective platform folder. This adds the compiler options to the setup pages. Adding a new platform seems to work by copying the full platform folder and editing Platform.Default.props replacing the platform name.

I guess you can also do this in a user/solution directory, but I have not tried this yet.

Regarding the linker, Visual D also replaces the linker if you enable demangling of the linker output, so you might have to adapt that. See LinkToolPath/LinkToolExe in "c:\Program Files (x86)\VisualD\msbuild\dcompile.targets" . This assumes compatible linker options, though.

@TurkeyMan
Copy link
Author

Ah yes, I was looking through the targets and project files for direct references to code that handled the D compiler; but I missed the ImportBefore and ImportAfter implicit inclusion mechanic. I got some stuff working.
VS is really pretty bad at extension of this nature. MSBuild just feels like a really bad design overall! I wonder why they commit to such a stupid architecture?

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

No branches or pull requests

2 participants