-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
add targetType "unlinkedObjects" #1792
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request, @WebFreak001! |
|
bump |
|
@WebFreak001 this is good to go as soon as it is green. Maybe give it another push? |
|
I tried restarting the travis builds but I'm not really sure why it still hangs up in the dependency fetching of dub in old DMD versions. And the ICE on appveyor I'm also not sure what to do about |
|
The appveyor failure is unrelated and Travis seems to fail spuriously on other PRs too. |
|
even after the third run it still froze at the same place for both the old DMD versions. Are you sure this is just a random occurrence? |
this can be used to generate .o with DMD and also .s and .ll files with LDC. This is useful for having an external linker or build step taking in the unoptimized llvm files for example or cross linking to another system.
42837bf
to
f3260ad
Compare
| objectExtension = ".ll"; | ||
| } else if (buildsettings.dflags.canFind("-output-s", "--output-s")) { | ||
| objectExtension = ".s"; | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is unfortunately a bit more complex than that - there's -output-bc too, and you can freely combine all 4 switches (-output-{o,bc,ll,s}) to generate multiple files per object at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, all of the LDC/DMD specific logic needs to be abstracted away in the Compiler interface. Otherwise this will get messy real quick, especially with all other generators potentially needing to duplicate the logic.
|
I'm very interested in this feature. What was the status? It seems to need a rebase now. |
|
I hope this works out, seems im not the only one |
fix #266
this can be used to generate .o with DMD and also .s and .ll files with LDC. This is useful for having an external linker or build step taking in the unoptimized llvm files for example or cross linking to another system. With LDC it is also possible to compile the code to assembly files using this target type.
All generated object files using this target type are being written into
$DUB_TARGET_PATH/obj/. By default this is only .o files (or .obj on windows) but this is completely up to the compiler and dub doesn't restrict anything here. On LDC it's possible to specify-output-llto output LLVM IR files instead or-output-sto output assembly files instead and they will just be put in the object folder like anything else the compiler generates.This is pretty much equivalent to passing
-cand removing the-ofargument and only leaving-odto a user directory.Example:
this will generate object files for each source file and then afterwards link them together using an external command. In this practical use-case avr-gcc links all the object files together to one elf file and then converts it to a hex file which is ready for flashing on an embedded MCU. This is needed because ldc alone cannot properly perform this linking task.
Currently caching for this is only temporarily implemented for dmd obj files because ldc names the files after the module name (which is what should be done with dmd in the future too) which aren't determined yet.
This PR makes it more feasible to do embedded development and other more complex build types with dub. This is currently required for https://github.com/WebFreak001/avrd and the example use case can be seen in action there. (with also more complex LLVM usage for better optimization)